aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2007-02-14 14:15:52 +0000
committerH.J. Lu <hjl.tools@gmail.com>2007-02-14 14:15:52 +0000
commitfab4a87f1bd9ec148d24bdaca9faf0f6bded94aa (patch)
treece747bd2c90f481a27b2d8a487ff00b5372cd9f7
parentb279a55c19a2826fa8b5b08ec13e8df13ff5b9f5 (diff)
downloadgdb-fab4a87f1bd9ec148d24bdaca9faf0f6bded94aa.zip
gdb-fab4a87f1bd9ec148d24bdaca9faf0f6bded94aa.tar.gz
gdb-fab4a87f1bd9ec148d24bdaca9faf0f6bded94aa.tar.bz2
bfd/
2007-02-14 H.J. Lu <hongjiu.lu@intel.com> PR ld/3953 * elflink.c (_bfd_elf_add_default_symbol): Check warning symbol when adding default symbol. ld/testsuite/ 2007-02-14 H.J. Lu <hongjiu.lu@intel.com> PR ld/3953 * ld-elf/beginwarn.c: New file. * ld-elf/warn.out: Likewise. * ld-elf/shared.exp (build_tests): Add "Build warn libbar.so". (run_tests): Add "Run warn with versioned libfoo.so". * lib/ld-lib.exp (default_ld_relocate): Make exec_output global and remove target first. (default_ld_link): Likewise. (default_ld_simple_link): Likewise. (run_ld_link_exec_tests): Take an optional linker warning and check it. (default_ld_link): Check pruned linker output.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c4
-rw-r--r--ld/testsuite/ChangeLog17
-rw-r--r--ld/testsuite/ld-elf/beginwarn.c9
-rw-r--r--ld/testsuite/ld-elf/shared.exp7
-rw-r--r--ld/testsuite/ld-elf/warn.out3
-rw-r--r--ld/testsuite/lib/ld-lib.exp32
7 files changed, 75 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fd34de2..d8ebc0d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2007-02-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3953
+ * elflink.c (_bfd_elf_add_default_symbol): Check warning symbol
+ when adding default symbol.
+
2007-02-13 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c (create_linkage_sections): Use section ".branch_lt"
diff --git a/bfd/elflink.c b/bfd/elflink.c
index d76faae..00baf5d 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1556,6 +1556,10 @@ _bfd_elf_add_default_symbol (bfd *abfd,
hi = h;
}
+ /* Check if HI is a warning symbol. */
+ if (hi->root.type == bfd_link_hash_warning)
+ hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
+
/* If there is a duplicate definition somewhere, then HI may not
point to an indirect symbol. We will have reported an error to
the user in that case. */
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index d465c6d..2f75a9e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2007-02-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/3953
+ * ld-elf/beginwarn.c: New file.
+ * ld-elf/warn.out: Likewise.
+
+ * ld-elf/shared.exp (build_tests): Add "Build warn libbar.so".
+ (run_tests): Add "Run warn with versioned libfoo.so".
+
+ * lib/ld-lib.exp (default_ld_relocate): Make exec_output global
+ and remove target first.
+ (default_ld_link): Likewise.
+ (default_ld_simple_link): Likewise.
+ (run_ld_link_exec_tests): Take an optional linker warning and
+ check it.
+ (default_ld_link): Check pruned linker output.
+
2007-02-13 H.J. Lu <hongjiu.lu@intel.com>
* ld-scripts/default-script1.d: Expect extra symbols.
diff --git a/ld/testsuite/ld-elf/beginwarn.c b/ld/testsuite/ld-elf/beginwarn.c
new file mode 100644
index 0000000..ebe2819
--- /dev/null
+++ b/ld/testsuite/ld-elf/beginwarn.c
@@ -0,0 +1,9 @@
+static const char _evoke_link_warning_foo []
+ __attribute__ ((used, section (".gnu.warning.foo")))
+ = "function foo is deprecated";
+
+extern void foo (void);
+
+static void (*const init_array []) (void)
+ __attribute__ ((used, section (".init_array"), aligned (sizeof (void *))))
+ = { foo };
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 19c22a9..c38294c 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -42,6 +42,9 @@ set build_tests {
{"Build libbar.so"
"-shared" "-fPIC"
{begin.c end.c} {} "libbar.so"}
+ {"Build warn libbar.so"
+ "-shared" "-fPIC"
+ {beginwarn.c end.c} {} "libbarw.so"}
{"Build hidden libbar.so"
"-shared" "-fPIC"
{begin.c endhidden.c} {} "libbarh.so"}
@@ -126,6 +129,10 @@ set run_tests {
{"Run normal with versioned libfoo.so"
"tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
{main.c} "normalv" "normal.out"}
+ {"Run warn with versioned libfoo.so"
+ "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
+ {main.c} "warn" "warn.out"
+ "" "" "^.*\\\): warning: function foo is deprecated$"}
{"Run protected with versioned libfoo.so"
"tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
{main.c} "protected" "normal.out"}
diff --git a/ld/testsuite/ld-elf/warn.out b/ld/testsuite/ld-elf/warn.out
new file mode 100644
index 0000000..ba836ce
--- /dev/null
+++ b/ld/testsuite/ld-elf/warn.out
@@ -0,0 +1,3 @@
+TEST2
+TEST2
+MAIN
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index bee8f14..acfe0df 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -39,12 +39,15 @@ proc default_ld_version { ld } {
proc default_ld_relocate { ld target objects } {
global HOSTING_EMU
global host_triplet
+ global exec_output
if { [which $ld] == 0 } then {
perror "$ld does not exist"
return 0
}
+ catch "exec rm -f $target" exec_output
+
verbose -log "$ld $HOSTING_EMU -o $target -r $objects"
catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
@@ -115,6 +118,7 @@ proc default_ld_link { ld target objects } {
global LIBS
global host_triplet
global link_output
+ global exec_output
set objs "$HOSTING_CRT0 $objects"
set libs "$LIBS $HOSTING_LIBS"
@@ -129,14 +133,17 @@ proc default_ld_link { ld target objects } {
} else {
set flags ""
}
+
+ catch "exec rm -f $target" exec_output
+
verbose -log "$ld $HOSTING_EMU $flags -o $target $objs $libs"
catch "exec $ld $HOSTING_EMU $flags -o $target $objs $libs" link_output
set exec_output [prune_warnings $link_output]
- if [string match "" $link_output] then {
+ if [string match "" $exec_output] then {
return 1
} else {
- verbose -log "$link_output"
+ verbose -log "$exec_output"
return 0
}
}
@@ -147,6 +154,7 @@ proc default_ld_simple_link { ld target objects } {
global host_triplet
global link_output
global gcc_ld_flag
+ global exec_output
if { [which $ld] == 0 } then {
perror "$ld does not exist"
@@ -172,6 +180,8 @@ proc default_ld_simple_link { ld target objects } {
set flags "$gcc_ld_flag $flags"
}
+ catch "exec rm -f $target" exec_output
+
verbose -log "$ld $flags -o $target $objects"
catch "exec $ld $flags -o $target $objects" link_output
@@ -1249,7 +1259,7 @@ if ![string length [info proc prune_warnings]] {
# targets_to_xfail is a list of target triplets to be xfailed.
# ldtests contains test-items with 3 items followed by 1 lists, 2 items
-# and 2 optional items:
+# and 3 optional items:
# 0:name
# 1:ld options
# 2:assembler options
@@ -1258,6 +1268,7 @@ if ![string length [info proc prune_warnings]] {
# 5:expected output
# 6:compiler flags (optional)
# 7:language (optional)
+# 8:linker warning (optional)
proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
global ld
@@ -1269,6 +1280,7 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
global CXX
global CFLAGS
global errcnt
+ global exec_output
foreach testitem $ldtests {
foreach target $targets_to_xfail {
@@ -1282,6 +1294,7 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
set expfile [lindex $testitem 5]
set cflags [lindex $testitem 6]
set lang [lindex $testitem 7]
+ set warning [lindex $testitem 8]
set objfiles {}
set failed 0
@@ -1322,6 +1335,19 @@ proc run_ld_link_exec_tests { targets_to_xfail ldtests } {
set failed 1
} else {
set failed 0
+ }
+
+ # Check if exec_output is expected.
+ if { $warning != "" } then {
+ verbose -log "returned with: <$exec_output>, expected: <$warning>"
+ if { [regexp $warning $exec_output] } then {
+ set failed 0
+ } else {
+ set failed 1
+ }
+ }
+
+ if { $failed == 0 } {
send_log "Running: $binfile > $binfile.out\n"
verbose "Running: $binfile > $binfile.out"
catch "exec $binfile > $binfile.out" exec_output