summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;