source: trunk/binutils/ld/testsuite/ld-scripts/crossref.exp

Last change on this file was 610, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.1 KB
Line 
1# Test NOCROSSREFS in a linker script.
2# By Ian Lance Taylor, Cygnus Support.
3# Copyright 2001
4# Free Software Foundation, Inc.
5#
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.
10#
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.
15#
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20set test1 "NOCROSSREFS 1"
21set test2 "NOCROSSREFS 2"
22
23if { [which $CC] == 0 } {
24 untested $test1
25 untested $test2
26 return
27}
28
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.
31global CFLAGS
32if [istarget xtensa*-*-*] {
33 set CFLAGS "$CFLAGS -mtext-section-literals"
34}
35
36if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
37 || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
38 unresolved $test1
39 unresolved $test2
40 return
41}
42
43set flags [big_or_little_endian]
44
45# The a29k compiled code calls V_SPILL and V_FILL. Since we don't
46# need to run this code, but we don't have definitions for those
47# functions, we just define them out.
48if [istarget a29k*-*-*] {
49 set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
50}
51
52if [istarget sh64*-*-elf] {
53 # This is what gcc passes to ld by default.
54 set flags "-mshelf32"
55}
56
57verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
58
59catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
60
61set exec_output [prune_warnings $exec_output]
62
63regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
64
65if [string match "" $exec_output] then {
66 fail $test1
67} else {
68 verbose -log "$exec_output"
69 if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
70 pass $test1
71 } else {
72 fail $test1
73 }
74}
75
76# Check cross references within a single object.
77
78if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
79 unresolved $test2
80 return
81}
82
83verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
84
85catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
86
87set exec_output [prune_warnings $exec_output]
88
89regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
90
91if [string match "" $exec_output] then {
92 fail $test2
93} else {
94 verbose -log "$exec_output"
95 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
96 pass $test2
97 } else {
98 fail $test2
99 }
100}
Note: See TracBrowser for help on using the repository browser.