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