]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - binutils/testsuite/binutils-all/mips/mips.exp
b6fe11d85a5a5bd835a020e9b238223ba5e07752
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / mips / mips.exp
1 # Copyright (C) 2013-2022 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
16 # MA 02110-1301, USA.
17
18 if {![istarget mips*-*-*] || ![is_elf_format]} {
19 return
20 }
21
22 if [is_remote host] {
23 set tempfile [remote_download host tmpdir/bintest.o]
24 set copyfile copy
25 } else {
26 set tempfile tmpdir/bintest.o
27 set copyfile tmpdir/copy
28 }
29
30 # run_dump_test_abi ABI NAME ARGS
31 #
32 # Invoke "run_dump_test" for test NAME using ABI if supported by the
33 # target used, passing predefined ABI-specific arguments. ARGS are
34 # as with "run_dump_test" and are appended to ABI-specific arguments,
35 # except for the special "noarch" keyword, which, if present, must
36 # appear first and is consumed causing any "-march=" option to be
37 # removed from ABI-specific GAS arguments, and likewise the special
38 # "useld" keyword, which, if present, must be next and is consumed
39 # causing LD arguments to be passed.
40 proc run_dump_test_abi { abi name args } {
41 global abi_asflags
42 global abi_ldflags
43 global has_abi
44
45 set args [lindex $args 0]
46 set asflags $abi_asflags($abi)
47 if { [lindex $args 0] == "noarch" } {
48 set asflags [regsub -- {-march=[^[:blank:]]*} $asflags {}]
49 set args [lreplace $args 0 0]
50 }
51 if { [lindex $args 0] == "useld" } {
52 set ldflags $abi_ldflags($abi)
53 set args [lreplace $args 0 0]
54 }
55 if !$has_abi($abi) {
56 lappend args {notarget *-*-*}
57 }
58
59 set testargs [list [list as $asflags]]
60 if { [info exists ldflags] } {
61 lappend testargs [list ld $ldflags]
62 }
63 if { [llength $args] > 0 } {
64 set testargs [concat $testargs $args]
65 }
66
67 run_dump_test $name $testargs
68 }
69
70 # run_dump_test_o32 NAME ARGS
71 #
72 # Invoke "run_dump_test_abi" for test NAME using the o32 ABI and
73 # passing ARGS.
74 proc run_dump_test_o32 { name args } {
75 run_dump_test_abi o32 $name [lindex $args 0]
76 }
77
78 # run_dump_test_n32 NAME ARGS
79 #
80 # Invoke "run_dump_test_abi" for test NAME using the n32 ABI and
81 # passing ARGS.
82 proc run_dump_test_n32 { name args } {
83 run_dump_test_abi n32 $name [lindex $args 0]
84 }
85
86 # run_dump_test_n64 NAME ARGS
87 #
88 # Invoke "run_dump_test_abi" for test NAME using the n64 ABI and
89 # passing ARGS.
90 proc run_dump_test_n64 { name args } {
91 run_dump_test_abi n64 $name [lindex $args 0]
92 }
93
94 set has_abi(o32) [expr ![istarget *-*-openbsd*] \
95 && ![istarget mips64*el-ps2-elf*]]
96 set has_abi(n32) [expr [istarget *-img-elf*] \
97 || [istarget *-mti-elf*] \
98 || [istarget mips64*el-ps2-elf*] \
99 || [istarget *-sde-elf*] \
100 || [istarget *-*-freebsd*] \
101 || [istarget *-*-irix6*] \
102 || [istarget *-*-kfreebsd*-gnu] \
103 || [istarget *-*-linux*]]
104 set has_abi(n64) [expr [istarget *-*-freebsd*] \
105 || [istarget *-*-irix6*] \
106 || [istarget *-*-kfreebsd*-gnu] \
107 || [istarget *-*-linux*] \
108 || [istarget *-*-netbsd*] \
109 || [istarget *-*-openbsd*]]
110
111 # Set defaults.
112 set abi_asflags(o32) ""
113 set abi_asflags(n32) ""
114 set abi_asflags(n64) ""
115 set abi_asflags(eabi) ""
116 set abi_ldflags(o32) ""
117 set abi_ldflags(n32) ""
118 set abi_ldflags(n64) ""
119 set abi_ldflags(eabi) ""
120
121 # Override as needed.
122 if {[istarget *-*-openbsd*] } {
123 set irixemul 0
124 } elseif { [istarget mips64*-*-linux*] } {
125 if [istarget *el-*-*] {
126 set abi_asflags(o32) -32
127 set abi_ldflags(o32) -melf32ltsmip
128 set abi_asflags(n64) "-march=from-abi -64"
129 set abi_ldflags(n64) -melf64ltsmip
130 } else {
131 set abi_asflags(o32) -32
132 set abi_ldflags(o32) -melf32btsmip
133 set abi_asflags(n64) "-march=from-abi -64"
134 set abi_ldflags(n64) -melf64btsmip
135 }
136 set irixemul 0
137 } elseif {[istarget *-*-linux*] } {
138 if [istarget *el-*-*] {
139 set abi_asflags(n32) "-march=from-abi -n32"
140 set abi_ldflags(n32) -melf32ltsmipn32
141 set abi_asflags(n64) "-march=from-abi -64"
142 set abi_ldflags(n64) -melf64ltsmip
143 } else {
144 set abi_asflags(n32) "-march=from-abi -n32"
145 set abi_ldflags(n32) -melf32btsmipn32
146 set abi_asflags(n64) "-march=from-abi -64"
147 set abi_ldflags(n64) -melf64btsmip
148 }
149 set irixemul 0
150 } elseif {[istarget *-img-elf*] \
151 || [istarget *-mti-elf*] \
152 || [istarget *-sde-elf*] \
153 || [istarget *-*-netbsd*] \
154 || [istarget *-*-linux*] \
155 || [istarget *-*-sysv4*] } {
156 if [istarget *el-*-*] {
157 set abi_asflags(o32) -32
158 set abi_asflags(n32) "-march=from-abi -n32"
159 set abi_ldflags(n32) -melf32ltsmipn32
160 set abi_asflags(n64) "-march=from-abi -64"
161 set abi_ldflags(n64) -melf64ltsmip
162 } else {
163 set abi_asflags(o32) -32
164 set abi_asflags(n32) "-march=from-abi -n32"
165 set abi_ldflags(n32) -melf32btsmipn32
166 set abi_asflags(n64) "-march=from-abi -64"
167 set abi_ldflags(n64) -melf64btsmip
168 }
169 set irixemul 0
170 } elseif { [istarget mips64*-*-freebsd*] \
171 || [istarget mips64*-*-kfreebsd*-gnu] } {
172 if [istarget *el-*-*] {
173 set abi_asflags(o32) -32
174 set abi_ldflags(o32) -melf32ltsmip_fbsd
175 set abi_asflags(n64) "-march=from-abi -64"
176 set abi_ldflags(n64) -melf64ltsmip_fbsd
177 } else {
178 set abi_asflags(o32) -32
179 set abi_ldflags(o32) -melf32btsmip_fbsd
180 set abi_asflags(n64) "-march=from-abi -64"
181 set abi_ldflags(n64) -melf64btsmip_fbsd
182 }
183 set irixemul 0
184 } elseif { [istarget *-*-freebsd*] \
185 || [istarget *-*-kfreebsd*-gnu] } {
186 if [istarget *el-*-*] {
187 set abi_asflags(n32) "-march=from-abi -n32"
188 set abi_ldflags(n32) -melf32ltsmipn32_fbsd
189 set abi_asflags(n64) "-march=from-abi -64"
190 set abi_ldflags(n64) -melf64ltsmip_fbsd
191 } else {
192 set abi_asflags(n32) "-march=from-abi -n32"
193 set abi_ldflags(n32) -melf32btsmipn32_fbsd
194 set abi_asflags(n64) "-march=from-abi -64"
195 set abi_ldflags(n64) -melf64btsmip_fbsd
196 }
197 set irixemul 0
198 } elseif { [istarget *vr4100*-*-elf*] \
199 || [istarget *vr4300*-*-elf*] \
200 || [istarget *vr5000*-*-elf*] } {
201 set abi_asflags(o32) -32
202 set irixemul 1
203 } elseif { [istarget mips64*el-ps2-elf*] } {
204 set abi_asflags(o32) -32
205 set abi_ldflags(o32) -melf32lr5900
206 set irixemul 1
207 } elseif { [istarget *-*-elf*] \
208 || [istarget *-*-rtems*] } {
209 set abi_asflags(o32) -32
210 set irixemul 1
211 } elseif { [istarget *-*-irix6*] } {
212 set abi_asflags(o32) -32
213 set abi_asflags(n64) "-march=from-abi -64"
214 set abi_ldflags(o32) -melf32bsmip
215 set abi_ldflags(n64) -melf64bmip
216 set irixemul 1
217 } else {
218 set abi_asflags(o32) -32
219 set irixemul 1
220 }
221 set tmips [expr $irixemul ? {""} : {"t"}]
222
223 run_dump_test_o32 "mips-ase-1"
224 run_dump_test_o32 "mips-ase-2"
225 run_dump_test_o32 "mips-ase-3"
226 run_dump_test "mips-xpa-virt-1"
227 run_dump_test "mips-xpa-virt-2"
228 run_dump_test "mips-xpa-virt-3"
229 run_dump_test "mips-xpa-virt-4"
230 run_dump_test_o32 "mixed-mips16" noarch
231 run_dump_test_o32 "mixed-micromips" noarch
232 run_dump_test "mixed-mips16-micromips"
233 run_dump_test_o32 "mips16-undecoded" noarch
234 run_dump_test_o32 "mips16e2-undecoded" noarch
235 run_dump_test_o32 "mips16-pcrel"
236 run_dump_test_o32 "mips16-extend-noinsn"
237 run_dump_test_o32 "mips16-extend-insn" noarch
238 run_dump_test_o32 "mips16e2-extend-insn" noarch
239 run_dump_test_o32 "mips16-alias" noarch
240 run_dump_test_o32 "mips16-noalias" noarch
241 run_dump_test_o32 "mips1-branch-alias"
242 run_dump_test_o32 "mips1-branch-noalias"
243 run_dump_test_o32 "mips2-branch-alias"
244 run_dump_test_o32 "mips2-branch-noalias"
245 run_dump_test_o32 "mips32r6-branch-alias"
246 run_dump_test_o32 "mips32r6-branch-noalias"
247 run_dump_test_o32 "micromips-branch-alias"
248 run_dump_test_o32 "micromips-branch-noalias"
249
250 run_dump_test_o32 "mips-note-2"
251 run_dump_test_n32 "mips-note-2-n32"
252 run_dump_test_n64 "mips-note-2-n64"
253 run_dump_test_o32 "mips-note-2r"
254 run_dump_test_n32 "mips-note-2r-n32"
255 run_dump_test_n64 "mips-note-2r-n64"
256
257 run_dump_test_o32 "mips-reginfo"
258 run_dump_test_n32 "mips-reginfo-n32"
259
260 run_dump_test_o32 "global-local-symtab-o32${tmips}"
261 run_dump_test_n32 "global-local-symtab-n32${tmips}"
262 run_dump_test_n64 "global-local-symtab-n64"
263 run_dump_test_o32 "global-local-symtab-sort-o32${tmips}"
264 run_dump_test_n32 "global-local-symtab-sort-n32${tmips}"
265 run_dump_test_n64 "global-local-symtab-sort-n64${tmips}"
266 run_dump_test_o32 "global-local-symtab-final-o32" useld
267 run_dump_test_n32 "global-local-symtab-final-n32" useld
268 run_dump_test_n64 "global-local-symtab-final-n64" useld