daily update
[binutils.git] / ld / testsuite / ld-undefined / weak-undef.exp
blobfe21a8fc031aef1fcee5f9279201549d5171c245
1 # Test handling of weak undefined symbols
2 # Copyright 2001
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 && ![istarget *-*-solaris2*] } then {
33 return
36 if { [istarget *-*-linux*aout*] \
37 || [istarget *-*-linux*oldld*] } {
38 return
41 if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then {
42 # It's OK if .weak doesn't work on this target.
43 unresolved $testname
44 return
47 # The linker should accept references to undefined weaks without error,
48 # and resolve them to zero.
50 set output_regexp \
51 ".*Contents of section .data:.*0000 00000000 11111111.*"
53 if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then {
54 fail $testname
55 } else {
56 if {[which $objdump] == 0} then {
57 unresolved $testname
58 return
61 verbose -log "$objdump -s tmpdir/weak-undef"
62 catch "exec $objdump -s tmpdir/weak-undef" exec_output
63 set exec_output [prune_warnings $exec_output]
64 verbose -log $exec_output
66 if {[regexp $output_regexp $exec_output]} then {
67 pass $testname
68 } else {
69 fail $testname