* config/default.exp (gcc_gas_flags): Force ABI to n32 on
[external/binutils.git] / ld / testsuite / config / default.exp
1 # Basic expect script for LD Regression Tests
2 #   Copyright 1993, 1994, 1995, 1997, 1998, 1999
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 # The mips64-*-linux-gnu compiler defaults to the N32 ABI after
64 # installed, but to the O32 ABI in the build tree, because of some
65 # specs-file hacks.  Make sure we use an ABI that is compatible with
66 # the one we expect.
67 if {[istarget mips64*-*-linux*] &&
68     (![board_info [target_info name] exists multilib_flags] ||
69      ![string match "*-mabi" [board_info [target_info name] multilib_flags]])
70    } {
71     append gcc_gas_flag " -mabi=n32"
72 }
73
74 # load the utility procedures
75 load_lib ld-lib.exp
76
77 proc get_link_files {varname} {
78     global $varname
79     global target_triplet
80     global srcdir
81     global CC
82     if ![info exists $varname] {
83         set status [catch "exec sh -c \"host='$target_triplet' && CC='$CC' && . $srcdir/../configure.host && eval echo \\$$varname\"" result]
84         if $status { error "Error getting native link files: $result" }
85         set $varname $result
86     }
87 }
88
89 proc get_target_emul {} {
90     global target_triplet
91     global srcdir
92     set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
93     if $status { error "Error getting emulation name: $result" }
94     return $result
95 }
96
97 if [isnative] {
98     foreach x {HOSTING_CRT0 HOSTING_LIBS} {
99         get_link_files $x
100     }
101 } else {
102     foreach x {HOSTING_CRT0 HOSTING_LIBS} { set $x "" }
103 }
104 if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
105
106 #
107 # ld_version -- extract and print the version number of ld compiler (GCC)
108 #
109 proc ld_version {} {
110     global ld
111     default_ld_version $ld
112 }
113
114 #
115 # ld_exit -- just a stub for ld
116 #
117 proc ld_exit {} {
118 }
119
120 #
121 # ld_start 
122 #       relink the linker
123 #
124 proc ld_start { ld target } {
125         #
126 }
127
128 #
129 # ld_relocate 
130 #       link an object using relocation
131 #
132 proc ld_relocate { ld target objects } {
133         default_ld_relocate $ld $target $objects
134 }
135
136 #
137 # ld_link 
138 #       link a program using ld
139 #
140 proc ld_link { ld target objects } {
141         default_ld_link $ld $target $objects
142 }
143
144 #
145 # ld_simple_link 
146 #       link a program using ld, without including any libraries
147 #
148 proc ld_simple_link { ld target objects } {
149         default_ld_simple_link $ld $target $objects
150 }
151
152 #
153 # ld_compile 
154 #       compile an object using $cc
155 #
156 proc ld_compile { cc source object } {
157         default_ld_compile $cc $source $object 
158 }
159
160 #
161 # ld_assemble
162 #       assemble a file
163 #
164 proc ld_assemble { as source object } {
165         default_ld_assemble $as $source $object 
166 }
167
168 #
169 # ld_nm
170 #       run nm on a file
171 #
172 proc ld_nm { nm nmflags object } {
173         default_ld_nm $nm $nmflags $object
174 }
175
176 #
177 # ld_exec
178 #       execute ithe target
179 #
180 proc ld_exec { target output } {
181         default_ld_exec $target $output
182 }
183
184 # From gas-defs.exp, to support run_dump_test.
185 if ![info exists AS] then {
186     set AS $as
187 }
188
189 if ![info exists GASP] then {
190     set GASP [findfile $base_dir/../gas/gasp-new $base_dir/../gas/gasp-new [transform gasp]]
191 }
192
193 if ![info exists ASFLAGS] then {
194     set ASFLAGS ""
195 }
196
197 if ![info exists OBJDUMP] then {
198     set OBJDUMP $objdump
199 }
200
201 if ![info exists OBJDUMPFLAGS] then {
202     set OBJDUMPFLAGS {}
203 }
204
205 if ![info exists NM] then {
206     set NM $nm
207 }
208
209 if ![info exists NMFLAGS] then {
210     set NMFLAGS {}
211 }
212
213 if ![info exists OBJCOPY] then {
214     set OBJCOPY $objcopy
215 }
216
217 if ![info exists OBJCOPYFLAGS] then {
218     set OBJCOPYFLAGS {}
219 }
220
221 if ![info exists READELF] then {
222     set READELF [findfile $base_dir/../binutils/readelf]
223 }
224
225 if ![info exists READELFFLAGS] then {
226     set READELFFLAGS {}
227 }
228
229 if ![info exists LD] then {
230     set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
231 }
232
233 if ![info exists LDFLAGS] then {
234     set LDFLAGS {}
235 }