Even more hppa testsuite patches.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / weak.exp
1 # Test weak symbols.
2 # By Ian Lance Taylor, Cygnus Solutions.
3
4 set testname "weak symbols"
5
6 # This test only works for ELF targets. It ought to work for some
7 # a.out targets, but it doesn't.
8
9 if { ![istarget *-*-sysv4*] \
10 && ![istarget *-*-unixware*] \
11 && ![istarget *-*-elf*] \
12 && ![istarget *-*-eabi*] \
13 && ![istarget *-*-linux*] \
14 && ![istarget *-*-irix5*] \
15 && ![istarget *-*-irix6*] \
16 && ![istarget *-*-solaris2*] } then {
17 return
18 }
19
20 if { [istarget *-*-linux*aout*] \
21 || [istarget *-*-linux*oldld*] } {
22 return
23 }
24
25 if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
26 || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
27 # It's OK if .weak doesn't work on this target.
28 unresolved $testname
29 return
30 }
31
32 set weak_regexp_big \
33 ".*Contents of section .text:.*1000 00001008 0000200c 12121212 34343434.*Contents of section .data:.*2000 00001008 0000200c 56565656 78787878.*"
34
35 set weak_regexp_little \
36 ".*Contents of section .text:.*1000 08100000 0c200000 12121212 34343434.*Contents of section .data:.*2000 08100000 0c200000 56565656 78787878.*"
37
38 # hppa-elf needs a definition for $global$.
39 set flags ""
40 if [istarget hppa*-*-*] {
41 set flags "--defsym \\\$global\\\$=0"
42 }
43
44 if {! [ld_simple_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
45 fail $testname
46 } else {
47 if {[which $objdump] == 0} then {
48 unresolved $testname
49 return
50 }
51
52 verbose -log "$objdump -s tmpdir/weak"
53 catch "exec $objdump -s tmpdir/weak" exec_output
54 set exec_output [prune_warnings $exec_output]
55 verbose -log $exec_output
56
57 if {[regexp $weak_regexp_big $exec_output] \
58 || [regexp $weak_regexp_little $exec_output] } then {
59 pass $testname
60 } else {
61 fail $testname
62 }
63 }
This page took 0.039284 seconds and 5 git commands to generate.