From: H.J. Lu Date: Wed, 5 Oct 2011 16:39:55 +0000 (+0000) Subject: Fix --gc-sections failure with symbol versioning. X-Git-Tag: binutils-2_22~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57974e6ea761de52b20d2d77d0a528cfbea3bd04;p=thirdparty%2Fbinutils-gdb.git Fix --gc-sections failure with symbol versioning. bfd/ 2011-09-29 H.J. Lu PR ld/13195 * elflink.c (_bfd_elf_merge_symbol): Don't set dynamic_def when clearing def_dynamic. (elf_link_add_object_symbols): Likewise. Set dynamic_def when setting def_dynamic. (bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is versioned. ld/testsuite/ 2011-09-29 H.J. Lu PR ld/13195 * ld-elf/elf.exp: Add a C link testcase for PR ld/13195. * ld-elf/pr13195.c: New. * ld-elf/pr13195.d: Likewise. * ld-elf/pr13195.s: Likewise. * ld-elf/pr13195.t: Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d5af9dbced0..c5334c95ab2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2011-09-29 H.J. Lu + + PR ld/13195 + * elflink.c (_bfd_elf_merge_symbol): Don't set dynamic_def when + clearing def_dynamic. + (elf_link_add_object_symbols): Likewise. Set dynamic_def when + setting def_dynamic. + (bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is + versioned. + 2011-09-29 Alan Modra PR ld/13233 diff --git a/bfd/elflink.c b/bfd/elflink.c index 9bd2c5c9d42..5d181f7993c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1238,7 +1238,6 @@ _bfd_elf_merge_symbol (bfd *abfd, { h->def_dynamic = 0; h->ref_dynamic = 1; - h->dynamic_def = 1; } /* FIXME: Should we check type and size for protected symbol? */ h->size = 0; @@ -4353,7 +4352,6 @@ error_free_dyn: { h->def_dynamic = 0; h->ref_dynamic = 1; - h->dynamic_def = 1; } } if (! info->executable @@ -4366,7 +4364,10 @@ error_free_dyn: if (! definition) h->ref_dynamic = 1; else - h->def_dynamic = 1; + { + h->def_dynamic = 1; + h->dynamic_def = 1; + } if (h->def_regular || h->ref_regular || (h->u.weakdef != NULL @@ -11915,8 +11916,9 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf) && h->def_regular && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN - && !bfd_hide_sym_by_version (info->version_info, - h->root.root.string)))) + && (strchr (h->root.root.string, ELF_VER_CHR) != NULL + || !bfd_hide_sym_by_version (info->version_info, + h->root.root.string))))) h->root.u.def.section->flags |= SEC_KEEP; return TRUE; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index be38879a39e..482d2b7fcac 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2011-09-29 H.J. Lu + + PR ld/13195 + * ld-elf/elf.exp: Add a C link testcase for PR ld/13195. + + * ld-elf/pr13195.c: New. + * ld-elf/pr13195.d: Likewise. + * ld-elf/pr13195.s: Likewise. + * ld-elf/pr13195.t: Likewise. + 2011-09-16 H.J. Lu * ld-elf/pr12975.d: Only run for *-*-linux* and *-*-gnu* diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 4a00b81ced0..866c86682ec 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -138,6 +138,11 @@ if ![isnative] { return } +run_cc_link_tests { + {"PR ld/13195" "-Wl,--gc-sections" "" + {pr13195.c} {} "pr13195"} +} + set array_tests { {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"} {"init array" "" "" {init.c} "init" "init.out"}