1 # Test NOCROSSREFS in a linker script.
2 # By Ian Lance Taylor, Cygnus Support.
3 # Copyright 2000, 2001, 2002, 2003, 2004
4 # Free Software Foundation, Inc.
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
20 set test1 "NOCROSSREFS 1"
21 set test2 "NOCROSSREFS 2"
23 if { [which $CC] == 0 } {
29 # Xtensa targets currently default to putting literal values in a separate
30 # section and that requires linker script support, so put literals in text.
32 if [istarget xtensa*-*-*] {
33 set CFLAGS "$CFLAGS -mtext-section-literals"
36 if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
37 || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
43 set flags [big_or_little_endian]
45 if [istarget sh64*-*-elf] {
46 # This is what gcc passes to ld by default.
50 # IA64 has both ordered and unordered sections in an input file.
53 verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
55 catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
57 set exec_output [prune_warnings $exec_output]
59 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
61 if [string match "" $exec_output] then {
64 verbose -log "$exec_output"
65 if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
72 # Check cross references within a single object.
74 if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
79 verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
81 catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
83 set exec_output [prune_warnings $exec_output]
85 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
87 if [string match "" $exec_output] then {
90 verbose -log "$exec_output"
91 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {