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