aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjakub <jakub@94c539fb-cf18-0410-b60f-edeeb537fa16>2006-10-27 12:36:43 +0000
committerjakub <jakub@94c539fb-cf18-0410-b60f-edeeb537fa16>2006-10-27 12:36:43 +0000
commit5f4c3234bea7bd7efb186e955b93a3f74e86311c (patch)
tree252a89c229a201502cd2e2f00ad67f6f9d128165
parentdd38e536a0a214c3ee0a40020964495185fc2dfa (diff)
downloadprelink-cross-5f4c3234bea7bd7efb186e955b93a3f74e86311c.tar.gz
prelink-cross-5f4c3234bea7bd7efb186e955b93a3f74e86311c.tar.bz2
prelink-cross-5f4c3234bea7bd7efb186e955b93a3f74e86311c.zip
* src/space.c (find_readonly_space): Don't place the new section
in the PT_PHDR segment. git-svn-id: http://sourceware.org/svn/prelink@144 94c539fb-cf18-0410-b60f-edeeb537fa16
-rw-r--r--trunk/ChangeLog3
-rw-r--r--trunk/src/space.c16
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)