From: norly Date: Fri, 24 May 2013 23:45:39 +0000 (+0100) Subject: Fix alignment error in mInsertSpaceBefore X-Git-Url: https://git.enpas.org/?p=centaur.git;a=commitdiff_plain;h=6a6a9a2e94f14470f26c2e74767b5ebb48dd7df2 Fix alignment error in mInsertSpaceBefore --- 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;