summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-05-25 00:45:39 +0100
committernorly <ny-git@enpas.org>2013-05-25 00:45:39 +0100
commit6a6a9a2e94f14470f26c2e74767b5ebb48dd7df2 (patch)
treef190b49db77c187070400eed4806eba67d277597 /src/model
parent264965b9323f90f1a834fb2d80c362aa91fbb5e5 (diff)
Fix alignment error in mInsertSpaceBefore
Diffstat (limited to 'src/model')
-rw-r--r--src/model/insert.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/model/insert.c b/src/model/insert.c
index 312be26..b18aa8a 100644
--- a/src/model/insert.c
+++ b/src/model/insert.c
@@ -27,6 +27,11 @@ GElf_Xword elfu_mInsertSpaceBefore(ElfuElf *me, GElf_Off off, GElf_Xword size)
assert(me);
+ /* Round up size to 4096 bytes to keep page alignment on x86 when
+ * remapping existing data to lower addresses. */
+ size += (4096 - (size % 4096)) % 4096;
+ // TODO: Find alignment size by checking p_align in PHDRs
+
/* Move SHDRs and PHDRs */
if (me->ehdr.e_shoff >= off) {
me->ehdr.e_shoff += size;