19990502 sourceware import
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / crossref.exp
CommitLineData
252b5132
RH
1# Test NOCROSSREFS in a linker script.
2# By Ian Lance Taylor, Cygnus Support.
3
4set test1 "NOCROSSREFS 1"
5set test2 "NOCROSSREFS 2"
6
7if { [which $CC] == 0 } {
8 untested $test1
9 untested $test2
10 return
11}
12
13if { ![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
20set flags ""
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.
25if [istarget a29k*-*-*] {
26 set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
27}
28
29# hppa-elf needs a definition for $global$.
30if [istarget hppa*-*-*] {
31 set flags "$flags --defsym '\$global\$'=0"
32}
33
34verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
35
36catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
37
38set exec_output [prune_warnings $exec_output]
39
40regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
41
42if [string match "" $exec_output] then {
43 fail $test1
44} else {
45 verbose -log "$exec_output"
46 if [regexp "prohibited cross reference from .* to `foo' in" $exec_output] {
47 pass $test1
48 } else {
49 fail $test1
50 }
51}
52
53# Check cross references within a single object.
54
55if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
56 unresolved $test2
57 return
58}
59
60verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
61
62catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
63
64set exec_output [prune_warnings $exec_output]
65
66regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
67
68if [string match "" $exec_output] then {
69 fail $test2
70} else {
71 verbose -log "$exec_output"
72 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
73 pass $test2
74 } else {
75 fail $test2
76 }
77}
This page took 0.027581 seconds and 4 git commands to generate.