1 # Copyright 1993, 1996, 1997, 2002, 2004, 2005, 2007
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
21 # Written by the Center for Software Science at the University of Utah
22 # and by Cygnus Support.
24 proc do_ble_relocation_test {} {
25 set testname "blebug.s: Test for proper relocation for BLE (part 2)"
28 if [gas_test_old "blebug.s" "" "Proper relocation for BLE (part 1)"] then {
29 objdump_start_no_subdir "a.out" "-r"
31 if {[istarget hppa*64*-*-*]
32 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
33 # At one time both versions of the assembler would incorrectly use
34 # a PC-relative relocation for a BLE instruction.
37 -re "^0+\[^\n\]*DIR21L\[^\n\]*\n" { set x 1 }
38 -re "^0+4\[^\n\]*DIR17R\[^\n\]*\n" { set x 1 }
40 timeout { perror "timeout\n"; break }
45 # At one time both versions of the assembler would incorrectly use
46 # a PC-relative relocation for a BLE instruction.
49 -re "^0+4\[^\n\]*ABS_CALL\[^\n\]*\n" { set x 1 }
51 timeout { perror "timeout\n"; break }
58 # This was intended to do any cleanup necessary. It kinda looks like it
59 # isn't needed, but just in case, please keep it in for now.
62 # Did we find what we were looking for? If not, flunk it.
63 if [expr $x==1] then { pass $testname } else { fail $testname }
66 proc do_relocation_reduction_tests {} {
67 set testname "reduce.s: Test relocation reductions (part 2)"
70 if {[istarget hppa*64*-*-*]
71 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
75 if [gas_test_old "reduce.s" "" "Relocation reductions (part1)"] then {
76 objdump_start_no_subdir "a.out" "-r"
78 # Check to make sure relocations involving procedure labels
79 # are not reduced to a relocation involving some other symbol.
80 # Doing so makes generating parameter relocation stubs impossible.
83 -re "^0+4\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
85 -re "^0+14\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
88 timeout { perror "timeout\n"; break }
94 # This was intended to do any cleanup necessary. It kinda looks like it
95 # isn't needed, but just in case, please keep it in for now.
98 # Did we find what we were looking for? If not, flunk it.
99 if [expr $x==2] then { pass $testname } else { fail $testname }
101 set testname "reduce2.s: More relocation reduction tests (part 2)"
104 if [gas_test_old "reduce2.s" "" "More relocation reductions (part1)"] then {
105 objdump_start_no_subdir "a.out" "-r"
107 # Check to make sure DLT relative relocs are not reduced to sym+addend
108 # Doing so doesn't work as one might expect
111 -re "^0+4\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
112 { set x [expr $x+1] }
113 -re "^0+1c\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
114 { set x [expr $x+1] }
115 -re "^0+30\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
116 { set x [expr $x+1] }
117 -re "^0+48\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
118 { set x [expr $x+1] }
120 timeout { perror "timeout\n"; break }
126 # This was intended to do any cleanup necessary. It kinda looks like it
127 # isn't needed, but just in case, please keep it in for now.
130 # Did we find what we were looking for? If not, flunk it.
131 if [expr $x==2] then { pass $testname } else { fail $testname }
133 set testname "reduce3.s: Test even more relocation reductions (part 2)"
136 if [gas_test_old "reduce3.s" "" "Even more relocation reductions (part1)"] then {
137 objdump_start_no_subdir "a.out" "-r"
139 # Check to make sure relocations involving procedure labels
140 # are not reduced to a relocation involving some other symbol.
141 # Doing so makes generating parameter relocation stubs impossible.
144 -re "^0+c\[^\n\]*yabba\[^\n\+\]*\n"
145 { set x [expr $x+1] }
146 -re "^0+c\[^\n\]*yabba\+\[^\n\]*\n"
148 -re "^0+10\[^\n\]*yabba\[^\n\+\]*\n"
149 { set x [expr $x+1] }
150 -re "^0+10\[^\n\]*yabba\+\[^\n\]*\n"
153 timeout { perror "timeout\n"; break }
159 # This was intended to do any cleanup necessary. It kinda looks like it
160 # isn't needed, but just in case, please keep it in for now.
163 # Did we find what we were looking for? If not, flunk it.
164 if [expr $x==2] then { pass $testname } else { fail $testname }
167 proc do_ble_mode_selector_test {} {
168 set testname "blebug2.s: blebug2"
171 gas_start "blebug2.s" "-al"
173 # GAS uses too many bits on the BLE instruction.
176 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
177 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
179 timeout { perror "timeout\n"; break }
184 # This was intended to do any cleanup necessary. It kinda looks like it
185 # isn't needed, but just in case, please keep it in for now.
188 # Did we find what we were looking for? If not, flunk it.
189 if [expr $x==2] then { pass $testname } else { fail $testname }
192 proc do_ble_relocation_test {} {
193 set testname "blebug3.s: blebug3"
196 gas_start "blebug3.s" "-al"
200 -re "^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n" { set x [expr $x+1] }
202 timeout { perror "timeout\n"; break }
207 # This was intended to do any cleanup necessary. It kinda looks like it
208 # isn't needed, but just in case, please keep it in for now.
211 # Did we find what we were looking for? If not, flunk it.
212 if [expr $x==1] then { pass $testname } else { fail $testname }
215 proc do_plabel_relocation_test {} {
216 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
219 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
220 objdump_start_no_subdir "a.out" "-r"
222 # Check that we make PLABEL relocation entries when they're needed.
225 -re "^0+\[^\n\]*PLABEL\[^\n\]*\n"
226 { set x [expr $x+1] }
227 -re "^0+4\[^\n\]*PLABEL\[^\n\]*\n"
228 { set x [expr $x+1] }
230 timeout { perror "timeout\n"; break }
235 # This was intended to do any cleanup necessary. It kinda looks like it
236 # isn't needed, but just in case, please keep it in for now.
239 # Did we find what we were looking for? If not, flunk it.
240 if [expr $x==2] then { pass $testname } else { fail $testname }
244 proc do_selector_scope_test {} {
245 set testname "selectorbug.s: Test scope of field selector"
248 if [istarget hppa*64*-*-*] then {
252 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
253 objdump_start_no_subdir "a.out" "-r"
255 # Check to make sure the relocation entry after the plabel is correct.
256 # If an old field selector was incorrectly "carried" over, then
257 # this test will fail.
258 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
261 -re "^0+14\[^\n\]*DIR32\[^\n\]*\n"
263 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
266 timeout { perror "timeout\n"; break }
273 -re "^0+14\[^\n\]*DATA_ONE\[^\n\]*\n"
275 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
278 timeout { perror "timeout\n"; break }
284 # This was intended to do any cleanup necessary. It kinda looks like it
285 # isn't needed, but just in case, please keep it in for now.
288 # Did we find what we were looking for? If not, flunk it.
289 if [expr $x==1] then { pass $testname } else { fail $testname }
293 proc do_local_label_as_operand_test {} {
294 set testname "labelopbug.s: Test local label as operand (non-branching)"
297 if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
298 objdump_start_no_subdir "a.out" "-r"
300 # Check to make sure we handle difference of local labels as an operand
301 # to a non-branching instruction correctly. On hppa elf targets, the
302 # R_PARISC_DIR21 and R_PARISC_DIR14R relocations are done with LR and
303 # RR selectors, respectively. As a result, we can't reduce these to
304 # section offsets without risking incorrect rounding. So, we just
305 # check to see if the label hasn't been reduced.
306 if {[istarget hppa*64*-*-*]
307 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
310 -re "^0+2c\[^\n\]*L.0002\[^\n\]*\n"
311 { set x [expr $x+1] }
312 -re "^0+30\[^\n\]*L.0002\[^\n\]*\n"
313 { set x [expr $x+1] }
315 timeout { perror "timeout\n"; break }
322 -re "^0+2c\[^\n\]*0x0+24\[^\n\]*\n"
323 { set x [expr $x+1] }
324 -re "^0+30\[^\n\]*0x0+24\[^\n\]*\n"
325 { set x [expr $x+1] }
327 timeout { perror "timeout\n"; break }
333 # This was intended to do any cleanup necessary. It kinda looks like it
334 # isn't needed, but just in case, please keep it in for now.
337 # Did we find what we were looking for? If not, flunk it.
338 if [expr $x==2] then { pass $testname } else { fail $testname }
342 proc do_exit_relocation_test {} {
343 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
346 # Elf (osf) does not use ENTRY/EXIT relocations.
347 # I guess we could look at the unwind subspaces it builds...
348 # Until then, make sure it still assembles.
349 if {[istarget hppa*64*-*-*]
350 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
351 gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
355 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
356 objdump_start_no_subdir "a.out" "-r"
358 # Note that a match here is really a FAILURE!
361 -re "^0+\[^\n\]*R_EXIT\[^\n\]*\n"
362 { set x [expr $x+1] }
364 timeout { perror "timeout\n"; break }
369 # This was intended to do any cleanup necessary. It kinda looks like it
370 # isn't needed, but just in case, please keep it in for now.
373 # Did we find what we were looking for? If not, flunk it.
374 if [expr $x==0] then { pass $testname } else { fail $testname }
378 proc do_cross_space_fixup_test_1 {} {
379 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 2)"
382 # ELF doesn't really handle extra sections too well...
383 if {[istarget hppa*64*-*-*]
384 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
388 if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
389 objdump_start_no_subdir "a.out" "-r"
391 # Make sure GAS generated a fixup/relocation for the cross-space
395 -re "^0+\[^\n\]*PCREL_CALL\[^\n\]*\n"
396 { set x [expr $x+1] }
398 timeout { perror "timeout\n"; break }
403 # This was intended to do any cleanup necessary. It kinda looks like it
404 # isn't needed, but just in case, please keep it in for now.
407 # Did we find what we were looking for? If not, flunk it.
408 if [expr $x==1] then { pass $testname } else { fail $testname }
412 proc do_cross_space_fixup_test_2 {} {
413 set testname "fixupbug.s: Test cross space jump/call fixup bug (part 3)"
416 # ELF doesn't really handle extra sections too well...
417 if {[istarget hppa*64*-*-*]
418 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
422 gas_start "fixupbug.s" "-al"
426 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
428 timeout { perror "timeout\n"; break }
433 # This was intended to do any cleanup necessary. It kinda looks like it
434 # isn't needed, but just in case, please keep it in for now.
437 # Did we find what we were looking for? If not, flunk it.
438 if [expr $x==1] then { pass $testname } else { fail $testname }
441 proc do_round_mode_test {} {
442 set testname "roundmode.s: Test switching of rounding modes (part 2)"
445 if [gas_test_old "roundmode.s" "" "Test switch of rounding modes(part 1)"] {
446 objdump_start_no_subdir "a.out" "-r"
448 # Make sure GAS generated correct relocations to switch rounding modes.
449 # Also make sure (for SOM) that redundant rounding mode relocations
451 if {[istarget hppa*64*-*-*]
452 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
455 -re "^0+\[^\n\]*DIR21L\[^\n\]*\n"
456 { set x [expr $x+1] }
457 -re "^0+4\[^\n\]*DIR14R\[^\n\]*\n"
458 { set x [expr $x+1] }
459 -re "^0+8\[^\n\]*DIR21L\[^\n\]*\n"
460 { set x [expr $x+1] }
461 -re "^0+c\[^\n\]*DIR14R\[^\n\]*\n"
462 { set x [expr $x+1] }
463 -re "^0+10\[^\n\]*DIR21L\[^\n\]*\n"
464 { set x [expr $x+1] }
465 -re "^0+14\[^\n\]*DIR14R\[^\n\]*\n"
466 { set x [expr $x+1] }
467 -re "^0+18\[^\n\]*DIR21L\[^\n\]*\n"
468 { set x [expr $x+1] }
469 -re "^0+1c\[^\n\]*DIR14R\[^\n\]*\n"
470 { set x [expr $x+1] }
472 timeout { perror "timeout\n"; break }
479 -re "^0+\[^\n\]*R_R_MODE\[^\n\]*\n"
480 { set x [expr $x+1] }
481 -re "^0+4\[^\n\]*R_R_MODE\[^\n\]*\n"
483 -re "^0+8\[^\n\]*R_N_MODE\[^\n\]*\n"
484 { set x [expr $x+1] }
485 -re "^0+c\[^\n\]*R_N_MODE\[^\n\]*\n"
487 -re "^0+10\[^\n\]*R_R_MODE\[^\n\]*\n"
488 { set x [expr $x+1] }
489 -re "^0+14\[^\n\]*R_R_MODE\[^\n\]*\n"
491 -re "^0+1c\[^\n\]*R_R_MODE\[^\n\]*\n"
494 timeout { perror "timeout\n"; break }
500 # This was intended to do any cleanup necessary. It kinda looks like it
501 # isn't needed, but just in case, please keep it in for now.
504 # Did we find what we were looking for? If not, flunk it.
505 if {[istarget hppa*64*-*-*]
506 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
507 if [expr $x==8] then { pass $testname } else { fail $testname }
509 if [expr $x==3] then { pass $testname } else { fail $testname }
514 proc do_function_reloc_bug {} {
515 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
518 if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
519 objdump_start_no_subdir "a.out" "-r"
521 # Make sure GAS generated a correct relocation for the reference.
525 -re "^0+cc\[^\n\]*f2___4\[^\n+\]*\n"
526 { set x [expr $x+1] }
527 -re "^0+d0\[^\n\]*f2___4\[^\n+\]*\n"
528 { set x [expr $x+1] }
530 timeout { perror "timeout\n"; break }
535 # This was intended to do any cleanup necessary. It kinda looks like it
536 # isn't needed, but just in case, please keep it in for now.
539 # Did we find what we were looking for? If not, flunk it.
540 if [expr $x==2] then { pass $testname } else { fail $testname }
542 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
545 objdump_start_no_subdir "a.out" "--prefix-addresses -d"
546 # Make sure we didn't put anything in the instruction itself!
549 -re "^0+cc\[^\n\]*ldil L%0,r20\[^\n\]*\n"
550 { set x [expr $x+1] }
551 -re "^0+d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n"
552 { set x [expr $x+1] }
554 timeout { perror "timeout\n"; break }
559 # This was intended to do any cleanup necessary. It kinda looks like it
560 # isn't needed, but just in case, please keep it in for now.
563 # Did we find what we were looking for? If not, flunk it.
564 if [expr $x==2] then { pass $testname } else { fail $testname }
569 proc do_r_no_reloc {} {
570 set testname "r_no_reloc.s: Test for reloc bug in 4-byte R_NO_RELCOATION fixups (part 2)"
573 if [gas_test_old "r_no_reloc.s" "" "Test for reloc bug in 4-byte R_NO_RELOCATION fixups (part 1)"] {
574 objdump_start_no_subdir "a.out" "-r"
576 # Make sure GAS generated a correct relocation for the reference.
579 -re "^0+c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n"
580 { set x [expr $x+1] }
582 timeout { perror "timeout\n"; break }
587 # This was intended to do any cleanup necessary. It kinda looks like it
588 # isn't needed, but just in case, please keep it in for now.
591 # Did we find what we were looking for? If not, flunk it.
592 if [expr $x==1] then { pass $testname } else { fail $testname }
597 proc do_pic_relocation_test {} {
598 set testname "picreloc.s: Test for proper PIC relocation (part 2)"
601 # ELF doesn't really handle extra sections too well...
602 if {[istarget hppa*64*-*-*]
603 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
607 gas_start "picreloc.s" "-al"
611 -re "^ +\[0-9\]+ 0000 00000004\[^\n\]*\n" { set x [expr $x+1] }
613 timeout { perror "timeout\n"; break }
618 # This was intended to do any cleanup necessary. It kinda looks like it
619 # isn't needed, but just in case, please keep it in for now.
622 # Did we find what we were looking for? If not, flunk it.
623 if [expr $x==1] then { pass $testname } else { fail $testname }
626 proc do_apply_test {} {
627 set testname "applybug.s: Test for proper fixup application (part 2)"
630 # ELF doesn't really handle extra sections too well...
631 if {[istarget hppa*64*-*-*]
632 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
636 gas_start "applybug.s" "-al"
640 -re "^ +\[0-9\]+ 0000 00000044\[^\n\]*\n" { set x [expr $x+1] }
641 -re "^ +\[0-9\]+ 0004 00000058\[^\n\]*\n" { set x [expr $x+1] }
642 -re "^ +\[0-9\]+ 0008 0000006C\[^\n\]*\n" { set x [expr $x+1] }
644 timeout { perror "timeout\n"; break }
649 # This was intended to do any cleanup necessary. It kinda looks like it
650 # isn't needed, but just in case, please keep it in for now.
653 # Did we find what we were looking for? If not, flunk it.
654 if [expr $x==3] then { pass $testname } else { fail $testname }
657 if [istarget hppa*-*-*] then {
658 # Make sure we put the right relocation entry on a BLE instruction.
659 do_ble_relocation_test
661 # Make sure relocation reductions are not too agressive about
662 # adjusting relocations against some symbols.
663 do_relocation_reduction_tests
665 # Check that mode selectors on a ble instruction actually work.
666 do_ble_mode_selector_test
668 # Check that we take the -8 adjustment into account when zeroing
669 # out the displacement field in a ble instruction with a reloc
670 do_ble_relocation_test
672 # 1.36 simply didn't generate all the plabels it should have. Make
674 do_plabel_relocation_test
676 # Make sure a field selector only effects the current instruction
677 # or assembler directive.
678 do_selector_scope_test
680 # This should really generate a relocation. It would make life much
681 # easier on the optimizing linker. Until then just make sure the
682 # difference is computed correctly.
683 do_local_label_as_operand_test
685 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
686 # were not in the source code.
687 do_exit_relocation_test
689 # GAS2 incorrectly thought it could apply a fixup for a pc-relative
690 # branch/call which crossed different subspaces.
691 # Also check that the assembled instruction is correct
692 do_cross_space_fixup_test_1
693 do_cross_space_fixup_test_2
695 # Make sure we switch rounding modes correctly
698 # Test for a bug found when a function was used in a non-branching
699 # instruction *without* a plabel (for portable runtime model)
700 do_function_reloc_bug
702 # Test for an off-by-one bug in the handling of 4-byte R_NO_RELOCATION
706 # Test a relocation problem which shows up when building shared
708 do_pic_relocation_test
710 # Test a problem with md_apply_fix that was introduced when fixing
711 # the pic relocation test.
714 # Make sure gas doesn't resolve long-calls which are to be fixed
716 gas_test "longcall.s" "" "" "Avoid resolving long-calls"