* contrib: Remove directory.
[binutils.git] / ld / testsuite / ld-undefined / weak-undef.exp
blobb87c319da1ebd2c07b2db157eddff1b9445bc7f0
1 # Test handling of weak undefined symbols
2 # Copyright 2001, 2002, 2004
3 # Free Software Foundation, Inc.
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19 set testname "weak undefined symbols"
21 # This test only works for ELF targets. It ought to work for some
22 # a.out targets, but it doesn't.
24 if { ![istarget *-*-sysv4*] \
25 && ![istarget *-*-unixware*] \
26 && ![istarget *-*-elf*] \
27 && ![istarget *-*-eabi*] \
28 && ![istarget hppa*64*-*-hpux*] \
29 && ![istarget *-*-linux*] \
30 && ![istarget *-*-irix5*] \
31 && ![istarget *-*-irix6*] \
32 && ![is_pecoff_format] \
33 && ![istarget *-*-solaris2*] } then {
34 unsupported $testname
35 return
38 if { [istarget *-*-linux*aout*] \
39 || [istarget *-*-linux*oldld*] } {
40 unsupported $testname
41 return
44 # Weak symbols are broken for non-i386 PE targets.
45 if {! [istarget i?86-*-*]} {
46 setup_xfail *-*-pe*
49 setup_xfail hppa64-*-* pj-*-*
51 if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then {
52 # It's OK if .weak doesn't work on this target.
53 unresolved $testname
54 return
57 # The linker should accept references to undefined weaks without error,
58 # and resolve them to zero.
60 set output_regexp \
61 ".*Contents of section .data:.*0000 00000000 11111111.*"
63 if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then {
64 fail $testname
65 } else {
66 if {[which $objdump] == 0} then {
67 unresolved $testname
68 return
71 verbose -log "$objdump -s tmpdir/weak-undef"
72 catch "exec $objdump -s tmpdir/weak-undef" exec_output
73 set exec_output [prune_warnings $exec_output]
74 verbose -log $exec_output
76 if {[regexp $output_regexp $exec_output]} then {
77 pass $testname
78 } else {
79 fail $testname