summaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2012-06-12 06:31:05 +0000
committerAlan Modra <amodra@bigpond.net.au>2012-06-12 06:31:05 +0000
commita5a29dc08d74b30a5111ff66a9468e11ac8d9f82 (patch)
treece893b38f1436fc82aa3ef8cdad65960c28c7486 /bfd/elf.c
parent0a4f31a180a160179bd39f5b04ac341be28b0f0c (diff)
downloadgdb-a5a29dc08d74b30a5111ff66a9468e11ac8d9f82.tar.gz
PR ld/14207
* elf.c (_bfd_elf_map_sections_to_segments): Disregard bss type sections at end of PT_LOAD segment when searching for segment that contains end of relro extent.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 6de314bebd7..6755a4e3090 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4152,15 +4152,22 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
{
for (m = mfirst; m != NULL; m = m->next)
{
- if (m->p_type == PT_LOAD)
+ if (m->p_type == PT_LOAD
+ && m->count != 0
+ && m->sections[0]->vma >= info->relro_start
+ && m->sections[0]->vma < info->relro_end)
{
- asection *last = m->sections[m->count - 1];
- bfd_vma vaddr = m->sections[0]->vma;
- bfd_vma filesz = last->vma - vaddr + last->size;
+ i = m->count;
+ while (--i != (unsigned) -1)
+ if ((m->sections[i]->flags & (SEC_LOAD | SEC_HAS_CONTENTS))
+ == (SEC_LOAD | SEC_HAS_CONTENTS))
+ break;
+
+ if (i == (unsigned) -1)
+ continue;
- if (vaddr < info->relro_end
- && vaddr >= info->relro_start
- && (vaddr + filesz) >= info->relro_end)
+ if (m->sections[i]->vma + m->sections[i]->size
+ >= info->relro_end)
break;
}
}