| 1 |
# Test handling of weak undefined symbols |
| 2 |
# Copyright 2001, 2002, 2004 |
| 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 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 |
| 36 |
} |
| 37 |
|
| 38 |
if { [istarget *-*-linux*aout*] \ |
| 39 |
|| [istarget *-*-linux*oldld*] } { |
| 40 |
unsupported $testname |
| 41 |
return |
| 42 |
} |
| 43 |
|
| 44 |
# Weak symbols are broken for non-i386 PE targets. |
| 45 |
if {! [istarget i?86-*-*]} { |
| 46 |
setup_xfail *-*-pe* |
| 47 |
} |
| 48 |
|
| 49 |
if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then { |
| 50 |
# It's OK if .weak doesn't work on this target. |
| 51 |
unresolved $testname |
| 52 |
return |
| 53 |
} |
| 54 |
|
| 55 |
# The linker should accept references to undefined weaks without error, |
| 56 |
# and resolve them to zero. |
| 57 |
|
| 58 |
set output_regexp \ |
| 59 |
".*Contents of section .data:.*0000 00000000 11111111.*" |
| 60 |
|
| 61 |
if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then { |
| 62 |
fail $testname |
| 63 |
} else { |
| 64 |
if {[which $objdump] == 0} then { |
| 65 |
unresolved $testname |
| 66 |
return |
| 67 |
} |
| 68 |
|
| 69 |
verbose -log "$objdump -s tmpdir/weak-undef" |
| 70 |
catch "exec $objdump -s tmpdir/weak-undef" exec_output |
| 71 |
set exec_output [prune_warnings $exec_output] |
| 72 |
verbose -log $exec_output |
| 73 |
|
| 74 |
if {[regexp $output_regexp $exec_output]} then { |
| 75 |
pass $testname |
| 76 |
} else { |
| 77 |
fail $testname |
| 78 |
} |
| 79 |
} |