From a26587bab514ebd91e3463018462acc6855826f1 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 23 Jul 2007 09:56:19 +0000 Subject: [PATCH] bfd/ * elflink.c (_bfd_elf_fix_symbol_flags): Only assert the type of weakdef->root.type if weakdef has no regular definition. ld/testsuite/ * ld-elf/weak-dyn-1a.s, ld-elf/weak-dyn-1b.s, ld-elf/weak-dyn-1.ld, * ld-elf/weak-dyn-1.rd: New test. * ld-elf/elf.exp: Run it. --- bfd/ChangeLog | 5 +++++ bfd/elflink.c | 9 +++++---- ld/testsuite/ChangeLog | 6 ++++++ ld/testsuite/ld-elf/elf.exp | 13 +++++++++++++ ld/testsuite/ld-elf/weak-dyn-1.ld | 8 ++++++++ ld/testsuite/ld-elf/weak-dyn-1.rd | 3 +++ ld/testsuite/ld-elf/weak-dyn-1a.s | 13 +++++++++++++ ld/testsuite/ld-elf/weak-dyn-1b.s | 3 +++ 8 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 ld/testsuite/ld-elf/weak-dyn-1.ld create mode 100644 ld/testsuite/ld-elf/weak-dyn-1.rd create mode 100644 ld/testsuite/ld-elf/weak-dyn-1a.s create mode 100644 ld/testsuite/ld-elf/weak-dyn-1b.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6dce330..5d3c939 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-07-23 Richard Sandiford + + * elflink.c (_bfd_elf_fix_symbol_flags): Only assert the type + of weakdef->root.type if weakdef has no regular definition. + 2007-07-22 Adam Nemet * elfxx-mips.c (struct mips_elf_link_hash_table): Add new field diff --git a/bfd/elflink.c b/bfd/elflink.c index a68d736..cd8b756 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2492,8 +2492,6 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, BFD_ASSERT (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak); - BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined - || weakdef->root.type == bfd_link_hash_defweak); BFD_ASSERT (weakdef->def_dynamic); /* If the real definition is defined by a regular object file, @@ -2502,8 +2500,11 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, if (weakdef->def_regular) h->u.weakdef = NULL; else - (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, - h); + { + BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined + || weakdef->root.type == bfd_link_hash_defweak); + (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h); + } } return TRUE; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 2f49bdd..4b82886 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-07-23 Richard Sandiford + + * ld-elf/weak-dyn-1a.s, ld-elf/weak-dyn-1b.s, ld-elf/weak-dyn-1.ld, + * ld-elf/weak-dyn-1.rd: New test. + * ld-elf/elf.exp: Run it. + 2007-07-13 Nathan Sidwell * ld-scripts/assert.t: Tweak to avoid relying on empty's VMA being diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 51780d3..20e9980 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -36,6 +36,19 @@ foreach t $test_list { run_dump_test [file rootname $t] } +if { [istarget *-*-linux*] } { + run_ld_link_tests { + {"Weak symbols in dynamic objects 1 (support)" + "-shared" "" {weak-dyn-1a.s} + {} + "libweakdyn1a.so"} + {"Weak symbols in dynamic objects 1 (main test)" + "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" {weak-dyn-1b.s} + {{readelf {--relocs --wide} weak-dyn-1.rd}} + "libweakdyn1b.so"} + } +} + # The following tests require running the executable generated by ld. if ![isnative] { return diff --git a/ld/testsuite/ld-elf/weak-dyn-1.ld b/ld/testsuite/ld-elf/weak-dyn-1.ld new file mode 100644 index 0000000..495b712 --- /dev/null +++ b/ld/testsuite/ld-elf/weak-dyn-1.ld @@ -0,0 +1,8 @@ +SECTIONS +{ + . = 0x800000; + PROVIDE (bar = .); + .data : { + *(.data) + } +} diff --git a/ld/testsuite/ld-elf/weak-dyn-1.rd b/ld/testsuite/ld-elf/weak-dyn-1.rd new file mode 100644 index 0000000..169abd8 --- /dev/null +++ b/ld/testsuite/ld-elf/weak-dyn-1.rd @@ -0,0 +1,3 @@ +#... +0+800000 .* foo.* +#pass diff --git a/ld/testsuite/ld-elf/weak-dyn-1a.s b/ld/testsuite/ld-elf/weak-dyn-1a.s new file mode 100644 index 0000000..d77c32e --- /dev/null +++ b/ld/testsuite/ld-elf/weak-dyn-1a.s @@ -0,0 +1,13 @@ + .globl foo + .weak foo + .type foo,%object + .size foo,1 + + .globl bar + .type bar,%object + .size bar,1 + + .data +foo: +bar: + .dc.a data_begin diff --git a/ld/testsuite/ld-elf/weak-dyn-1b.s b/ld/testsuite/ld-elf/weak-dyn-1b.s new file mode 100644 index 0000000..a3c3fa5 --- /dev/null +++ b/ld/testsuite/ld-elf/weak-dyn-1b.s @@ -0,0 +1,3 @@ + .data + .dc.a foo + .dc.a data_begin -- 2.7.4