Commit | Line | Data |
---|---|---|
7dc542b2 | 1 | # Test handling of weak undefined symbols |
5a68afcf | 2 | # Copyright 2001, 2002, 2004, 2005, 2007, 2010, 2011, 2012 |
a2b64bed NC |
3 | # Free Software Foundation, Inc. |
4 | # | |
f96b4a7b NC |
5 | # This file is part of the GNU Binutils. |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
a2b64bed | 8 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
a2b64bed | 10 | # (at your option) any later version. |
f96b4a7b | 11 | # |
a2b64bed NC |
12 | # This program is distributed in the hope that it will be useful, |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
f96b4a7b | 16 | # |
a2b64bed NC |
17 | # You should have received a copy of the GNU General Public License |
18 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
7dc542b2 PB |
21 | |
22 | set testname "weak undefined symbols" | |
23 | ||
24 | # This test only works for ELF targets. It ought to work for some | |
25 | # a.out targets, but it doesn't. | |
26 | ||
27 | if { ![istarget *-*-sysv4*] \ | |
28 | && ![istarget *-*-unixware*] \ | |
29 | && ![istarget *-*-elf*] \ | |
30 | && ![istarget *-*-eabi*] \ | |
19c7c582 | 31 | && ![istarget hppa*64*-*-hpux*] \ |
7dc542b2 | 32 | && ![istarget *-*-linux*] \ |
5940a93c | 33 | && ![istarget *-*-gnu*] \ |
5a68afcf | 34 | && ![istarget *-*-nacl*] \ |
7dc542b2 PB |
35 | && ![istarget *-*-irix5*] \ |
36 | && ![istarget *-*-irix6*] \ | |
977cdf5a | 37 | && ![is_pecoff_format] \ |
7dc542b2 | 38 | && ![istarget *-*-solaris2*] } then { |
977cdf5a | 39 | unsupported $testname |
7dc542b2 PB |
40 | return |
41 | } | |
42 | ||
43 | if { [istarget *-*-linux*aout*] \ | |
44 | || [istarget *-*-linux*oldld*] } { | |
977cdf5a | 45 | unsupported $testname |
7dc542b2 PB |
46 | return |
47 | } | |
48 | ||
977cdf5a NC |
49 | # Weak symbols are broken for non-i386 PE targets. |
50 | if {! [istarget i?86-*-*]} { | |
51 | setup_xfail *-*-pe* | |
52 | } | |
53 | ||
c9eaa05f | 54 | setup_xfail pj-*-* |
48733062 | 55 | |
7dc542b2 PB |
56 | if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then { |
57 | # It's OK if .weak doesn't work on this target. | |
58 | unresolved $testname | |
59 | return | |
60 | } | |
61 | ||
62 | # The linker should accept references to undefined weaks without error, | |
63 | # and resolve them to zero. | |
64 | ||
65 | set output_regexp \ | |
66 | ".*Contents of section .data:.*0000 00000000 11111111.*" | |
67 | ||
68 | if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then { | |
69 | fail $testname | |
70 | } else { | |
7f6a71ff | 71 | if {![is_remote host] && [which $objdump] == 0} then { |
7dc542b2 PB |
72 | unresolved $testname |
73 | return | |
74 | } | |
75 | ||
7f6a71ff | 76 | set exec_output [run_host_cmd "$objdump" "-s tmpdir/weak-undef"] |
7dc542b2 PB |
77 | set exec_output [prune_warnings $exec_output] |
78 | verbose -log $exec_output | |
79 | ||
80 | if {[regexp $output_regexp $exec_output]} then { | |
81 | pass $testname | |
82 | } else { | |
83 | fail $testname | |
84 | } | |
85 | } |