2001-02-28 Matt Hiller <hiller@redhat.com>
[platform/upstream/binutils.git] / ld / testsuite / ld-scripts / crossref.exp
1 # Test NOCROSSREFS in a linker script.
2 # By Ian Lance Taylor, Cygnus Support.
3
4 set test1 "NOCROSSREFS 1"
5 set test2 "NOCROSSREFS 2"
6
7 if { [which $CC] == 0 } {
8     untested $test1
9     untested $test2
10     return
11 }
12
13 if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
14      || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
15     unresolved $test1
16     unresolved $test2
17     return
18 }
19
20 set flags [big_or_little_endian]
21
22 # The a29k compiled code calls V_SPILL and V_FILL.  Since we don't
23 # need to run this code, but we don't have definitions for those
24 # functions, we just define them out.
25 if [istarget a29k*-*-*] {
26     set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
27 }
28
29 verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
30
31 catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
32
33 set exec_output [prune_warnings $exec_output]
34
35 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
36
37 if [string match "" $exec_output] then {
38     fail $test1
39 } else {
40     verbose -log "$exec_output"
41     if [regexp "prohibited cross reference from .* to `foo' in" $exec_output] {
42         pass $test1
43     } else {
44         fail $test1
45     }
46 }
47
48 # Check cross references within a single object.
49
50 if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
51     unresolved $test2
52     return
53 }
54
55 verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
56
57 catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
58
59 set exec_output [prune_warnings $exec_output]
60
61 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
62
63 if [string match "" $exec_output] then {
64     fail $test2
65 } else {
66     verbose -log "$exec_output"
67     if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
68         pass $test2
69     } else {
70         fail $test2
71     }
72 }