daily update
[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.
aa820537 3# Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007
a2b64bed
NC
4# Free Software Foundation, Inc.
5#
f96b4a7b
NC
6# This file is part of the GNU Binutils.
7#
8# This program is free software; you can redistribute it and/or modify
a2b64bed 9# it under the terms of the GNU General Public License as published by
f96b4a7b 10# the Free Software Foundation; either version 3 of the License, or
a2b64bed 11# (at your option) any later version.
f96b4a7b 12#
a2b64bed
NC
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
f96b4a7b 17#
a2b64bed
NC
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
f96b4a7b
NC
20# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21# MA 02110-1301, USA.
252b5132
RH
22
23set test1 "NOCROSSREFS 1"
24set test2 "NOCROSSREFS 2"
b239e909 25set test3 "NOCROSSREFS 3"
252b5132 26
7f6a71ff 27if { ![is_remote host] && [which $CC] == 0 } {
252b5132
RH
28 untested $test1
29 untested $test2
b239e909 30 untested $test3
252b5132
RH
31 return
32}
33
e0001a05
NC
34# Xtensa targets currently default to putting literal values in a separate
35# section and that requires linker script support, so put literals in text.
36global CFLAGS
37if [istarget xtensa*-*-*] {
38 set CFLAGS "$CFLAGS -mtext-section-literals"
39}
40
97e5838e
AM
41# If we have a compiler that doesn't use/reference dot-symbols, then
42# calls to functions reference the .opd section function descriptor.
43# This makes NOCROSSREFS rather useless on powerpc64.
44if [istarget powerpc64*-*-*] {
45 set CFLAGS "$CFLAGS -mcall-aixdesc"
46}
47
4dcdce13
NC
48# Prevent the use of the MeP's small data area which references a symbol
49# called __sdabase which will not be defined by our test linker scripts.
50if [istarget mep*-*-elf] {
51 set CFLAGS "-mtiny=0"
52}
53
ac145307
BS
54# The .dsbt section and __c6xabi_DSBT_BASE are not defined in our test
55# linker scripts.
56if [istarget tic6x*-*-*] {
57 set CFLAGS "-mno-dsbt -msdata=none"
58}
59
252b5132
RH
60if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
61 || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
62 unresolved $test1
63 unresolved $test2
64 return
65}
66
1688b748 67set flags [big_or_little_endian]
252b5132 68
1b19eb81
AO
69if [istarget sh64*-*-elf] {
70 # This is what gcc passes to ld by default.
71 set flags "-mshelf32"
72}
73
08ccf96b
L
74# IA64 has both ordered and unordered sections in an input file.
75setup_xfail ia64-*-*
76
7f6a71ff 77set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"]
252b5132
RH
78
79set exec_output [prune_warnings $exec_output]
80
81regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
82
83if [string match "" $exec_output] then {
84 fail $test1
85} else {
86 verbose -log "$exec_output"
dbc37f89 87 if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
252b5132
RH
88 pass $test1
89 } else {
90 fail $test1
91 }
92}
93
94# Check cross references within a single object.
95
96if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
97 unresolved $test2
98 return
99}
100
7f6a71ff 101set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"]
252b5132
RH
102set exec_output [prune_warnings $exec_output]
103
104regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
105
106if [string match "" $exec_output] then {
107 fail $test2
108} else {
109 verbose -log "$exec_output"
110 if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
111 pass $test2
112 } else {
113 fail $test2
114 }
115}
b239e909
L
116
117# Check cross references for ld -r
118
119if { ![ld_compile $CC "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
120 unresolved $test3
121 return
122}
123
124if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
125 unresolved $test3
126 return
127}
128
7f6a71ff 129set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"]
b239e909
L
130
131set exec_output [prune_warnings $exec_output]
132
133regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
134
135if [string match "" $exec_output] then {
136 pass $test3
137} else {
138 verbose -log "$exec_output"
139 fail $test3
140}
This page took 0.741662 seconds and 4 git commands to generate.