1 # Copyright (C) 1993, 1996, 1997 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "^0+4\[^\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 "^0+\[^\n\]*DIR21L\[^\n\]*\n" { set x 1 }
47 -re "^0+4\[^\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 "reduce.s: Test relocation reductions (part 2)"
68 if {[istarget hppa*w-*-*]
69 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
73 if [gas_test_old "reduce.s" "" "Relocation reductions (part1)"] then {
74 objdump_start_no_subdir "a.out" "-r"
76 # Check to make sure relocations involving procedure labels
77 # are not reduced to a relocation involving some other symbol.
78 # Doing so makes generating parameter relocation stubs impossible.
81 -re "^0+4\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
83 -re "^0+14\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
86 timeout { perror "timeout\n"; break }
92 # This was intended to do any cleanup necessary. It kinda looks like it
93 # isn't needed, but just in case, please keep it in for now.
96 # Did we find what we were looking for? If not, flunk it.
97 if [expr $x==2] then { pass $testname } else { fail $testname }
99 set testname "reduce2.s: More relocation reduction tests (part 2)"
102 if [gas_test_old "reduce2.s" "" "More relocation reductions (part1)"] then {
103 objdump_start_no_subdir "a.out" "-r"
105 # Check to make sure DLT relative relocs are not reduced to sym+addend
106 # Doing so doesn't work as one might expect
109 -re "^0+4\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
110 { set x [expr $x+1] }
111 -re "^0+1c\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
112 { set x [expr $x+1] }
113 -re "^0+30\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
114 { set x [expr $x+1] }
115 -re "^0+48\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
116 { set x [expr $x+1] }
118 timeout { perror "timeout\n"; break }
124 # This was intended to do any cleanup necessary. It kinda looks like it
125 # isn't needed, but just in case, please keep it in for now.
128 # Did we find what we were looking for? If not, flunk it.
129 if [expr $x==2] then { pass $testname } else { fail $testname }
131 set testname "reduce3.s: Test even more relocation reductions (part 2)"
134 if [gas_test_old "reduce3.s" "" "Even more relocation reductions (part1)"] then {
135 objdump_start_no_subdir "a.out" "-r"
137 # Check to make sure relocations involving procedure labels
138 # are not reduced to a relocation involving some other symbol.
139 # Doing so makes generating parameter relocation stubs impossible.
142 -re "^0+c\[^\n\]*yabba\[^\n\+\]*\n"
143 { set x [expr $x+1] }
144 -re "^0+c\[^\n\]*yabba\+\[^\n\]*\n"
146 -re "^0+10\[^\n\]*yabba\[^\n\+\]*\n"
147 { set x [expr $x+1] }
148 -re "^0+10\[^\n\]*yabba\+\[^\n\]*\n"
151 timeout { perror "timeout\n"; break }
157 # This was intended to do any cleanup necessary. It kinda looks like it
158 # isn't needed, but just in case, please keep it in for now.
161 # Did we find what we were looking for? If not, flunk it.
162 if [expr $x==2] then { pass $testname } else { fail $testname }
165 proc do_ble_mode_selector_test {} {
166 set testname "blebug2.s: blebug2"
169 gas_start "blebug2.s" "-al"
171 # GAS uses too many bits on the BLE instruction.
174 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
175 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
177 timeout { perror "timeout\n"; break }
182 # This was intended to do any cleanup necessary. It kinda looks like it
183 # isn't needed, but just in case, please keep it in for now.
186 # Did we find what we were looking for? If not, flunk it.
187 if [expr $x==2] then { pass $testname } else { fail $testname }
190 proc do_ble_relocation_test {} {
191 set testname "blebug3.s: blebug3"
194 gas_start "blebug3.s" "-al"
198 -re "^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n" { set x [expr $x+1] }
200 timeout { perror "timeout\n"; break }
205 # This was intended to do any cleanup necessary. It kinda looks like it
206 # isn't needed, but just in case, please keep it in for now.
209 # Did we find what we were looking for? If not, flunk it.
210 if [expr $x==1] then { pass $testname } else { fail $testname }
213 proc do_plabel_relocation_test {} {
214 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
217 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
218 objdump_start_no_subdir "a.out" "-r"
220 # Check that we make PLABEL relocation entries when they're needed.
223 -re "^0+\[^\n\]*PLABEL\[^\n\]*\n"
224 { set x [expr $x+1] }
225 -re "^0+4\[^\n\]*PLABEL\[^\n\]*\n"
226 { set x [expr $x+1] }
228 timeout { perror "timeout\n"; break }
233 # This was intended to do any cleanup necessary. It kinda looks like it
234 # isn't needed, but just in case, please keep it in for now.
237 # Did we find what we were looking for? If not, flunk it.
238 if [expr $x==2] then { pass $testname } else { fail $testname }
242 proc do_selector_scope_test {} {
243 set testname "selectorbug.s: Test scope of field selector"
246 if [istarget hppa*w-*-*] then {
250 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
251 objdump_start_no_subdir "a.out" "-r"
253 # Check to make sure the relocation entry after the plabel is correct.
254 # If an old field selector was incorrectly "carried" over, then
255 # this test will fail.
256 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
259 -re "^0+14\[^\n\]*DIR32\[^\n\]*\n"
261 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
264 timeout { perror "timeout\n"; break }
271 -re "^0+14\[^\n\]*DATA_ONE\[^\n\]*\n"
273 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
276 timeout { perror "timeout\n"; break }
282 # This was intended to do any cleanup necessary. It kinda looks like it
283 # isn't needed, but just in case, please keep it in for now.
286 # Did we find what we were looking for? If not, flunk it.
287 if [expr $x==1] then { pass $testname } else { fail $testname }
291 proc do_local_label_as_operand_test {} {
292 set testname "labelopbug.s: Test local label as operand (non-branching)"
295 if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
296 objdump_start_no_subdir "a.out" "-r"
298 # Check to make sure we handle difference of local lables as an operand
299 # to a non-branching instruction correctly.
302 -re "^0+2c\[^\n\]*0x0+24\[^\n\]*\n"
303 { set x [expr $x+1] }
304 -re "^0+30\[^\n\]*0x0+24\[^\n\]*\n"
305 { 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==2] then { pass $testname } else { fail $testname }
321 proc do_exit_relocation_test {} {
322 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
325 # Elf (osf) does not use ENTRY/EXIT relocations.
326 # I guess we could look at the unwind subspaces it builds...
327 # Until then, make sure it still assembles.
328 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
329 gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
333 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
334 objdump_start_no_subdir "a.out" "-r"
336 # Note that a match here is really a FAILURE!
339 -re "^0+\[^\n\]*R_EXIT\[^\n\]*\n"
340 { set x [expr $x+1] }
342 timeout { perror "timeout\n"; break }
347 # This was intended to do any cleanup necessary. It kinda looks like it
348 # isn't needed, but just in case, please keep it in for now.
351 # Did we find what we were looking for? If not, flunk it.
352 if [expr $x==0] then { pass $testname } else { fail $testname }
356 proc do_cross_space_fixup_test_1 {} {
357 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 2)"
360 if [istarget hppa*w-*-*] then {
364 # ELF (osf) doesn't really handle extra sections too well...
365 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
369 if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
370 objdump_start_no_subdir "a.out" "-r"
372 # Make sure GAS generated a fixup/relocation for the cross-space
376 -re "^0+\[^\n\]*PCREL_CALL\[^\n\]*\n"
377 { set x [expr $x+1] }
379 timeout { perror "timeout\n"; break }
384 # This was intended to do any cleanup necessary. It kinda looks like it
385 # isn't needed, but just in case, please keep it in for now.
388 # Did we find what we were looking for? If not, flunk it.
389 if [expr $x==1] then { pass $testname } else { fail $testname }
393 proc do_cross_space_fixup_test_2 {} {
394 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 3)"
397 if [istarget hppa*w-*-*] then {
401 # ELF (osf) doesn't really handle extra sections too well...
402 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
406 gas_start "fixupbug.s" "-al"
410 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
412 timeout { perror "timeout\n"; break }
417 # This was intended to do any cleanup necessary. It kinda looks like it
418 # isn't needed, but just in case, please keep it in for now.
421 # Did we find what we were looking for? If not, flunk it.
422 if [expr $x==1] then { pass $testname } else { fail $testname }
425 proc do_round_mode_test {} {
426 set testname "roundmode.s: Test switching of rounding modes (part 2)"
429 if [gas_test_old "roundmode.s" "" "Test switch of rounding modes(part 1)"] {
430 objdump_start_no_subdir "a.out" "-r"
432 # Make sure GAS generated correct relocations to switch rounding modes.
433 # Also make sure (for SOM) that redundant rounding mode relocations
435 if { [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*] || [istarget hppa*w-*-*] } then {
438 -re "^0+\[^\n\]*DIR21L\[^\n\]*\n"
439 { set x [expr $x+1] }
440 -re "^0+4\[^\n\]*DIR14R\[^\n\]*\n"
441 { set x [expr $x+1] }
442 -re "^0+8\[^\n\]*DIR21L\[^\n\]*\n"
443 { set x [expr $x+1] }
444 -re "^0+c\[^\n\]*DIR14R\[^\n\]*\n"
445 { set x [expr $x+1] }
446 -re "^0+10\[^\n\]*DIR21L\[^\n\]*\n"
447 { set x [expr $x+1] }
448 -re "^0+14\[^\n\]*DIR14R\[^\n\]*\n"
449 { set x [expr $x+1] }
450 -re "^0+18\[^\n\]*DIR21L\[^\n\]*\n"
451 { set x [expr $x+1] }
452 -re "^0+1c\[^\n\]*DIR14R\[^\n\]*\n"
453 { set x [expr $x+1] }
455 timeout { perror "timeout\n"; break }
462 -re "^0+\[^\n\]*R_R_MODE\[^\n\]*\n"
463 { set x [expr $x+1] }
464 -re "^0+4\[^\n\]*R_R_MODE\[^\n\]*\n"
466 -re "^0+8\[^\n\]*R_N_MODE\[^\n\]*\n"
467 { set x [expr $x+1] }
468 -re "^0+c\[^\n\]*R_N_MODE\[^\n\]*\n"
470 -re "^0+10\[^\n\]*R_R_MODE\[^\n\]*\n"
471 { set x [expr $x+1] }
472 -re "^0+14\[^\n\]*R_R_MODE\[^\n\]*\n"
474 -re "^0+1c\[^\n\]*R_R_MODE\[^\n\]*\n"
477 timeout { perror "timeout\n"; break }
483 # This was intended to do any cleanup necessary. It kinda looks like it
484 # isn't needed, but just in case, please keep it in for now.
487 # Did we find what we were looking for? If not, flunk it.
488 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*] || [istarget hppa*w-*-*] } then {
489 if [expr $x==8] then { pass $testname } else { fail $testname }
491 if [expr $x==3] then { pass $testname } else { fail $testname }
496 proc do_function_reloc_bug {} {
497 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
500 if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
501 objdump_start_no_subdir "a.out" "-r"
503 # Make sure GAS generated a correct relocation for the reference.
507 -re "^0+cc\[^\n\]*f2___4\[^\n+\]*\n"
508 { set x [expr $x+1] }
509 -re "^0+d0\[^\n\]*f2___4\[^\n+\]*\n"
510 { set x [expr $x+1] }
512 timeout { perror "timeout\n"; break }
517 # This was intended to do any cleanup necessary. It kinda looks like it
518 # isn't needed, but just in case, please keep it in for now.
521 # Did we find what we were looking for? If not, flunk it.
522 if [expr $x==2] then { pass $testname } else { fail $testname }
524 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
527 objdump_start_no_subdir "a.out" "--prefix-addresses -d"
528 # Make sure we didn't put anything in the instruction itself!
531 -re "^0+cc\[^\n\]*ldil 0,r20\[^\n\]*\n"
532 { set x [expr $x+1] }
533 -re "^0+d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n"
534 { set x [expr $x+1] }
536 timeout { perror "timeout\n"; break }
541 # This was intended to do any cleanup necessary. It kinda looks like it
542 # isn't needed, but just in case, please keep it in for now.
545 # Did we find what we were looking for? If not, flunk it.
546 if [expr $x==2] then { pass $testname } else { fail $testname }
551 proc do_r_no_reloc {} {
552 set testname "r_no_reloc.s: Test for reloc bug in 4-byte R_NO_RELCOATION fixups (part 2)"
555 if [gas_test_old "r_no_reloc.s" "" "Test for reloc bug in 4-byte R_NO_RELOCATION fixups (part 1)"] {
556 objdump_start_no_subdir "a.out" "-r"
558 # Make sure GAS generated a correct relocation for the reference.
561 -re "^0+c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n"
562 { set x [expr $x+1] }
564 timeout { perror "timeout\n"; break }
569 # This was intended to do any cleanup necessary. It kinda looks like it
570 # isn't needed, but just in case, please keep it in for now.
573 # Did we find what we were looking for? If not, flunk it.
574 if [expr $x==1] then { pass $testname } else { fail $testname }
579 proc do_pic_relocation_test {} {
580 set testname "picreloc.s: Test for proper PIC relocation (part 2)"
583 if [istarget hppa*w-*-*] then {
587 # ELF (osf) doesn't really handle extra sections too well...
588 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
592 gas_start "picreloc.s" "-al"
596 -re "^ +\[0-9\]+ 0000 00000004\[^\n\]*\n" { set x [expr $x+1] }
598 timeout { perror "timeout\n"; break }
603 # This was intended to do any cleanup necessary. It kinda looks like it
604 # isn't needed, but just in case, please keep it in for now.
607 # Did we find what we were looking for? If not, flunk it.
608 if [expr $x==1] then { pass $testname } else { fail $testname }
611 proc do_apply_test {} {
612 set testname "applybug.s: Test for proper fixup appliation (part 2)"
615 # ELF (osf) doesn't really handle extra sections too well...
616 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
620 gas_start "applybug.s" "-al"
624 -re "^ +\[0-9\]+ 0000 00000000\[^\n\]*\n" { set x [expr $x+1] }
625 -re "^ +\[0-9\]+ 0004 00000000\[^\n\]*\n" { set x [expr $x+1] }
626 -re "^ +\[0-9\]+ 0008 00000000\[^\n\]*\n" { set x [expr $x+1] }
628 timeout { perror "timeout\n"; break }
633 # This was intended to do any cleanup necessary. It kinda looks like it
634 # isn't needed, but just in case, please keep it in for now.
637 # Did we find what we were looking for? If not, flunk it.
638 if [expr $x==3] then { pass $testname } else { fail $testname }
640 if [istarget hppa*-*-*] then {
641 # Make sure we put the right relocation entry on a BLE instruction.
642 do_ble_relocation_test
644 # Make sure relocation reductions are not too agressive about
645 # adjusting relocations against some symbols.
646 do_relocation_reduction_tests
648 # Check that mode selectors on a ble instruction actually work.
649 do_ble_mode_selector_test
651 # Check that we take the -8 adjustment into account when zeroing
652 # out the displacement field in a ble instruction with a reloc
653 do_ble_relocation_test
655 # 1.36 simply didn't generate all the plabels it should have. Make
657 do_plabel_relocation_test
659 # Make sure a field selector only effects the current instruction
660 # or assembler directive.
661 do_selector_scope_test
663 # This should really generate a relocation. It would make life much
664 # easier on the optimizing linker. Until then just make sure the
665 # difference is computed correctly.
666 do_local_label_as_operand_test
668 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
669 # were not in the source code.
670 do_exit_relocation_test
672 # GAS2 incorrectly thought it could apply a fixup for a pc-relative
673 # branch/call which crossed different subspaces.
674 # Also check that the assembled instruction is correct
675 do_cross_space_fixup_test_1
676 do_cross_space_fixup_test_2
678 # Make sure we switch rounding modes correctly
681 # Test for a bug found when a function was used in a non-branching
682 # instruction *without* a plabel (for portable runtime model)
683 do_function_reloc_bug
685 # Test for an off-by-one bug in the handling of 4-byte R_NO_RELOCATION
689 # Test a relocation problem which shows up when building shared
691 do_pic_relocation_test
693 # Test a problem with md_apply_fix that was introduced when fixing
694 # the pic relocation test.
697 # Make sure gas doesn't resolve long-calls which are to be fixed
699 gas_test "longcall.s" "" "" "Avoid resolving long-calls"