Add HOSTING_SLIBS and use it for -pie
[deliverable/binutils-gdb.git] / ld / testsuite / config / default.exp
CommitLineData
252b5132 1# Basic expect script for LD Regression Tests
aa820537 2# Copyright 1993, 1994, 1995, 1997, 1998, 1999, 2001, 2003, 2005, 2007, 2009
5cb49709 3# 2011, 2012 Free Software Foundation, Inc.
252b5132 4#
f96b4a7b
NC
5# This file is part of the GNU Binutils.
6#
252b5132
RH
7# This file is free software; you can redistribute it and/or modify
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
252b5132
RH
10# (at your option) any later version.
11#
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.
16#
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#
22# Written by Jeffrey Wheat (cassidy@cygnus.com)
23#
24
25if ![info exists ld] then {
26 set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
27}
28
29if ![info exists as] then {
30 set as [findfile $base_dir/../gas/as-new $base_dir/../gas/as-new [transform as]]
31}
32
33if ![info exists nm] then {
34 set nm [findfile $base_dir/../binutils/nm-new $base_dir/../binutils/nm-new [transform nm]]
35}
36
37if ![info exists objdump] then {
38 set objdump [findfile $base_dir/../binutils/objdump]
39}
40
41if ![info exists objcopy] then {
42 set objcopy [findfile $base_dir/../binutils/objcopy]
43}
44
45if ![info exists ar] then {
46 set ar [findfile $base_dir/../binutils/ar]
47}
48
49if ![info exists strip] then {
50 set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]]
51}
52
7f6a71ff 53remote_exec host "mkdir -p tmpdir"
252b5132
RH
54
55# Make a symlink from tmpdir/as to the assembler in the build tree, so
56# that we can use a -B option to gcc to force it to use the newly
57# built assembler.
58if {![file isdirectory tmpdir/gas]} then {
59 catch "exec mkdir tmpdir/gas" status
60 catch "exec ln -s ../../../gas/as-new tmpdir/gas/as" status
61}
62set gcc_gas_flag "-B[pwd]/tmpdir/gas/"
63
b765d4e3
L
64# Make a symlink from tmpdir/ld to the linker in the build tree, so
65# that we can use a -B option to gcc to force it to use the newly
66# built linker.
67if {![file isdirectory tmpdir/ld]} then {
68 catch "exec mkdir tmpdir/ld" status
69 catch "exec ln -s ../../ld-new tmpdir/ld/ld" status
3499cebd 70 catch "exec ln -s ld tmpdir/ld/collect-ld" status
b765d4e3
L
71}
72set gcc_ld_flag "-B[pwd]/tmpdir/ld/"
73
cdaeef2e 74# load the linker path
99c05fe4
MM
75if {[file exists tmpdir/libpath.exp]} {
76 load_lib tmpdir/libpath.exp
cdaeef2e 77
99c05fe4
MM
78 foreach dir $libpath {
79 set gcc_ld_flag "$gcc_ld_flag -L$dir"
80 }
81}
82
83# The "make check" target in the Makefile passes in
84# "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly
dae043d2 85# (as when testing an installed linker), these flags may not be set.
99c05fe4 86if {![info exists CC]} {
dae043d2
MM
87 set CC [find_gcc]
88}
89if {![info exists CFLAGS]} {
90 set CFLAGS "-g -O2"
91}
92if {![info exists CXX]} {
93 set CXX [find_g++]
94}
95if {![info exists CXXFLAGS]} {
96 set CXXFLAGS ""
cdaeef2e
L
97}
98
697380b3
AO
99# The mips64-*-linux-gnu compiler defaults to the N32 ABI after
100# installed, but to the O32 ABI in the build tree, because of some
101# specs-file hacks. Make sure we use an ABI that is compatible with
102# the one we expect.
103if {[istarget mips64*-*-linux*] &&
104 (![board_info [target_info name] exists multilib_flags] ||
105 ![string match "*-mabi" [board_info [target_info name] multilib_flags]])
106 } {
107 append gcc_gas_flag " -mabi=n32"
108}
109
252b5132
RH
110# load the utility procedures
111load_lib ld-lib.exp
112
113proc get_link_files {varname} {
114 global $varname
115 global target_triplet
116 global srcdir
117 global CC
118 if ![info exists $varname] {
bba21f15
AM
119 #configure.host returns variables that can be substituted into
120 #makefile rules, with embedded shell variable expansions.
121 #make wants $$shell_var, we want $shell_var ...
122 set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' <<EOF\n\$$varname\nEOF"
123 set status [catch "exec sh -c [list $cmd]" result]
124 if $status { error "Error getting native link files: $result" }
125 set cmd "CC='$CC' && eval echo \"$result\""
126 set status [catch "exec sh -c [list $cmd]" result]
252b5132
RH
127 if $status { error "Error getting native link files: $result" }
128 set $varname $result
bba21f15 129 send_log "$varname = $result\n"
252b5132
RH
130 }
131}
132
133proc get_target_emul {} {
134 global target_triplet
135 global srcdir
136 set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
137 if $status { error "Error getting emulation name: $result" }
138 return $result
139}
140
141if [isnative] {
b27caf75 142 foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
252b5132
RH
143 get_link_files $x
144 }
145} else {
b27caf75 146 foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
252b5132
RH
147}
148if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
149
150#
151# ld_version -- extract and print the version number of ld compiler (GCC)
152#
153proc ld_version {} {
154 global ld
155 default_ld_version $ld
156}
157
158#
159# ld_exit -- just a stub for ld
160#
161proc ld_exit {} {
162}
163
164#
165# ld_start
166# relink the linker
167#
168proc ld_start { ld target } {
169 #
170}
171
172#
173# ld_relocate
174# link an object using relocation
175#
176proc ld_relocate { ld target objects } {
177 default_ld_relocate $ld $target $objects
178}
179
180#
181# ld_link
182# link a program using ld
183#
184proc ld_link { ld target objects } {
185 default_ld_link $ld $target $objects
186}
187
188#
189# ld_simple_link
190# link a program using ld, without including any libraries
191#
192proc ld_simple_link { ld target objects } {
193 default_ld_simple_link $ld $target $objects
194}
195
196#
197# ld_compile
198# compile an object using $cc
199#
200proc ld_compile { cc source object } {
201 default_ld_compile $cc $source $object
202}
203
204#
205# ld_assemble
206# assemble a file
207#
208proc ld_assemble { as source object } {
de1491f0
BS
209 default_ld_assemble $as "" $source $object
210}
211
212#
213# ld_assemble_flags
214# assemble a file with extra flags
215#
216proc ld_assemble_flags { as flags source object } {
217 default_ld_assemble $as $flags $source $object
252b5132
RH
218}
219
220#
221# ld_nm
222# run nm on a file
223#
992c450d
AM
224proc ld_nm { nm nmflags object } {
225 default_ld_nm $nm $nmflags $object
252b5132
RH
226}
227
228#
229# ld_exec
230# execute ithe target
231#
232proc ld_exec { target output } {
233 default_ld_exec $target $output
234}
235
261def70
HPN
236# From gas-defs.exp, to support run_dump_test.
237if ![info exists AS] then {
238 set AS $as
239}
240
241if ![info exists GASP] then {
242 set GASP [findfile $base_dir/../gas/gasp-new $base_dir/../gas/gasp-new [transform gasp]]
243}
244
245if ![info exists ASFLAGS] then {
246 set ASFLAGS ""
247}
248
249if ![info exists OBJDUMP] then {
250 set OBJDUMP $objdump
251}
252
253if ![info exists OBJDUMPFLAGS] then {
254 set OBJDUMPFLAGS {}
255}
256
257if ![info exists NM] then {
258 set NM $nm
259}
260
261if ![info exists NMFLAGS] then {
262 set NMFLAGS {}
263}
264
265if ![info exists OBJCOPY] then {
266 set OBJCOPY $objcopy
267}
268
269if ![info exists OBJCOPYFLAGS] then {
270 set OBJCOPYFLAGS {}
271}
272
273if ![info exists READELF] then {
274 set READELF [findfile $base_dir/../binutils/readelf]
275}
276
277if ![info exists READELFFLAGS] then {
278 set READELFFLAGS {}
279}
280
281if ![info exists LD] then {
282 set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
283}
284
285if ![info exists LDFLAGS] then {
286 set LDFLAGS {}
287}
This page took 1.241144 seconds and 4 git commands to generate.