Commit | Line | Data |
---|---|---|
7dc542b2 PB |
1 | # Test handling of weak undefined symbols |
2 | ||
3 | set testname "weak undefined symbols" | |
4 | ||
5 | # This test only works for ELF targets. It ought to work for some | |
6 | # a.out targets, but it doesn't. | |
7 | ||
8 | if { ![istarget *-*-sysv4*] \ | |
9 | && ![istarget *-*-unixware*] \ | |
10 | && ![istarget *-*-elf*] \ | |
11 | && ![istarget *-*-eabi*] \ | |
12 | && ![istarget *-*-linux*] \ | |
13 | && ![istarget *-*-irix5*] \ | |
14 | && ![istarget *-*-irix6*] \ | |
15 | && ![istarget *-*-solaris2*] } then { | |
16 | return | |
17 | } | |
18 | ||
19 | if { [istarget *-*-linux*aout*] \ | |
20 | || [istarget *-*-linux*oldld*] } { | |
21 | return | |
22 | } | |
23 | ||
24 | if {! [ld_assemble $as $srcdir/$subdir/weak-undef.s tmpdir/weak-undef.o]} then { | |
25 | # It's OK if .weak doesn't work on this target. | |
26 | unresolved $testname | |
27 | return | |
28 | } | |
29 | ||
30 | # The linker should accept references to undefined weaks without error, | |
31 | # and resolve them to zero. | |
32 | ||
33 | set output_regexp \ | |
34 | ".*Contents of section .data:.*0000 00000000 11111111.*" | |
35 | ||
36 | if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then { | |
37 | fail $testname | |
38 | } else { | |
39 | if {[which $objdump] == 0} then { | |
40 | unresolved $testname | |
41 | return | |
42 | } | |
43 | ||
44 | verbose -log "$objdump -s tmpdir/weak-undef" | |
45 | catch "exec $objdump -s tmpdir/weak-undef" exec_output | |
46 | set exec_output [prune_warnings $exec_output] | |
47 | verbose -log $exec_output | |
48 | ||
49 | if {[regexp $output_regexp $exec_output]} then { | |
50 | pass $testname | |
51 | } else { | |
52 | fail $testname | |
53 | } | |
54 | } |