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