From dd98f8d276fb5538228255c4da43dd755738d151 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 18 May 2011 14:04:32 +0000 Subject: [PATCH] PR ld/12761 * elflink.c (elf_link_add_object_symbols): Process .gnu.warning sections when building shared libraries. * lib/ld-lib.exp (run_cc_link_tests): Add an optional 8th parameter - an expected warning message from the linker. * ld-elf/shared.exp (build_tests): Expect a warning message when building the libbarw.so library. * ld-elf/shared.exp: Run library building tests even when not building a native toolchain. --- bfd/ChangeLog | 6 ++++++ bfd/elflink.c | 3 ++- ld/testsuite/ChangeLog | 11 +++++++++++ ld/testsuite/ld-elf/shared.exp | 20 +++++++++++--------- ld/testsuite/lib/ld-lib.exp | 17 +++++++++++++++-- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 02b19414a3..b9a0473f4b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2011-05-18 Nick Clifton + + PR ld/12761 + * elflink.c (elf_link_add_object_symbols): Process .gnu.warning + sections when building shared libraries. + 2011-05-18 Rafał Krypa PR ld/12778 diff --git a/bfd/elflink.c b/bfd/elflink.c index b08b150845..4675aab82a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3423,7 +3423,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) .gnu.warning.SYMBOL are treated as warning symbols for the given symbol. This differs from .gnu.warning sections, which generate warnings when they are included in an output file. */ - if (info->executable) + /* PR 12761: Also generate this warning when building shared libraries. */ + if (info->executable || info->shared) { asection *s; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 0874ab441e..356151a464 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2011-05-18 Nick Clifton + + PR ld/12761 + * lib/ld-lib.exp (run_cc_link_tests): Add an optional 8th + parameter - an expected warning message from the linker. + * ld-elf/shared.exp (build_tests): Expect a warning message when + building the libbarw.so library. + + * ld-elf/shared.exp: Run library building tests even when not + building a native toolchain. + 2011-05-16 H.J. Lu * ld-scripts/phdrs.exp: Replace --private with diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index d0c3478b84..016d270974 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -25,12 +25,7 @@ if ![is_elf_format] { return } -# The following tests require running the executable generated by ld. -if ![isnative] { - return -} - -# Check if compiler works +# Check to see if the C compiler works if { [which $CC] == 0 } { return } @@ -47,7 +42,8 @@ set build_tests { {begin.c end.c} {} "libbar.so"} {"Build warn libbar.so" "-shared" "-fPIC" - {beginwarn.c end.c} {} "libbarw.so"} + {beginwarn.c end.c} {} "libbarw.so" + "C" "^.*\\\): warning: function foo is deprecated$"} {"Build hidden libbar.so" "-shared" "-fPIC" {begin.c endhidden.c} {} "libbarh.so"} @@ -156,6 +152,13 @@ set build_tests { {pr11138-2.c} {} "libpr11138-2.o"} } +run_cc_link_tests $build_tests + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + set run_tests { {"Run normal with libfoo.so" "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" @@ -280,11 +283,10 @@ set run_tests { {dummy.c} "pr11138b" "pr11138.out"} } -run_cc_link_tests $build_tests # NetBSD ELF systems do not currently support the .*_array sections. run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests -# Check if compiler works +# Check to see if the C++ compiler works if { [which $CXX] == 0 } { return } diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 34de7c8d39..62e0ff70d2 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -1243,6 +1243,7 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } { # 4:action and options. # 5:name of output file # 6:language (optional) +# 7:linker warnings (optional) # # Actions: # objdump: Apply objdump options on result. Compare with regex (last arg). @@ -1261,6 +1262,7 @@ proc run_cc_link_tests { ldtests } { global CFLAGS global CXXFLAGS global ar + global exec_output foreach testitem $ldtests { set testname [lindex $testitem 0] @@ -1270,6 +1272,7 @@ proc run_cc_link_tests { ldtests } { set actions [lindex $testitem 4] set binfile tmpdir/[lindex $testitem 5] set lang [lindex $testitem 6] + set warnings [lindex $testitem 7] set objfiles {} set is_unresolved 0 set failed 0 @@ -1306,8 +1309,18 @@ proc run_cc_link_tests { ldtests } { set failed 0 } } elseif { ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] } { - fail $testname - set failed 1 + # Check if exec_output is expected. + if { $warnings != "" } then { + verbose -log "returned with: <$exec_output>, expected: <$warnings>" + if { [regexp $warnings $exec_output] } then { + set failed 0 + } else { + set failed 1 + } + } else { + fail $testname + set failed 1 + } } else { set failed 0 } -- 2.34.1