projects
/
centaur.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2affa1e
)
Minor fixes to PHDR expansion to lower addresses
author
norly
<ny-git@enpas.org>
Sat, 22 Jun 2013 00:02:29 +0000
(
01:02
+0100)
committer
norly
<ny-git@enpas.org>
Sat, 22 Jun 2013 00:02:29 +0000
(
01:02
+0100)
src/libelfu/modelops/layout.c
patch
|
blob
|
history
diff --git
a/src/libelfu/modelops/layout.c
b/src/libelfu/modelops/layout.c
index 65a713df9e19110535e6144277eecbbf8c4d7ad6..afa12c94f02b2e61d8f0018c57130ade72710876 100644
(file)
--- a/
src/libelfu/modelops/layout.c
+++ b/
src/libelfu/modelops/layout.c
@@
-161,8
+161,10
@@
GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
*injPhdr = last;
}
return last->phdr.p_vaddr + (injOffset - last->phdr.p_offset);
*injPhdr = last;
}
return last->phdr.p_vaddr + (injOffset - last->phdr.p_offset);
- } else if ((w && (first->phdr.p_flags & PF_W))
- || (x && (first->phdr.p_flags & PF_X))) {
+ } else if (((w && (first->phdr.p_flags & PF_W))
+ || (x && (first->phdr.p_flags & PF_X)))
+ && /* Enough space to expand downwards? */
+ (first->phdr.p_vaddr > 3 * first->phdr.p_align)) {
/* Need to prepend or split up the PHDR. */
GElf_Off injOffset = OFFS_END(first->phdr.p_offset, first->phdr.p_filesz);
ElfuScn *ms;
/* Need to prepend or split up the PHDR. */
GElf_Off injOffset = OFFS_END(first->phdr.p_offset, first->phdr.p_filesz);
ElfuScn *ms;
@@
-194,7
+196,7
@@
GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
}
/* Move other PHDRs and sections */
}
/* Move other PHDRs and sections */
- assert(size <= shiftStuffAtAfterOffset(me, injOffset, size));
+ assert(size <= shiftStuffAtAfterOffset(me, injOffset
+ 1
, size));
/* Remap ourselves */
first->phdr.p_vaddr -= size;
/* Remap ourselves */
first->phdr.p_vaddr -= size;