bfd/
[deliverable/binutils-gdb.git] / ld / testsuite / config / default.exp
1 # Basic expect script for LD Regression Tests
2 # Copyright 1993, 1994, 1995, 1997, 1998, 1999, 2001, 2003
3 # Free Software Foundation, Inc.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # Written by Jeffrey Wheat (cassidy@cygnus.com)
20 #
21
22 if ![info exists ld] then {
23 set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
24 }
25
26 if ![info exists as] then {
27 set as [findfile $base_dir/../gas/as-new $base_dir/../gas/as-new [transform as]]
28 }
29
30 if ![info exists nm] then {
31 set nm [findfile $base_dir/../binutils/nm-new $base_dir/../binutils/nm-new [transform nm]]
32 }
33
34 if ![info exists objdump] then {
35 set objdump [findfile $base_dir/../binutils/objdump]
36 }
37
38 if ![info exists objcopy] then {
39 set objcopy [findfile $base_dir/../binutils/objcopy]
40 }
41
42 if ![info exists ar] then {
43 set ar [findfile $base_dir/../binutils/ar]
44 }
45
46 if ![info exists strip] then {
47 set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]]
48 }
49
50 if {![file isdirectory tmpdir]} then {
51 catch "exec mkdir tmpdir" status
52 }
53
54 # Make a symlink from tmpdir/as to the assembler in the build tree, so
55 # that we can use a -B option to gcc to force it to use the newly
56 # built assembler.
57 if {![file isdirectory tmpdir/gas]} then {
58 catch "exec mkdir tmpdir/gas" status
59 catch "exec ln -s ../../../gas/as-new tmpdir/gas/as" status
60 }
61 set gcc_gas_flag "-B[pwd]/tmpdir/gas/"
62
63 # Make a symlink from tmpdir/ld to the linker in the build tree, so
64 # that we can use a -B option to gcc to force it to use the newly
65 # built linker.
66 if {![file isdirectory tmpdir/ld]} then {
67 catch "exec mkdir tmpdir/ld" status
68 catch "exec ln -s ../../ld-new tmpdir/ld/ld" status
69 }
70 set gcc_ld_flag "-B[pwd]/tmpdir/ld/"
71
72 # load the linker path
73 if {[file exists tmpdir/libpath.exp]} {
74 load_lib tmpdir/libpath.exp
75
76 foreach dir $libpath {
77 set gcc_ld_flag "$gcc_ld_flag -L$dir"
78 }
79 }
80
81 # The "make check" target in the Makefile passes in
82 # "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly
83 # (as when testing an installed linker), these flags may not be set.
84 if {![info exists CC]} {
85 set CC [find_gcc]
86 }
87 if {![info exists CFLAGS]} {
88 set CFLAGS "-g -O2"
89 }
90 if {![info exists CXX]} {
91 set CXX [find_g++]
92 }
93 if {![info exists CXXFLAGS]} {
94 set CXXFLAGS ""
95 }
96
97 # The mips64-*-linux-gnu compiler defaults to the N32 ABI after
98 # installed, but to the O32 ABI in the build tree, because of some
99 # specs-file hacks. Make sure we use an ABI that is compatible with
100 # the one we expect.
101 if {[istarget mips64*-*-linux*] &&
102 (![board_info [target_info name] exists multilib_flags] ||
103 ![string match "*-mabi" [board_info [target_info name] multilib_flags]])
104 } {
105 append gcc_gas_flag " -mabi=n32"
106 }
107
108 # load the utility procedures
109 load_lib ld-lib.exp
110
111 proc get_link_files {varname} {
112 global $varname
113 global target_triplet
114 global srcdir
115 global CC
116 if ![info exists $varname] {
117 set status [catch "exec sh -c \"host='$target_triplet' && CC='$CC' && . $srcdir/../configure.host && eval echo \\$$varname\"" result]
118 if $status { error "Error getting native link files: $result" }
119 set $varname $result
120 }
121 }
122
123 proc get_target_emul {} {
124 global target_triplet
125 global srcdir
126 set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
127 if $status { error "Error getting emulation name: $result" }
128 return $result
129 }
130
131 if [isnative] {
132 foreach x {HOSTING_CRT0 HOSTING_LIBS} {
133 get_link_files $x
134 }
135 } else {
136 foreach x {HOSTING_CRT0 HOSTING_LIBS} { set $x "" }
137 }
138 if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
139
140 #
141 # ld_version -- extract and print the version number of ld compiler (GCC)
142 #
143 proc ld_version {} {
144 global ld
145 default_ld_version $ld
146 }
147
148 #
149 # ld_exit -- just a stub for ld
150 #
151 proc ld_exit {} {
152 }
153
154 #
155 # ld_start
156 # relink the linker
157 #
158 proc ld_start { ld target } {
159 #
160 }
161
162 #
163 # ld_relocate
164 # link an object using relocation
165 #
166 proc ld_relocate { ld target objects } {
167 default_ld_relocate $ld $target $objects
168 }
169
170 #
171 # ld_link
172 # link a program using ld
173 #
174 proc ld_link { ld target objects } {
175 default_ld_link $ld $target $objects
176 }
177
178 #
179 # ld_simple_link
180 # link a program using ld, without including any libraries
181 #
182 proc ld_simple_link { ld target objects } {
183 default_ld_simple_link $ld $target $objects
184 }
185
186 #
187 # ld_compile
188 # compile an object using $cc
189 #
190 proc ld_compile { cc source object } {
191 default_ld_compile $cc $source $object
192 }
193
194 #
195 # ld_assemble
196 # assemble a file
197 #
198 proc ld_assemble { as source object } {
199 default_ld_assemble $as $source $object
200 }
201
202 #
203 # ld_nm
204 # run nm on a file
205 #
206 proc ld_nm { nm nmflags object } {
207 default_ld_nm $nm $nmflags $object
208 }
209
210 #
211 # ld_exec
212 # execute ithe target
213 #
214 proc ld_exec { target output } {
215 default_ld_exec $target $output
216 }
217
218 # From gas-defs.exp, to support run_dump_test.
219 if ![info exists AS] then {
220 set AS $as
221 }
222
223 if ![info exists GASP] then {
224 set GASP [findfile $base_dir/../gas/gasp-new $base_dir/../gas/gasp-new [transform gasp]]
225 }
226
227 if ![info exists ASFLAGS] then {
228 set ASFLAGS ""
229 }
230
231 if ![info exists OBJDUMP] then {
232 set OBJDUMP $objdump
233 }
234
235 if ![info exists OBJDUMPFLAGS] then {
236 set OBJDUMPFLAGS {}
237 }
238
239 if ![info exists NM] then {
240 set NM $nm
241 }
242
243 if ![info exists NMFLAGS] then {
244 set NMFLAGS {}
245 }
246
247 if ![info exists OBJCOPY] then {
248 set OBJCOPY $objcopy
249 }
250
251 if ![info exists OBJCOPYFLAGS] then {
252 set OBJCOPYFLAGS {}
253 }
254
255 if ![info exists READELF] then {
256 set READELF [findfile $base_dir/../binutils/readelf]
257 }
258
259 if ![info exists READELFFLAGS] then {
260 set READELFFLAGS {}
261 }
262
263 if ![info exists LD] then {
264 set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
265 }
266
267 if ![info exists LDFLAGS] then {
268 set LDFLAGS {}
269 }
This page took 0.035363 seconds and 4 git commands to generate.