78 lines
2.1 KiB
Text
78 lines
2.1 KiB
Text
|
# Test NOCROSSREFS in a linker script.
|
||
|
# By Ian Lance Taylor, Cygnus Support.
|
||
|
|
||
|
set test1 "NOCROSSREFS 1"
|
||
|
set test2 "NOCROSSREFS 2"
|
||
|
|
||
|
if { [which $CC] == 0 } {
|
||
|
untested $test1
|
||
|
untested $test2
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
|
||
|
|| ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
|
||
|
unresolved $test1
|
||
|
unresolved $test2
|
||
|
return
|
||
|
}
|
||
|
|
||
|
set flags ""
|
||
|
|
||
|
# The a29k compiled code calls V_SPILL and V_FILL. Since we don't
|
||
|
# need to run this code, but we don't have definitions for those
|
||
|
# functions, we just define them out.
|
||
|
if [istarget a29k*-*-*] {
|
||
|
set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
|
||
|
}
|
||
|
|
||
|
# hppa-elf needs a definition for $global$.
|
||
|
if [istarget hppa*-*-*] {
|
||
|
set flags "$flags --defsym '\$global\$'=0"
|
||
|
}
|
||
|
|
||
|
verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
|
||
|
|
||
|
catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
|
||
|
|
||
|
set exec_output [prune_warnings $exec_output]
|
||
|
|
||
|
regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
|
||
|
|
||
|
if [string match "" $exec_output] then {
|
||
|
fail $test1
|
||
|
} else {
|
||
|
verbose -log "$exec_output"
|
||
|
if [regexp "prohibited cross reference from .* to `foo' in" $exec_output] {
|
||
|
pass $test1
|
||
|
} else {
|
||
|
fail $test1
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Check cross references within a single object.
|
||
|
|
||
|
if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
|
||
|
unresolved $test2
|
||
|
return
|
||
|
}
|
||
|
|
||
|
verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
|
||
|
|
||
|
catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
|
||
|
|
||
|
set exec_output [prune_warnings $exec_output]
|
||
|
|
||
|
regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
|
||
|
|
||
|
if [string match "" $exec_output] then {
|
||
|
fail $test2
|
||
|
} else {
|
||
|
verbose -log "$exec_output"
|
||
|
if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
|
||
|
pass $test2
|
||
|
} else {
|
||
|
fail $test2
|
||
|
}
|
||
|
}
|