1 # Copyright (C) 2013-2021 Free Software Foundation, Inc.
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.
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.
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,
18 if {![istarget mips*-*-*] || ![is_elf_format]} {
23 set tempfile [remote_download host tmpdir/bintest.o]
26 set tempfile tmpdir/bintest.o
27 set copyfile tmpdir/copy
30 # run_dump_test_abi ABI NAME ARGS
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 } {
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]
51 if { [lindex $args 0] == "useld" } {
52 set ldflags $abi_ldflags($abi)
53 set args [lreplace $args 0 0]
56 lappend args {notarget *-*-*}
59 set testargs [list [list as $asflags]]
60 if { [info exists ldflags] } {
61 lappend testargs [list ld $ldflags]
63 if { [llength $args] > 0 } {
64 set testargs [concat $testargs $args]
67 run_dump_test $name $testargs
70 # run_dump_test_o32 NAME ARGS
72 # Invoke "run_dump_test_abi" for test NAME using the o32 ABI and
74 proc run_dump_test_o32 { name args } {
75 run_dump_test_abi o32 $name [lindex $args 0]
78 # run_dump_test_n32 NAME ARGS
80 # Invoke "run_dump_test_abi" for test NAME using the n32 ABI and
82 proc run_dump_test_n32 { name args } {
83 run_dump_test_abi n32 $name [lindex $args 0]
86 # run_dump_test_n64 NAME ARGS
88 # Invoke "run_dump_test_abi" for test NAME using the n64 ABI and
90 proc run_dump_test_n64 { name args } {
91 run_dump_test_abi n64 $name [lindex $args 0]
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*]]
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) ""
121 # Override as needed.
122 if {[istarget *-*-openbsd*] } {
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
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
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
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
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
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
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
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
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
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
198 } elseif { [istarget *vr4100*-*-elf*] \
199 || [istarget *vr4300*-*-elf*] \
200 || [istarget *vr5000*-*-elf*] } {
201 set abi_asflags(o32) -32
203 } elseif { [istarget mips64*el-ps2-elf*] } {
204 set abi_asflags(o32) -32
205 set abi_ldflags(o32) -melf32lr5900
207 } elseif { [istarget *-*-elf*] \
208 || [istarget *-*-rtems*] } {
209 set abi_asflags(o32) -32
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
218 set abi_asflags(o32) -32
221 set tmips [expr $irixemul ? {""} : {"t"}]
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
242 run_dump_test_o32 "mips-note-2"
243 run_dump_test_n32 "mips-note-2-n32"
244 run_dump_test_n64 "mips-note-2-n64"
245 run_dump_test_o32 "mips-note-2r"
246 run_dump_test_n32 "mips-note-2r-n32"
247 run_dump_test_n64 "mips-note-2r-n64"
249 run_dump_test_o32 "mips-reginfo"
250 run_dump_test_n32 "mips-reginfo-n32"
252 run_dump_test_o32 "global-local-symtab-o32${tmips}"
253 run_dump_test_n32 "global-local-symtab-n32${tmips}"
254 run_dump_test_n64 "global-local-symtab-n64"
255 run_dump_test_o32 "global-local-symtab-sort-o32${tmips}"
256 run_dump_test_n32 "global-local-symtab-sort-n32${tmips}"
257 run_dump_test_n64 "global-local-symtab-sort-n64${tmips}"
258 run_dump_test_o32 "global-local-symtab-final-o32" useld
259 run_dump_test_n32 "global-local-symtab-final-n32" useld
260 run_dump_test_n64 "global-local-symtab-final-n64" useld