aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-06-09 04:52:15 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-06-09 04:52:15 +0000
commit240077501163f169043c1d87ce05cd57f0e9ee3a (patch)
treefb6ec993fc0b8832f3ee562ccc8849c4cae36e0e /bfd/elflink.c
parent61220854262b44474cf3e95f7594d69a73fbb63a (diff)
downloadgdb-240077501163f169043c1d87ce05cd57f0e9ee3a.zip
gdb-240077501163f169043c1d87ce05cd57f0e9ee3a.tar.gz
gdb-240077501163f169043c1d87ce05cd57f0e9ee3a.tar.bz2
Check relocations in note sections for --gc-sections.
bfd/ 2011-06-08 H.J. Lu <hongjiu.lu@intel.com> PR ld/12851 * elflink.c (elf_gc_sweep): Don't check SHT_NOTE sections here. (bfd_elf_gc_sections): Also check SHT_NOTE sections. ld/testsuite/ 2011-06-08 H.J. Lu <hongjiu.lu@intel.com> PR ld/12851 * ld-elf/pr12851.d: New. * ld-elf/pr12851.s: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 562217d..639c3e7 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11728,10 +11728,9 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
o->gc_mark = first->gc_mark;
}
else if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0
- || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0
- || elf_section_data (o)->this_hdr.sh_type == SHT_NOTE)
+ || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
{
- /* Keep debug, special and SHT_NOTE sections. */
+ /* Keep debug and special sections. */
o->gc_mark = 1;
}
@@ -12013,8 +12012,12 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
continue;
+ /* Also keep SHT_NOTE sections. */
for (o = sub->sections; o != NULL; o = o->next)
- if ((o->flags & (SEC_EXCLUDE | SEC_KEEP)) == SEC_KEEP && !o->gc_mark)
+ if ((o->flags & SEC_EXCLUDE) == 0
+ && ((o->flags & SEC_KEEP) != 0
+ || elf_section_data (o)->this_hdr.sh_type == SHT_NOTE)
+ && !o->gc_mark)
if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
return FALSE;
}