8de2949750c900266f265aef11494e803f110c2c
[deliverable/binutils-gdb.git] / ld / testsuite / ld-undefined / weak-undef.exp
1 # Test handling of weak undefined symbols
2 # Copyright 2001
3 # Free Software Foundation, Inc.
4 #
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.
14 #
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 set testname "weak undefined symbols"
20
21 # This test only works for ELF targets. It ought to work for some
22 # a.out targets, but it doesn't.
23
24 if { ![istarget *-*-sysv4*] \
25 && ![istarget *-*-unixware*] \
26 && ![istarget *-*-elf*] \
27 && ![istarget *-*-eabi*] \
28 && ![istarget *-*-linux*] \
29 && ![istarget *-*-irix5*] \
30 && ![istarget *-*-irix6*] \
31 && ![istarget *-*-solaris2*] } then {
32 return
33 }
34
35 if { [istarget *-*-linux*aout*] \
36 || [istarget *-*-linux*oldld*] } {
37 return
38 }
39
40 if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then {
41 # It's OK if .weak doesn't work on this target.
42 unresolved $testname
43 return
44 }
45
46 # The linker should accept references to undefined weaks without error,
47 # and resolve them to zero.
48
49 set output_regexp \
50 ".*Contents of section .data:.*0000 00000000 11111111.*"
51
52 if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then {
53 fail $testname
54 } else {
55 if {[which $objdump] == 0} then {
56 unresolved $testname
57 return
58 }
59
60 verbose -log "$objdump -s tmpdir/weak-undef"
61 catch "exec $objdump -s tmpdir/weak-undef" exec_output
62 set exec_output [prune_warnings $exec_output]
63 verbose -log $exec_output
64
65 if {[regexp $output_regexp $exec_output]} then {
66 pass $testname
67 } else {
68 fail $testname
69 }
70 }
This page took 0.031549 seconds and 3 git commands to generate.