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"
22 set test3 "NOCROSSREFS 3"
24 if { [which $CC] == 0 } {
31 # Xtensa targets currently default to putting literal values in a separate
32 # section and that requires linker script support, so put literals in text.
34 if [istarget xtensa*-*-*] {
35 set CFLAGS "$CFLAGS -mtext-section-literals"
38 if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
39 || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
45 set flags [big_or_little_endian]
47 if [istarget sh64*-*-elf] {
48 # This is what gcc passes to ld by default.
52 # IA64 has both ordered and unordered sections in an input file.
55 verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
57 catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
59 set exec_output [prune_warnings $exec_output]
61 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
63 if [string match "" $exec_output] then {
66 verbose -log "$exec_output"
67 if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
74 # Check cross references within a single object.
76 if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
81 verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
83 catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
85 set exec_output [prune_warnings $exec_output]
87 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
89 if [string match "" $exec_output] then {
92 verbose -log "$exec_output"
93 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
100 # Check cross references for ld -r
102 if { ![ld_compile $CC "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
107 if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
112 verbose -log "$ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"
114 catch "exec $ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o" exec_output
116 set exec_output [prune_warnings $exec_output]
118 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
120 if [string match "" $exec_output] then {
123 verbose -log "$exec_output"