Index: src/space.c =================================================================== --- src/space.c (revision 159199) +++ src/space.c (working copy) @@ -498,9 +498,20 @@ find_readonly_space (DSO *dso, GElf_Shdr } /* We have to create new PT_LOAD if at all possible. */ + for (j = 0; j < ehdr->e_phnum; ++j) + if (phdr[j].p_type == PT_NULL) + break; + + if (j < ehdr->e_phnum) + { + memmove (phdr, &phdr[j + 1], + (ehdr->e_phnum - j - 1) * sizeof (GElf_Phdr)); + ehdr->e_phnum--; + } + else + { addr = ehdr->e_phoff + (ehdr->e_phnum + 1) * ehdr->e_phentsize; for (j = 1; j < ehdr->e_shnum; ++j) - { if (addr > shdr[j].sh_offset) { GElf_Addr start, addstart, endaddr, *old_addr;