Use is_xcoff_format in gas testsuite
[deliverable/binutils-gdb.git] / gas / testsuite / gas / all / gas.exp
1 # Copyright (C) 2012-2020 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, MA 02110-1301, USA.
16
17 #
18 # These tests should be valid on all targets.
19 #
20
21 # I think currently all targets fail this one when listings are enabled.
22 gas_test "p2425.s" "" "" "pcrel values in assignment"
23
24 # p1480.s uses a ".space" directive which for most assemblers means
25 # "allocate some space". On the PA it means "switch into this space".
26 #
27 # Therefore this test (as it is currently written) is completely bogus
28 # for any PA target. Do not bother trying to run it and just claim
29 # it fails.
30 #
31 # The C54x uses ".space" to allocate bits, and requires absolute expressions;
32 # The ".space" directive is taken care of in the C54x-specific tests, so fail
33 # here
34 #
35 # The test also doesn't work on mep targets, since they use RELC, and it
36 # will avoid simplifying the expression since it conservatively assumes
37 # ugly expressions can be saved until link-time.
38 if { [istarget hppa*-*-*] || [istarget *c54x*-*-*] || [istarget mep*-*-*]} then {
39 setup_xfail *-*-*
40 fail "simplifiable double subtraction"
41 } else {
42 gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
43 }
44
45 # No floating point support in assembly code for CRIS and Z80.
46 if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
47 && ![istarget z80-*-*] } then {
48 gas_test "float.s" "" "" "simple FP constants"
49 }
50
51 # This test is meaningless for the PA; the difference of two undefined
52 # symbols is something that is (and must be) supported on the PA.
53 # The same is true for ALPHA-VMS.
54 #
55 # The AVR, MICROBLAZE, MN10300, RL78 and RX ports all support link time
56 # relaxation, which in turn allows for link time resolution of the
57 # differences of two previously undefined symbols. Hence this test will
58 # not pass for these targets.
59 if { ![istarget alpha*-*-*vms*]
60 && ![istarget am3*-*-*]
61 && ![istarget avr-*-*]
62 && ![istarget ft32-*-*]
63 && ![istarget hppa*-*-*]
64 && ![istarget microblaze-*-*]
65 && ![istarget mn10300-*-*]
66 && ![istarget msp430*-*-*]
67 && ![istarget riscv*-*-*]
68 && ![istarget rl78-*-*]
69 && ![istarget rx-*-*] } then {
70 gas_test_error "diff1.s" "" "difference of two undefined symbols"
71 }
72
73 gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
74 gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
75
76 # The inode comparison used to detect identical input and output files
77 # doesn't work on non-Posix hosts.
78 if { ![ishost "*-*-mingw*"] } then {
79 gas_test_error "none.s" "-o $srcdir/$subdir/none.s" "Output file must be distinct from input"
80 }
81
82 # .equ works differently on some targets.
83 switch -glob $target_triplet {
84 hppa*-*-* { }
85 *c54x*-*-* { }
86 default {
87 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
88 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
89 }
90 }
91
92 gas_test "eqv-ok.s" "" "" ".eqv support"
93 gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
94 if { [istarget "pdp11-*-*"] } then {
95 run_dump_test eqv-dot-pdp11
96 } else {
97 run_dump_test eqv-dot
98 }
99
100 if { ![istarget "bfin-*-*"] } then {
101 gas_test "assign-ok.s" "" "" "== assignment support"
102 }
103 gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
104 run_dump_test assign-bad-recursive
105
106 run_dump_test simple-forward
107 run_dump_test forward
108
109 # aout relocs are often weird, so is mep. don't bother testing
110 # som doesn't use a .text section
111 # mmix doesn't like .L1:
112 # ti addresses aren't octets.
113 if { ![is_aout_format] } {
114 switch -glob $target_triplet {
115 hppa*64*-*-* {
116 run_dump_test fwdexp
117 }
118 alpha-*-*linux*ecoff { }
119 alpha-*-osf* { }
120 hppa*-*-hpux* { }
121 mep-*-* { }
122 mmix-*-* { }
123 nds32*-*-* { }
124 tic30*-*-* { }
125 tic4x*-*-* { }
126 tic54x*-*-* { }
127 default {
128 run_dump_test fwdexp
129 }
130 }
131 }
132
133 # .set works differently on some targets.
134 # most of the tests won't work on targets that set linkrelax.
135 # 4 octet bytes confuse address matching on ti targets.
136 # pdp11 gets unexpected reloc types.
137 switch -glob $target_triplet {
138 alpha*-*-* { }
139 am3*-*-* { }
140 cr16*-*-* { }
141 crx*-*-* { }
142 h8300-*-* { }
143 mips*-*-* { }
144 mn10200-*-* { }
145 mn10300-*-* { }
146 msp430*-*-* { }
147 nds32*-*-* { }
148 pdp11-*-* { }
149 tic30*-*-* { }
150 tic4x*-*-* { }
151 tic54x*-*-* { }
152 xtensa*-*-* { }
153 z80-*-* { }
154 default {
155 run_dump_test redef
156 # These targets fail redef2 because they disallow redefined
157 # symbols on relocs.
158 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
159 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
160 run_dump_test redef2
161 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
162 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
163 # rs6000-aix disallows redefinition via .comm.
164 if [is_xcoff_format] {
165 setup_xfail *-*-*
166 }
167 # These targets fail redef3 because section contents for the
168 # word referencing the .comm sym is not zero and/or its reloc
169 # has a non-zero addend. Relaxing the test would hide real
170 # failures.
171 setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
172 "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
173 "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" \
174 "x86_64-*-cygwin*" "x86_64-*-mingw*"
175 run_dump_test redef3
176 gas_test_error "redef4.s" "" ".set for symbol already used as label"
177 gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
178 }
179 }
180
181 proc do_comment {} {
182 set testname "comment.s: comments in listings"
183 set x1 0
184 set x2 0
185 set x3 0
186 set white {[ \t]*}
187 gas_start "comment.s" "-al"
188 while 1 {
189 # Apparently CRLF is received when using ptys for subprocesses; hence the
190 # \r\n for line 3.
191 expect {
192 -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 }
193 -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 }
194 -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 }
195 -re "\[^\n\]*\n" { }
196 timeout { perror "timeout\n"; break }
197 eof { break }
198 }
199 }
200 gas_finish
201 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
202 }
203
204 do_comment
205
206 # This test checks the output of the -ag switch. It must detect at least
207 # the name of the input file, output file, and options passed.
208 proc general_info_section {} {
209 set testname "general info section in listings"
210 set x1 0
211 set x2 0
212 set x3 0
213 set white {[ \t]*}
214 gas_start "comment.s" "-agn"
215 while 1 {
216 expect {
217 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
218 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
219 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
220 -re "\[^\n\]*\n" { }
221 timeout { perror "timeout\n"; break }
222 eof { break }
223 }
224 }
225 gas_finish
226 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
227 }
228
229 general_info_section
230
231 #
232 # Test x930509a -- correct assembly of differences involving forward
233 # references.
234 #
235
236 proc do_930509a {} {
237 set testname "difference between forward references"
238 set x 0
239 gas_start "x930509.s" "-al"
240 while 1 {
241 # We need to accommodate both byte orders here.
242 # If ".long" means an 8-byte value on some target someday, this test will have
243 # to be fixed.
244 expect {
245 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
246 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
247 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
248 -re "\[^\n\]*\n" { }
249 timeout { perror "timeout\n"; break }
250 eof { break }
251 }
252 }
253 gas_finish
254 if !$x then { fail $testname }
255 }
256
257 # This test is meaningless for the PA and CR16/CRX: the difference of two
258 # symbols cannot be resolved by the assembler.
259 # C54x assembler (for compatibility) does not allow differences between
260 # forward references.
261 # C30 counts a four byte offset as a difference of one.
262 if { ![istarget *c30*-*-*]
263 && ![istarget *c4x*-*-*]
264 && ![istarget *c54x*-*-*]
265 && ![istarget cr16*-*-*]
266 && ![istarget crx*-*-*]
267 && ![istarget ft32-*-*]
268 && ![istarget h8300*-*-*]
269 && ![istarget hppa*-*-*] } then {
270 # The vax fails because VMS can apparently actually handle this
271 # case in relocs, so gas doesn't handle it itself.
272 # msp430, mn10[23]00 and riscv emit two relocs to handle the difference of two symbols.
273 setup_xfail "am3*-*-*" "mn10200-*-*" "mn10300*-*-*" "msp430*-*-*" "riscv*-*-*" "vax*-*-vms*"
274 do_930509a
275 }
276
277 # ".struct" and ".align" have different meanings on c54x
278 # These directives are done in the c54x-specific tests instead
279 switch -glob $target_triplet {
280 hppa*-*-* { }
281 *c4x*-*-* { }
282 *c54x*-*-* { }
283 default {
284 run_dump_test struct
285 run_dump_test align
286 run_dump_test align2
287 }
288 }
289
290 # '<' and '>' appear to have special meanings on the excluded targets
291 switch -glob $target_triplet {
292 frv-*-* { }
293 hppa*-*-* { }
294 m32r-*-* { }
295 mmix-*-* { }
296 *c4x*-*-* { }
297 *c54x*-*-* { }
298 bfin-*-* { }
299 default {
300 run_dump_test altmacro
301 # The second test is valid only when '!' is not a comment
302 # character (it is allowed to be a line comment character).
303 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
304 run_dump_test altmac2
305 # Similarly this test does not work when ! is a line separator.
306 run_dump_test eval
307 }
308 }
309 }
310
311 # This test is for any COFF target.
312 # We omit the ARM toolchains because they define locals to
313 # start with '.', which eliminates .eos, .text etc from the output.
314 # Omit c54x, since .tag and .def mean something different on that target
315 if { ([istarget *-*-coff*] && ![istarget arm*-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
316 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
317 || [istarget i*86-*-aix*] \
318 || [istarget i*86-*-sco*] \
319 || [istarget i*86-*-isc*] \
320 || [istarget i*86-*-go32*] \
321 || [istarget i*86-*-cygwin*] \
322 || [istarget x86_64-*-mingw*] \
323 || [istarget i*86-*-*nt] \
324 || [istarget i*86-*-interix*] } {
325 run_dump_test cofftag
326 }
327
328 # Test omitting conditionals from listings.
329 proc test_cond {} {
330 global comp_output
331 global srcdir
332 global subdir
333
334 set testname "conditional listings"
335 if { [istarget "pdp11-*-*"] } then {
336 set listing "cond-pdp11.l"
337 } else {
338 set listing "cond.l"
339 }
340 gas_run cond.s "-alc" ">dump.out"
341 if ![string match "" $comp_output] {
342 send_log "$comp_output\n"
343 fail $testname
344 } else {
345 if { [regexp_diff dump.out $srcdir/$subdir/$listing] } {
346 fail $testname
347 } else {
348 pass $testname
349 }
350 }
351 }
352
353 # This test is not suitable for the PA for various reasons
354 # not limited to the fact that it depends on specific section
355 # names appearing in the output file.
356 # Again, p2align doesn't work on c54x and related targets.
357 switch -glob $target_triplet {
358 alpha-*-linux*ecoff { }
359 alpha-*-osf* { }
360 hppa*-*-* { }
361 *c4x*-*-* { }
362 *c54x*-*-* { }
363 rl78-*-* { }
364 rx-*-* { }
365 default {
366 test_cond
367 remote_download host "$srcdir/$subdir/incbin.dat"
368 run_dump_test incbin
369 }
370 }
371
372 if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
373 || [istarget "i*86-*-cygwin*"] \
374 || [istarget "i*86-*-mingw32*"] } {
375 gas_test "fastcall.s" "" "" "fastcall labels"
376 }
377
378 if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
379 run_dump_test assign
380 }
381 run_dump_test sleb128
382 run_dump_test sleb128-2
383 run_dump_test sleb128-3
384 run_dump_test sleb128-4
385 run_dump_test sleb128-5
386 # .byte is not 8 bits on either tic4x or tic54x
387 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
388 run_dump_test sleb128-7
389 run_dump_test sleb128-8
390 }
391 run_dump_test sleb128-9
392
393 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
394 # .space is different on hppa*-hpux.
395 # MeP put bytes into packets.
396 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
397 run_dump_test relax
398 }
399
400 # powerpc and s390 allow a string argument to .byte
401 if { ![istarget "powerpc*-*-*"] && ![istarget "rs6000*-*-*"] && ![istarget "s390*-*-*"] } {
402 run_dump_test byte
403 }
404
405 run_dump_test quad
406
407 # poor little PDP-11 can't handle 16-byte values
408 if { ![istarget "pdp11-*-*"] } {
409 run_dump_test octa
410 }
411
412 # .set works differently on some targets.
413 switch -glob $target_triplet {
414 alpha*-*-* { }
415 mips*-*-* { }
416 *c54x*-*-* { }
417 z80-*-* { }
418 default {
419 run_dump_test weakref1
420 run_dump_test weakref1g
421 run_dump_test weakref1l
422 run_dump_test weakref1u
423 run_dump_test weakref1w
424 }
425 }
426 gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
427 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
428 gas_test_error "weakref4.s" "" "is already defined"
429
430 run_dump_test string
431 if [is_elf_format] {
432 run_dump_test none
433 }
434
435 run_dump_test quoted-sym-names
436
437 run_list_test pr20312
438
439 load_lib gas-dg.exp
440 dg-init
441 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
442 dg-finish
443
444 # Set $nop_type appropriately to indicate the NOP instruction mnemonic.
445 switch -glob $target_triplet {
446 bpf-*-* {
447 set nop_type 6
448 }
449 mmix-*-* {
450 set nop_type 5
451 }
452 or1k*-*-* {
453 set nop_type 2
454 }
455 ia64-*-* {
456 set nop_type 1
457 }
458 default {
459 set nop_type 0
460 }
461 }
462 run_dump_test "org-1" [list [list as "--defsym nop_type=$nop_type"]]
463 run_dump_test "org-2"
464 run_dump_test "org-3"
465 run_dump_test "org-4"
466 run_dump_test "org-5"
467 run_dump_test "org-6"
468
469 run_dump_test "fill-1"
470
471 gas_test "pr23938.s" "" "" ".xstabs"
This page took 0.040797 seconds and 4 git commands to generate.