Expand PHDR space only if there are pages available
authornorly <ny-git@enpas.org>
Wed, 26 Jun 2013 18:49:58 +0000 (19:49 +0100)
committernorly <ny-git@enpas.org>
Wed, 26 Jun 2013 18:49:58 +0000 (19:49 +0100)
src/libelfu/modelops/layout.c

index f8a30ed4e2d66b4a40eebbfd45fb70e77abeeb84..2fd610ce3b0808f6858854c0aca0666b3d5ac4d4 100644 (file)
@@ -101,7 +101,8 @@ static ElfuPhdr* appendPhdr(ElfuElf *me)
                                 &lowestOffs, &highestOffsEnd);
     if (phdr_maxsz < (me->ehdr.e_phnum + 1) * me->ehdr.e_phentsize
         && phdrmp == lowestAddr
-        && phdrmp == lowestOffs) {
+        && phdrmp == lowestOffs
+        && (lowestAddr->phdr.p_vaddr >= 2 * lowestAddr->phdr.p_align)) {
       ElfuPhdr *mp;
       ElfuScn *ms;
       GElf_Word size = ROUNDUP(me->ehdr.e_phentsize, phdrmp->phdr.p_align);