1 # Copyright (C) 1993 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
20 # Written by the Center for Software Science at the University of Utah
21 # and by Cygnus Support.
23 proc do_ble_relocation_test {} {
24 set testname "blebug.s: Test for proper relocation for BLE (part 2)"
27 if [gas_test_old "blebug.s" "" "Proper relocation for BLE (part 1)"] then {
28 objdump_start_no_subdir "a.out" "-r"
30 if ![istarget hppa*-*-*elf*] then {
31 # At one time both versions of the assembler would incorrectly use
32 # a PC-relative relocation for a BLE instruction.
35 -re "^00000004\[^\n\]*ABS_CALL\[^\n\]*\n" { set x 1 }
37 timeout { perror "timeout\n"; break }
42 # At one time both versions of the assembler would incorrectly use
43 # a PC-relative relocation for a BLE instruction.
46 -re "^00000000\[^\n\]*DIR21L\[^\n\]*\n" { set x 1 }
47 -re "^00000004\[^\n\]*DIR17R\[^\n\]*\n" { set x 1 }
49 timeout { perror "timeout\n"; break }
56 # This was intended to do any cleanup necessary. It kinda looks like it
57 # isn't needed, but just in case, please keep it in for now.
60 # Did we find what we were looking for? If not, flunk it.
61 if [expr $x==1] then { pass $testname } else { fail $testname }
64 proc do_relocation_reduction_tests {} {
65 set testname "relocreduce.s: Test relocation reductions (part 2)"
68 if [gas_test_old "relocreduce.s" "" "Relocation reductions (part1)"] then {
69 objdump_start_no_subdir "a.out" "-r"
71 # Check to make sure relocations involving procedure labels
72 # are not reduced to a relocation involving some other symbol.
73 # Doing so makes generating parameter relocation stubs impossible.
76 -re "^00000004\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
78 -re "^00000014\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
81 timeout { perror "timeout\n"; break }
87 # This was intended to do any cleanup necessary. It kinda looks like it
88 # isn't needed, but just in case, please keep it in for now.
91 # Did we find what we were looking for? If not, flunk it.
92 if [expr $x==2] then { pass $testname } else { fail $testname }
95 proc do_ble_mode_selector_test {} {
96 set testname "blebug2.s: blebug2"
99 gas_start "blebug2.s" "-al"
101 # GAS uses too many bits on the BLE instruction.
104 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
105 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
107 timeout { perror "timeout\n"; break }
112 # This was intended to do any cleanup necessary. It kinda looks like it
113 # isn't needed, but just in case, please keep it in for now.
116 # Did we find what we were looking for? If not, flunk it.
117 if [expr $x==2] then { pass $testname } else { fail $testname }
120 proc do_plabel_relocation_test {} {
121 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
124 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
125 objdump_start_no_subdir "a.out" "-r"
127 # Check that we make PLABEL relocation entries when they're needed.
130 -re "^\[04\]0000000\[^\n\]*PLABEL\[^\n\]*\n"
131 { set x [expr $x+1] }
132 -re "^\[04\]0000004\[^\n\]*PLABEL\[^\n\]*\n"
133 { set x [expr $x+1] }
135 timeout { perror "timeout\n"; break }
140 # This was intended to do any cleanup necessary. It kinda looks like it
141 # isn't needed, but just in case, please keep it in for now.
144 # Did we find what we were looking for? If not, flunk it.
145 if [expr $x==2] then { pass $testname } else { fail $testname }
149 proc do_selector_scope_test {} {
150 set testname "selectorbug.s: Test scope of field selector"
153 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
154 objdump_start_no_subdir "a.out" "-r"
156 # Check to make sure the relocation entry after the plabel is correct.
157 # If an old field selector was incorrectly "carried" over, then
158 # this test will fail.
159 if [istarget hppa*-*-*elf*] then {
162 -re "^00000014\[^\n\]*DIR32\[^\n\]*\n"
164 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
167 timeout { perror "timeout\n"; break }
174 -re "^00000014\[^\n\]*DATA_ONE\[^\n\]*\n"
176 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
179 timeout { perror "timeout\n"; break }
185 # This was intended to do any cleanup necessary. It kinda looks like it
186 # isn't needed, but just in case, please keep it in for now.
189 # Did we find what we were looking for? If not, flunk it.
190 if [expr $x==1] then { pass $testname } else { fail $testname }
194 proc do_local_label_as_operand_test {} {
195 set testname "labelopbug.s: Test local label as operand (non-branching)"
198 if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
199 objdump_start_no_subdir "a.out" "-r"
201 # Check to make sure we handle difference of local lables as an operand
202 # to a non-branching instruction correctly.
205 -re "^0000002c\[^\n\]*0x00000024\[^\n\]*\n"
206 { set x [expr $x+1] }
207 -re "^00000030\[^\n\]*0x00000024\[^\n\]*\n"
208 { set x [expr $x+1] }
210 timeout { perror "timeout\n"; break }
215 # This was intended to do any cleanup necessary. It kinda looks like it
216 # isn't needed, but just in case, please keep it in for now.
219 # Did we find what we were looking for? If not, flunk it.
220 if [expr $x==2] then { pass $testname } else { fail $testname }
224 proc do_exit_relocation_test {} {
225 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
228 # Elf (osf) does not use ENTRY/EXIT relocations.
229 # I guess we could look at the unwind subspaces it builds...
230 # Until then, make sure it still assembles.
231 if [istarget hppa*-*-*elf*] then {
232 gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
236 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
237 objdump_start_no_subdir "a.out" "-r"
239 # Note that a match here is really a FAILURE!
242 -re "^00000000\[^\n\]*R_EXIT\[^\n\]*\n"
243 { set x [expr $x+1] }
245 timeout { perror "timeout\n"; break }
250 # This was intended to do any cleanup necessary. It kinda looks like it
251 # isn't needed, but just in case, please keep it in for now.
254 # Did we find what we were looking for? If not, flunk it.
255 if [expr $x==0] then { pass $testname } else { fail $testname }
259 proc do_cross_space_fixup_test_1 {} {
260 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 2)"
263 # ELF (osf) doesn't really handle extra sections too well...
264 if [istarget hppa*-*-*elf*] then {
268 if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
269 objdump_start_no_subdir "a.out" "-r"
271 # Make sure GAS generated a fixup/relocation for the cross-space
275 -re "^00000000\[^\n\]*PCREL_CALL\[^\n\]*\n"
276 { set x [expr $x+1] }
278 timeout { perror "timeout\n"; break }
283 # This was intended to do any cleanup necessary. It kinda looks like it
284 # isn't needed, but just in case, please keep it in for now.
287 # Did we find what we were looking for? If not, flunk it.
288 if [expr $x==1] then { pass $testname } else { fail $testname }
292 proc do_cross_space_fixup_test_2 {} {
293 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 3)"
296 # ELF (osf) doesn't really handle extra sections too well...
297 if [istarget hppa*-*-*elf*] then {
301 gas_start "fixupbug.s" "-al"
305 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
307 timeout { perror "timeout\n"; break }
312 # This was intended to do any cleanup necessary. It kinda looks like it
313 # isn't needed, but just in case, please keep it in for now.
316 # Did we find what we were looking for? If not, flunk it.
317 if [expr $x==1] then { pass $testname } else { fail $testname }
320 proc do_round_mode_test {} {
321 set testname "roundmode.s: Test switching of rounding modes (part 2)"
324 if [gas_test_old "roundmode.s" "" "Test switch of rounding modes(part 1)"] {
325 objdump_start_no_subdir "a.out" "-r"
327 # Make sure GAS generated correct relocations to switch rounding modes.
328 # Also make sure (for SOM) that redundant rounding mode relocations
330 if [istarget hppa*-*-*elf*] then {
333 -re "^00000000\[^\n\]*DIR21L\[^\n\]*\n"
334 { set x [expr $x+1] }
335 -re "^00000004\[^\n\]*DIR14R\[^\n\]*\n"
336 { set x [expr $x+1] }
337 -re "^00000008\[^\n\]*DIR21L\[^\n\]*\n"
338 { set x [expr $x+1] }
339 -re "^0000000c\[^\n\]*DIR14R\[^\n\]*\n"
340 { set x [expr $x+1] }
341 -re "^00000010\[^\n\]*DIR21L\[^\n\]*\n"
342 { set x [expr $x+1] }
343 -re "^00000014\[^\n\]*DIR14R\[^\n\]*\n"
344 { set x [expr $x+1] }
345 -re "^00000018\[^\n\]*DIR21L\[^\n\]*\n"
346 { set x [expr $x+1] }
347 -re "^0000001c\[^\n\]*DIR14R\[^\n\]*\n"
348 { set x [expr $x+1] }
350 timeout { perror "timeout\n"; break }
357 -re "^00000000\[^\n\]*R_R_MODE\[^\n\]*\n"
358 { set x [expr $x+1] }
359 -re "^00000004\[^\n\]*R_R_MODE\[^\n\]*\n"
361 -re "^00000008\[^\n\]*R_N_MODE\[^\n\]*\n"
362 { set x [expr $x+1] }
363 -re "^0000000c\[^\n\]*R_N_MODE\[^\n\]*\n"
365 -re "^00000010\[^\n\]*R_R_MODE\[^\n\]*\n"
366 { set x [expr $x+1] }
367 -re "^00000014\[^\n\]*R_R_MODE\[^\n\]*\n"
369 -re "^00000018\[^\n\]*R_R_MODE\[^\n\]*\n"
370 { set x [expr $x+1] }
371 -re "^0000001c\[^\n\]*R_R_MODE\[^\n\]*\n"
374 timeout { perror "timeout\n"; break }
380 # This was intended to do any cleanup necessary. It kinda looks like it
381 # isn't needed, but just in case, please keep it in for now.
384 # Did we find what we were looking for? If not, flunk it.
385 if [istarget hppa*-*-*elf*] then {
386 if [expr $x==8] then { pass $testname } else { fail $testname }
388 if [expr $x==4] then { pass $testname } else { fail $testname }
393 proc do_function_reloc_bug {} {
394 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
397 if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
398 objdump_start_no_subdir "a.out" "-r"
400 # Make sure GAS generated a correct relocation for the reference.
404 -re "^000000cc\[^\n\]*f2___4\[^\n+\]*\n"
405 { set x [expr $x+1] }
406 -re "^000000d0\[^\n\]*f2___4\[^\n+\]*\n"
407 { set x [expr $x+1] }
409 timeout { perror "timeout\n"; break }
414 # This was intended to do any cleanup necessary. It kinda looks like it
415 # isn't needed, but just in case, please keep it in for now.
418 # Did we find what we were looking for? If not, flunk it.
419 if [expr $x==2] then { pass $testname } else { fail $testname }
421 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
424 objdump_start_no_subdir "a.out" "-d"
425 # Make sure we didn't put anything in the instruction itself!
428 -re "^000000cc\[^\n\]*ldil 0,r20\[^\n\]*\n"
429 { set x [expr $x+1] }
430 -re "^000000d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n"
431 { set x [expr $x+1] }
433 timeout { perror "timeout\n"; break }
438 # This was intended to do any cleanup necessary. It kinda looks like it
439 # isn't needed, but just in case, please keep it in for now.
442 # Did we find what we were looking for? If not, flunk it.
443 if [expr $x==2] then { pass $testname } else { fail $testname }
448 if [istarget hppa*-*-*] then {
449 # Make sure we put the right relocation entry on a BLE instruction.
450 do_ble_relocation_test
452 # Make sure relocation reductions are not too agressive about
453 # adjusting relocations against some symbols.
454 do_relocation_reduction_tests
456 # Check that mode selectors on a ble instruction actually work.
457 do_ble_mode_selector_test
459 # 1.36 simply didn't generate all the plabels it should have. Make
461 do_plabel_relocation_test
463 # Make sure a field selector only effects the current instruction
464 # or assembler directive.
465 do_selector_scope_test
467 # This should really generate a relocation. It would make life much
468 # easier on the optimizing linker. Until then just make sure the
469 # difference is computed correctly.
470 do_local_label_as_operand_test
472 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
473 # were not in the source code.
474 do_exit_relocation_test
476 # GAS2 incorrectly thought it could apply a fixup for a pc-relative
477 # branch/call which crossed different subspaces.
478 # Also check that the assembled instruction is correct
479 do_cross_space_fixup_test_1
480 do_cross_space_fixup_test_2
482 # Make sure we switch rounding modes correctly
485 # Test for a bug found when a function was used in a non-branching
486 # instruction *without* a plabel (for portable runtime model)
487 do_function_reloc_bug