summaryrefslogtreecommitdiff
path: root/src/libelfu
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-06-26 18:44:42 +0100
committernorly <ny-git@enpas.org>2013-06-26 18:44:42 +0100
commitba9a2612324c2cfaf63d64a722a1a0ecc5793de7 (patch)
tree57292a1375d84bd5e386fe762f5721bf4167496b /src/libelfu
parenta417ad3293da4293cfcc4b43ea146a272247d9ea (diff)
Expand downwards only if there is enough space
Diffstat (limited to 'src/libelfu')
-rw-r--r--src/libelfu/modelops/layout.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libelfu/modelops/layout.c b/src/libelfu/modelops/layout.c
index 4026e58..f8a30ed 100644
--- a/src/libelfu/modelops/layout.c
+++ b/src/libelfu/modelops/layout.c
@@ -240,7 +240,8 @@ GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
} else if (((w && (lowestAddr->phdr.p_flags & PF_W))
|| (x && (lowestAddr->phdr.p_flags & PF_X)))
&& /* Enough space to expand downwards? */
- (lowestAddr->phdr.p_vaddr > 3 * lowestAddr->phdr.p_align)
+ (lowestAddr->phdr.p_vaddr >= ((2 * lowestAddr->phdr.p_align)
+ + ROUNDUP(size, lowestAddr->phdr.p_align)))
/* Merging only works if the LOAD is the first both in file and mem */
&& lowestAddr == lowestOffs) {
/* Need to prepend or split up the PHDR. */