From: H.J. Lu Date: Thu, 9 Jun 2011 04:52:15 +0000 (+0000) Subject: Check relocations in note sections for --gc-sections. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=240077501163f169043c1d87ce05cd57f0e9ee3a;p=binutils-gdb.git Check relocations in note sections for --gc-sections. bfd/ 2011-06-08 H.J. Lu 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 PR ld/12851 * ld-elf/pr12851.d: New. * ld-elf/pr12851.s: Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5b678231843..f9b36883a45 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2011-06-08 H.J. Lu + + PR ld/12851 + * elflink.c (elf_gc_sweep): Don't check SHT_NOTE sections here. + (bfd_elf_gc_sections): Also check SHT_NOTE sections. + 2011-06-08 Tristan Gingold * makefile.vms (OBJS): Add elfxx-ia64.obj diff --git a/bfd/elflink.c b/bfd/elflink.c index 562217d3e11..639c3e7edf3 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; } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 31d542d8dad..dcefc10e978 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-06-08 H.J. Lu + + PR ld/12851 + * ld-elf/pr12851.d: New. + * ld-elf/pr12851.s: Likewise. + 2011-06-07 H.J. Lu * ld-elf/elf.exp: Build symbol3.a and symbol3w.a. diff --git a/ld/testsuite/ld-elf/pr12851.d b/ld/testsuite/ld-elf/pr12851.d new file mode 100644 index 00000000000..84aa59a8924 --- /dev/null +++ b/ld/testsuite/ld-elf/pr12851.d @@ -0,0 +1,14 @@ +#source: pr12851.s +#source: start.s +#ld: --gc-sections +#readelf: -s --wide +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* +#notarget: alpha-*-* hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* +#xfail: cr16-*-* crx-*-* +# generic linker targets don't support --gc-sections, nor do a bunch of others +# cr16 and crx use non-standard scripts with memory regions, which don't play +# well with unique group sections under ld -r. + +#... + +.* _.stapsdt.base +#pass diff --git a/ld/testsuite/ld-elf/pr12851.s b/ld/testsuite/ld-elf/pr12851.s new file mode 100644 index 00000000000..784b91fcb09 --- /dev/null +++ b/ld/testsuite/ld-elf/pr12851.s @@ -0,0 +1,5 @@ + .section .note.stapsdt,"?","note" + .dc.a _.stapsdt.base + .section .stapsdt.base,"a","progbits" +_.stapsdt.base: .space 1 + .size _.stapsdt.base,1