update copyright dates
[external/binutils.git] / ld / testsuite / ld-undefined / weak-undef.exp
1 # Test handling of weak undefined symbols
2 #   Copyright 2001, 2002, 2004, 2005, 2007
3 #   Free Software Foundation, Inc.
4 #
5 # This file is part of the GNU Binutils.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
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.
16 #
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
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
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*] \
31      && ![istarget hppa*64*-*-hpux*] \
32      && ![istarget *-*-linux*] \
33      && ![istarget *-*-irix5*] \
34      && ![istarget *-*-irix6*] \
35      && ![is_pecoff_format] \
36      && ![istarget *-*-solaris2*] } then {
37     unsupported $testname
38     return
39 }
40
41 if { [istarget *-*-linux*aout*] \
42      || [istarget *-*-linux*oldld*] } {
43     unsupported $testname
44     return
45 }
46
47 # Weak symbols are broken for non-i386 PE targets.
48 if {! [istarget i?86-*-*]} {
49     setup_xfail *-*-pe*
50 }
51
52 setup_xfail hppa64-*-* pj-*-*
53
54 if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then {
55     # It's OK if .weak doesn't work on this target.
56     unresolved $testname
57     return
58 }
59
60 # The linker should accept references to undefined weaks without error,
61 # and resolve them to zero.
62
63 set output_regexp \
64 ".*Contents of section .data:.*0000 00000000 11111111.*"
65
66 if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then {
67     fail $testname
68 } else {
69     if {![is_remote host] && [which $objdump] == 0} then {
70         unresolved $testname
71         return
72     }
73
74     set exec_output [run_host_cmd "$objdump" "-s tmpdir/weak-undef"]
75     set exec_output [prune_warnings $exec_output]
76     verbose -log $exec_output
77
78     if {[regexp $output_regexp $exec_output]} then {
79         pass $testname
80     } else {
81         fail $testname
82     }
83 }