diff options
-rw-r--r-- | trunk/ChangeLog | 3 | ||||
-rw-r--r-- | trunk/src/space.c | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/trunk/ChangeLog b/trunk/ChangeLog index f0ee2cb..27ea993 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,5 +1,8 @@ 2006-10-24 Richard Sandiford <richard@codesourcery.com> + * src/space.c (find_readonly_space): Don't place the new section + in the PT_PHDR segment. + * src/prelink.h (data_iterator): New structure. (init_data_iterator): Declare. (get_data_from_iterator): Likewise. diff --git a/trunk/src/space.c b/trunk/src/space.c index 155feba..4fea7c7 100644 --- a/trunk/src/space.c +++ b/trunk/src/space.c @@ -247,9 +247,19 @@ find_readonly_space (DSO *dso, GElf_Shdr *add, GElf_Ehdr *ehdr, int after = -1, min; if (phdr[i].p_offset < ehdr->e_phoff) - start += ehdr->e_phoff - + ehdr->e_phnum * ehdr->e_phentsize - - phdr[i].p_offset; + { + for (j = 0; j < ehdr->e_phnum; j++) + if (phdr[j].p_type == PT_PHDR + && phdr[j].p_offset == ehdr->e_phoff + && phdr[j].p_filesz >= ehdr->e_phnum * ehdr->e_phentsize) + break; + start += ehdr->e_phoff; + if (j < ehdr->e_phnum) + start += phdr[j].p_filesz; + else + start += ehdr->e_phnum * ehdr->e_phentsize; + start -= phdr[i].p_offset; + } start = (start + add->sh_addralign - 1) & ~(add->sh_addralign - 1); for (j = 1; j < ehdr->e_shnum; ++j) if ((shdr[j].sh_flags & SHF_ALLOC) |