From: Tristan Gingold Date: Mon, 24 Sep 2012 12:22:49 +0000 (+0000) Subject: bfd/ X-Git-Tag: binutils-2_23~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1193a9738951ef5bf76eeb21e4bae1ec02656bd6;p=thirdparty%2Fbinutils-gdb.git bfd/ 2012-09-18 H.J. Lu PR ld/14591 * elf-bfd.h (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. * elf32-sh-symbian.c (sh_symbian_relocate_section): Update _bfd_elf_merge_symbol call. * elflink.c (_bfd_elf_merge_symbol): Add an argument to return if the old symbol is weak. (_bfd_elf_add_default_symbol): Update _bfd_elf_merge_symbol call. (elf_link_add_object_symbols): Don't update symbol type from a weak definition. Update symbol type from a common symbol when overriding a weak symbol. ld/testsuite/ 2012-09-18 H.J. Lu PR ld/14591 * ld-elf/comm-data.exp (run_ld_link_tests): Add comm-data3a and comm-data3b tests. * ld-ifunc/ifunc.exp (run_ld_link_exec_tests): New. * ld-elf/comm-data3.sd: New file. * ld-elf/comm-data3a.s: Likewise. * ld-elf/comm-data3b.s: Likewise. * ld-ifunc/ifunc-17a-i386.d: Likewise. * ld-ifunc/ifunc-17a-x86-64.d: Likewise. * ld-ifunc/ifunc-17a.s: Likewise. * ld-ifunc/ifunc-17b-i386.d: Likewise. * ld-ifunc/ifunc-17b-x86-64.d: Likewise. * ld-ifunc/ifunc-17b.s: Likewise. * ld-ifunc/ifunc-common-1.out: Likewise. * ld-ifunc/ifunc-common-1a.c: Likewise. * ld-ifunc/ifunc-common-1b.c: Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5516d3480e9..0309325f0fe 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,20 @@ +2012-09-18 H.J. Lu + + PR ld/14591 + * elf-bfd.h (_bfd_elf_merge_symbol): Add an argument to return + if the old symbol is weak. + + * elf32-sh-symbian.c (sh_symbian_relocate_section): Update + _bfd_elf_merge_symbol call. + + * elflink.c (_bfd_elf_merge_symbol): Add an argument to return + if the old symbol is weak. + (_bfd_elf_add_default_symbol): Update _bfd_elf_merge_symbol + call. + (elf_link_add_object_symbols): Don't update symbol type from a + weak definition. Update symbol type from a common symbol when + overriding a weak symbol. + 2012-09-17 Walter Lee * elf32-tilepro.c (tilepro_elf_relocate_section): Remove unused diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 6a44912fd48..2ae8538f040 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1967,7 +1967,7 @@ extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr extern bfd_boolean _bfd_elf_merge_symbol (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *, - asection **, bfd_vma *, unsigned int *, + asection **, bfd_vma *, bfd_boolean *, unsigned int *, struct elf_link_hash_entry **, bfd_boolean *, bfd_boolean *, bfd_boolean *, bfd_boolean *); diff --git a/bfd/elf32-sh-symbian.c b/bfd/elf32-sh-symbian.c index 0882d52b9a4..1f03dbc40e5 100644 --- a/bfd/elf32-sh-symbian.c +++ b/bfd/elf32-sh-symbian.c @@ -497,7 +497,7 @@ sh_symbian_relocate_section (bfd * output_bfd, if (! _bfd_elf_merge_symbol (input_bfd, info, ptr->new_name, & new_sym, & psec, & new_value, NULL, - & new_hash, & skip, + NULL, & new_hash, & skip, & override, & type_change_ok, & size_change_ok)) { diff --git a/bfd/elflink.c b/bfd/elflink.c index 3ef3f9bf5f6..50e65efe652 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -938,6 +938,7 @@ _bfd_elf_merge_symbol (bfd *abfd, Elf_Internal_Sym *sym, asection **psec, bfd_vma *pvalue, + bfd_boolean *pold_weak, unsigned int *pold_alignment, struct elf_link_hash_entry **sym_hash, bfd_boolean *skip, @@ -1040,6 +1041,8 @@ _bfd_elf_merge_symbol (bfd *abfd, newweak = bind == STB_WEAK; oldweak = (h->root.type == bfd_link_hash_defweak || h->root.type == bfd_link_hash_undefweak); + if (pold_weak) + *pold_weak = oldweak; /* In cases involving weak versioned symbols, we may wind up trying to merge a symbol with itself. Catch that here, to avoid the @@ -1662,7 +1665,7 @@ _bfd_elf_add_default_symbol (bfd *abfd, size_change_ok = FALSE; sec = *psec; if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value, - NULL, &hi, &skip, &override, + NULL, NULL, &hi, &skip, &override, &type_change_ok, &size_change_ok)) return FALSE; @@ -1771,7 +1774,7 @@ nondefault: size_change_ok = FALSE; sec = *psec; if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value, - NULL, &hi, &skip, &override, + NULL, NULL, &hi, &skip, &override, &type_change_ok, &size_change_ok)) return FALSE; @@ -3865,6 +3868,8 @@ error_free_dyn: bfd_boolean size_change_ok; bfd_boolean type_change_ok; bfd_boolean new_weakdef; + bfd_boolean new_weak; + bfd_boolean old_weak; bfd_boolean override; bfd_boolean common; unsigned int old_alignment; @@ -3997,6 +4002,7 @@ error_free_dyn: size_change_ok = FALSE; type_change_ok = bed->type_change_ok; + old_weak = FALSE; old_alignment = 0; old_bfd = NULL; new_sec = sec; @@ -4142,7 +4148,7 @@ error_free_dyn: } if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, - &value, &old_alignment, + &value, &old_weak, &old_alignment, sym_hash, &skip, &override, &type_change_ok, &size_change_ok)) goto error_free_vers; @@ -4204,10 +4210,11 @@ error_free_dyn: if (is_elf_hash_table (htab)) h->unique_global = (flags & BSF_GNU_UNIQUE) != 0; + new_weak = (flags & BSF_WEAK) != 0; new_weakdef = FALSE; if (dynamic && definition - && (flags & BSF_WEAK) != 0 + && new_weak && !bed->is_function_type (ELF_ST_TYPE (isym->st_info)) && is_elf_hash_table (htab) && h->u.weakdef == NULL) @@ -4336,7 +4343,9 @@ error_free_dyn: h->size = h->root.u.c.size; if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE - && (definition || h->type == STT_NOTYPE)) + && ((definition && !new_weak) + || (old_weak && h->root.type == bfd_link_hash_common) + || h->type == STT_NOTYPE)) { unsigned int type = ELF_ST_TYPE (isym->st_info); diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 6623c409717..be12587ff31 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2012-09-18 H.J. Lu + + PR ld/14591 + * ld-elf/comm-data.exp (run_ld_link_tests): Add comm-data3a and + comm-data3b tests. + + * ld-ifunc/ifunc.exp (run_ld_link_exec_tests): New. + + * ld-elf/comm-data3.sd: New file. + * ld-elf/comm-data3a.s: Likewise. + * ld-elf/comm-data3b.s: Likewise. + * ld-ifunc/ifunc-17a-i386.d: Likewise. + * ld-ifunc/ifunc-17a-x86-64.d: Likewise. + * ld-ifunc/ifunc-17a.s: Likewise. + * ld-ifunc/ifunc-17b-i386.d: Likewise. + * ld-ifunc/ifunc-17b-x86-64.d: Likewise. + * ld-ifunc/ifunc-17b.s: Likewise. + * ld-ifunc/ifunc-common-1.out: Likewise. + * ld-ifunc/ifunc-common-1a.c: Likewise. + * ld-ifunc/ifunc-common-1b.c: Likewise. + 2012-09-10 Hans-Peter Nilsson * ld-mmix/sec-1.d, ld-mmix/sec-3.d: Force end-of-section symbols diff --git a/ld/testsuite/ld-elf/comm-data.exp b/ld/testsuite/ld-elf/comm-data.exp index 2258afb5f4d..1c75f552160 100644 --- a/ld/testsuite/ld-elf/comm-data.exp +++ b/ld/testsuite/ld-elf/comm-data.exp @@ -75,4 +75,24 @@ run_ld_link_tests [list \ } \ "comm-data" \ ] \ + [list \ + "$testname 3a" \ + "-static" \ + "" \ + { comm-data3a.s comm-data3b.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3a" \ + ] \ + [list \ + "$testname 3b" \ + "-static" \ + "" \ + { comm-data3b.s comm-data3a.s } \ + { \ + { readelf -s comm-data3.sd } \ + } \ + "comm-data3b" \ + ] \ ] diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index 3eef3a9e03a..df913d89bdb 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -347,6 +347,27 @@ if { $verbose < 1 } { remote_file host delete "tmpdir/static_nonifunc_prog" } +run_ld_link_exec_tests [] [list \ + [list \ + "Common symbol override ifunc test 1a" \ + "-static" \ + "" \ + { ifunc-common-1a.c ifunc-common-1b.c } \ + "ifunc-common-1a" \ + "ifunc-common-1.out" \ + "-g" \ + ] \ + [list \ + "Common symbol override ifunc test 1b" \ + "-static" \ + "" \ + { ifunc-common-1b.c ifunc-common-1a.c } \ + "ifunc-common-1b" \ + "ifunc-common-1.out" \ + "-g" \ + ] \ +] + set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] foreach t $test_list { # We need to strip the ".d", but can leave the dirname.