1 # Copyright
1993, 1996, 1997, 2002, 2004 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.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, 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
*64*-*-*]
31 ||
[istarget hppa
*-*-*elf
*] ||
[istarget hppa
*-*-linux
*]} then {
32 # At one time both versions of the assembler would incorrectly use
33 # a PC
-relative relocation
for a BLE instruction.
36 -re
"^0+\[^\n\]*DIR21L\[^\n\]*\n" { set x 1 }
37 -re
"^0+4\[^\n\]*DIR17R\[^\n\]*\n" { set x 1 }
39 timeout
{ perror
"timeout\n"; break }
44 # At one time both versions of the assembler would incorrectly use
45 # a PC
-relative relocation
for a BLE instruction.
48 -re
"^0+4\[^\n\]*ABS_CALL\[^\n\]*\n" { set x 1 }
50 timeout
{ perror
"timeout\n"; break }
57 # This was intended to
do any cleanup necessary. It kinda looks like it
58 # isn
't needed, but just in case, please keep it in for now.
61 # Did we find what we were looking for? If not, flunk it.
62 if [expr $x==1] then { pass $testname } else { fail $testname }
65 proc do_relocation_reduction_tests {} {
66 set testname "reduce.s: Test relocation reductions (part 2)"
69 if {[istarget hppa*64*-*-*]
70 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
74 if [gas_test_old "reduce.s" "" "Relocation reductions (part1)"] then {
75 objdump_start_no_subdir "a.out" "-r"
77 # Check to make sure relocations involving procedure labels
78 # are not reduced to a relocation involving some other symbol.
79 # Doing so makes generating parameter relocation stubs impossible.
82 -re "^0+4\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
84 -re "^0+14\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
87 timeout { perror "timeout\n"; break }
93 # This was intended to do any cleanup necessary. It kinda looks like it
94 # isn't needed
, but just in case
, please keep it in
for now.
97 # Did we find what we were looking
for?
If not
, flunk it.
98 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
100 set testname
"reduce2.s: More relocation reduction tests (part 2)"
103 if [gas_test_old
"reduce2.s" "" "More relocation reductions (part1)"] then {
104 objdump_start_no_subdir
"a.out" "-r"
106 # Check to make sure DLT relative relocs are not reduced to sym
+addend
107 # Doing so doesn
't work as one might expect
110 -re "^0+4\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
111 { set x [expr $x+1] }
112 -re "^0+1c\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
113 { set x [expr $x+1] }
114 -re "^0+30\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
115 { set x [expr $x+1] }
116 -re "^0+48\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
117 { set x [expr $x+1] }
119 timeout { perror "timeout\n"; break }
125 # This was intended to do any cleanup necessary. It kinda looks like it
126 # isn't needed
, but just in case
, please keep it in
for now.
129 # Did we find what we were looking
for?
If not
, flunk it.
130 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
132 set testname
"reduce3.s: Test even more relocation reductions (part 2)"
135 if [gas_test_old
"reduce3.s" "" "Even more relocation reductions (part1)"] then {
136 objdump_start_no_subdir
"a.out" "-r"
138 # Check to make sure relocations involving procedure labels
139 # are not reduced to a relocation involving some other symbol.
140 # Doing so makes generating parameter relocation stubs impossible.
143 -re
"^0+c\[^\n\]*yabba\[^\n\+\]*\n"
144 { set x
[expr $x
+1] }
145 -re
"^0+c\[^\n\]*yabba\+\[^\n\]*\n"
147 -re
"^0+10\[^\n\]*yabba\[^\n\+\]*\n"
148 { set x
[expr $x
+1] }
149 -re
"^0+10\[^\n\]*yabba\+\[^\n\]*\n"
152 timeout
{ perror
"timeout\n"; break }
158 # This was intended to
do any cleanup necessary. It kinda looks like it
159 # isn
't needed, but just in case, please keep it in for now.
162 # Did we find what we were looking for? If not, flunk it.
163 if [expr $x==2] then { pass $testname } else { fail $testname }
166 proc do_ble_mode_selector_test {} {
167 set testname "blebug2.s: blebug2"
170 gas_start "blebug2.s" "-al"
172 # GAS uses too many bits on the BLE instruction.
175 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
176 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
178 timeout { perror "timeout\n"; break }
183 # This was intended to do any cleanup necessary. It kinda looks like it
184 # isn't needed
, but just in case
, please keep it in
for now.
187 # Did we find what we were looking
for?
If not
, flunk it.
188 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
191 proc do_ble_relocation_test
{} {
192 set testname
"blebug3.s: blebug3"
195 gas_start
"blebug3.s" "-al"
199 -re
"^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n" { set x [expr $x+1] }
201 timeout
{ perror
"timeout\n"; break }
206 # This was intended to
do any cleanup necessary. It kinda looks like it
207 # isn
't needed, but just in case, please keep it in for now.
210 # Did we find what we were looking for? If not, flunk it.
211 if [expr $x==1] then { pass $testname } else { fail $testname }
214 proc do_plabel_relocation_test {} {
215 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
218 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
219 objdump_start_no_subdir "a.out" "-r"
221 # Check that we make PLABEL relocation entries when they're needed.
224 -re
"^0+\[^\n\]*PLABEL\[^\n\]*\n"
225 { set x
[expr $x
+1] }
226 -re
"^0+4\[^\n\]*PLABEL\[^\n\]*\n"
227 { set x
[expr $x
+1] }
229 timeout
{ perror
"timeout\n"; break }
234 # This was intended to
do any cleanup necessary. It kinda looks like it
235 # isn
't needed, but just in case, please keep it in for now.
238 # Did we find what we were looking for? If not, flunk it.
239 if [expr $x==2] then { pass $testname } else { fail $testname }
243 proc do_selector_scope_test {} {
244 set testname "selectorbug.s: Test scope of field selector"
247 if [istarget hppa*64*-*-*] then {
251 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
252 objdump_start_no_subdir "a.out" "-r"
254 # Check to make sure the relocation entry after the plabel is correct.
255 # If an old field selector was incorrectly "carried" over, then
256 # this test will fail.
257 if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
260 -re "^0+14\[^\n\]*DIR32\[^\n\]*\n"
262 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
265 timeout { perror "timeout\n"; break }
272 -re "^0+14\[^\n\]*DATA_ONE\[^\n\]*\n"
274 -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
277 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_local_label_as_operand_test
{} {
293 set testname
"labelopbug.s: Test local label as operand (non-branching)"
296 if [gas_test_old
"labelopbug.s" "" "Local label as operand (part 1)"] {
297 objdump_start_no_subdir
"a.out" "-r"
299 # Check to make sure we handle difference of local labels as an operand
300 # to a non
-branching instruction correctly.
On hppa elf targets
, the
301 # R_PARISC_DIR21 and R_PARISC_DIR14R relocations are done with LR and
302 # RR selectors
, respectively. As a result
, we can
't reduce these to
303 # section offsets without risking incorrect rounding. So, we just
304 # check to see if the label hasn't been reduced.
305 if {[istarget hppa
*64*-*-*]
306 ||
[istarget hppa
*-*-*elf
*] ||
[istarget hppa
*-*-linux
*]} then {
309 -re
"^0+2c\[^\n\]*L.0002\[^\n\]*\n"
310 { set x
[expr $x
+1] }
311 -re
"^0+30\[^\n\]*L.0002\[^\n\]*\n"
312 { set x
[expr $x
+1] }
314 timeout
{ perror
"timeout\n"; break }
321 -re
"^0+2c\[^\n\]*0x0+24\[^\n\]*\n"
322 { set x
[expr $x
+1] }
323 -re
"^0+30\[^\n\]*0x0+24\[^\n\]*\n"
324 { set x
[expr $x
+1] }
326 timeout
{ perror
"timeout\n"; break }
332 # This was intended to
do any cleanup necessary. It kinda looks like it
333 # isn
't needed, but just in case, please keep it in for now.
336 # Did we find what we were looking for? If not, flunk it.
337 if [expr $x==2] then { pass $testname } else { fail $testname }
341 proc do_exit_relocation_test {} {
342 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
345 # Elf (osf) does not use ENTRY/EXIT relocations.
346 # I guess we could look at the unwind subspaces it builds...
347 # Until then, make sure it still assembles.
348 if {[istarget hppa*64*-*-*]
349 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
350 gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
354 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
355 objdump_start_no_subdir "a.out" "-r"
357 # Note that a match here is really a FAILURE!
360 -re "^0+\[^\n\]*R_EXIT\[^\n\]*\n"
361 { set x [expr $x+1] }
363 timeout { perror "timeout\n"; break }
368 # This was intended to do any cleanup necessary. It kinda looks like it
369 # isn't needed
, but just in case
, please keep it in
for now.
372 # Did we find what we were looking
for?
If not
, flunk it.
373 if [expr $x
==0] then { pass $testname
} else { fail $testname
}
377 proc do_cross_space_fixup_test_1
{} {
378 set testname
"fixupbug.s: Test cross space jump/call fixup bug (part 2)"
381 # ELF doesn
't really handle extra sections too well...
382 if {[istarget hppa*64*-*-*]
383 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
387 if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
388 objdump_start_no_subdir "a.out" "-r"
390 # Make sure GAS generated a fixup/relocation for the cross-space
394 -re "^0+\[^\n\]*PCREL_CALL\[^\n\]*\n"
395 { set x [expr $x+1] }
397 timeout { perror "timeout\n"; break }
402 # This was intended to do any cleanup necessary. It kinda looks like it
403 # isn't needed
, but just in case
, please keep it in
for now.
406 # Did we find what we were looking
for?
If not
, flunk it.
407 if [expr $x
==1] then { pass $testname
} else { fail $testname
}
411 proc do_cross_space_fixup_test_2
{} {
412 set testname
"fixupbug.s: Test cross space jump/call fixup bug (part 3)"
415 # ELF doesn
't really handle extra sections too well...
416 if {[istarget hppa*64*-*-*]
417 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
421 gas_start "fixupbug.s" "-al"
425 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
427 timeout { perror "timeout\n"; break }
432 # This was intended to do any cleanup necessary. It kinda looks like it
433 # isn't needed
, but just in case
, please keep it in
for now.
436 # Did we find what we were looking
for?
If not
, flunk it.
437 if [expr $x
==1] then { pass $testname
} else { fail $testname
}
440 proc do_round_mode_test
{} {
441 set testname
"roundmode.s: Test switching of rounding modes (part 2)"
444 if [gas_test_old
"roundmode.s" "" "Test switch of rounding modes(part 1)"] {
445 objdump_start_no_subdir
"a.out" "-r"
447 # Make sure GAS generated correct relocations to
switch rounding modes.
448 # Also make sure
(for SOM
) that redundant rounding
mode relocations
450 if {[istarget hppa
*64*-*-*]
451 ||
[istarget hppa
*-*-*elf
*] ||
[istarget hppa
*-*-linux
*]} then {
454 -re
"^0+\[^\n\]*DIR21L\[^\n\]*\n"
455 { set x
[expr $x
+1] }
456 -re
"^0+4\[^\n\]*DIR14R\[^\n\]*\n"
457 { set x
[expr $x
+1] }
458 -re
"^0+8\[^\n\]*DIR21L\[^\n\]*\n"
459 { set x
[expr $x
+1] }
460 -re
"^0+c\[^\n\]*DIR14R\[^\n\]*\n"
461 { set x
[expr $x
+1] }
462 -re
"^0+10\[^\n\]*DIR21L\[^\n\]*\n"
463 { set x
[expr $x
+1] }
464 -re
"^0+14\[^\n\]*DIR14R\[^\n\]*\n"
465 { set x
[expr $x
+1] }
466 -re
"^0+18\[^\n\]*DIR21L\[^\n\]*\n"
467 { set x
[expr $x
+1] }
468 -re
"^0+1c\[^\n\]*DIR14R\[^\n\]*\n"
469 { set x
[expr $x
+1] }
471 timeout
{ perror
"timeout\n"; break }
478 -re
"^0+\[^\n\]*R_R_MODE\[^\n\]*\n"
479 { set x
[expr $x
+1] }
480 -re
"^0+4\[^\n\]*R_R_MODE\[^\n\]*\n"
482 -re
"^0+8\[^\n\]*R_N_MODE\[^\n\]*\n"
483 { set x
[expr $x
+1] }
484 -re
"^0+c\[^\n\]*R_N_MODE\[^\n\]*\n"
486 -re
"^0+10\[^\n\]*R_R_MODE\[^\n\]*\n"
487 { set x
[expr $x
+1] }
488 -re
"^0+14\[^\n\]*R_R_MODE\[^\n\]*\n"
490 -re
"^0+1c\[^\n\]*R_R_MODE\[^\n\]*\n"
493 timeout
{ perror
"timeout\n"; break }
499 # This was intended to
do any cleanup necessary. It kinda looks like it
500 # isn
't needed, but just in case, please keep it in for now.
503 # Did we find what we were looking for? If not, flunk it.
504 if {[istarget hppa*64*-*-*]
505 || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
506 if [expr $x==8] then { pass $testname } else { fail $testname }
508 if [expr $x==3] then { pass $testname } else { fail $testname }
513 proc do_function_reloc_bug {} {
514 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
517 if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
518 objdump_start_no_subdir "a.out" "-r"
520 # Make sure GAS generated a correct relocation for the reference.
524 -re "^0+cc\[^\n\]*f2___4\[^\n+\]*\n"
525 { set x [expr $x+1] }
526 -re "^0+d0\[^\n\]*f2___4\[^\n+\]*\n"
527 { set x [expr $x+1] }
529 timeout { perror "timeout\n"; break }
534 # This was intended to do any cleanup necessary. It kinda looks like it
535 # isn't needed
, but just in case
, please keep it in
for now.
538 # Did we find what we were looking
for?
If not
, flunk it.
539 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
541 set testname
"funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
544 objdump_start_no_subdir
"a.out" "--prefix-addresses -d"
545 # Make sure we didn
't put anything in the instruction itself!
548 -re "^0+cc\[^\n\]*ldil L%0,r20\[^\n\]*\n"
549 { set x [expr $x+1] }
550 -re "^0+d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n"
551 { set x [expr $x+1] }
553 timeout { perror "timeout\n"; break }
558 # This was intended to do any cleanup necessary. It kinda looks like it
559 # isn't needed
, but just in case
, please keep it in
for now.
562 # Did we find what we were looking
for?
If not
, flunk it.
563 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
568 proc do_r_no_reloc
{} {
569 set testname
"r_no_reloc.s: Test for reloc bug in 4-byte R_NO_RELCOATION fixups (part 2)"
572 if [gas_test_old
"r_no_reloc.s" "" "Test for reloc bug in 4-byte R_NO_RELOCATION fixups (part 1)"] {
573 objdump_start_no_subdir
"a.out" "-r"
575 # Make sure GAS generated a correct relocation
for the reference.
578 -re
"^0+c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n"
579 { set x
[expr $x
+1] }
581 timeout
{ perror
"timeout\n"; break }
586 # This was intended to
do any cleanup necessary. It kinda looks like it
587 # isn
't needed, but just in case, please keep it in for now.
590 # Did we find what we were looking for? If not, flunk it.
591 if [expr $x==1] then { pass $testname } else { fail $testname }
596 proc do_pic_relocation_test {} {
597 set testname "picreloc.s: Test for proper PIC relocation (part 2)"
600 # ELF doesn't really handle extra sections too well...
601 if {[istarget hppa
*64*-*-*]
602 ||
[istarget hppa
*-*-*elf
*] ||
[istarget hppa
*-*-linux
*]} then {
606 gas_start
"picreloc.s" "-al"
610 -re
"^ +\[0-9\]+ 0000 00000004\[^\n\]*\n" { set x [expr $x+1] }
612 timeout
{ perror
"timeout\n"; break }
617 # This was intended to
do any cleanup necessary. It kinda looks like it
618 # isn
't needed, but just in case, please keep it in for now.
621 # Did we find what we were looking for? If not, flunk it.
622 if [expr $x==1] then { pass $testname } else { fail $testname }
625 proc do_apply_test {} {
626 set testname "applybug.s: Test for proper fixup application (part 2)"
629 # ELF doesn't really handle extra sections too well...
630 if {[istarget hppa
*64*-*-*]
631 ||
[istarget hppa
*-*-*elf
*] ||
[istarget hppa
*-*-linux
*]} then {
635 gas_start
"applybug.s" "-al"
639 -re
"^ +\[0-9\]+ 0000 00000000\[^\n\]*\n" { set x [expr $x+1] }
640 -re
"^ +\[0-9\]+ 0004 00000000\[^\n\]*\n" { set x [expr $x+1] }
641 -re
"^ +\[0-9\]+ 0008 00000000\[^\n\]*\n" { set x [expr $x+1] }
643 timeout
{ perror
"timeout\n"; break }
648 # This was intended to
do any cleanup necessary. It kinda looks like it
649 # isn
't needed, but just in case, please keep it in for now.
652 # Did we find what we were looking for? If not, flunk it.
653 if [expr $x==3] then { pass $testname } else { fail $testname }
656 if [istarget hppa*-*-*] then {
657 # Make sure we put the right relocation entry on a BLE instruction.
658 do_ble_relocation_test
660 # Make sure relocation reductions are not too agressive about
661 # adjusting relocations against some symbols.
662 do_relocation_reduction_tests
664 # Check that mode selectors on a ble instruction actually work.
665 do_ble_mode_selector_test
667 # Check that we take the -8 adjustment into account when zeroing
668 # out the displacement field in a ble instruction with a reloc
669 do_ble_relocation_test
671 # 1.36 simply didn't generate all the plabels it should have. Make
673 do_plabel_relocation_test
675 # Make sure a field selector only effects the current instruction
676 # or assembler directive.
677 do_selector_scope_test
679 # This should really generate a relocation. It would make life much
680 # easier
on the optimizing linker. Until
then just make sure the
681 # difference is computed correctly.
682 do_local_label_as_operand_test
684 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
685 # were not in the source code.
686 do_exit_relocation_test
688 # GAS2 incorrectly thought it could apply a fixup
for a pc
-relative
689 # branch
/call which crossed different subspaces.
690 # Also check that the assembled instruction is correct
691 do_cross_space_fixup_test_1
692 do_cross_space_fixup_test_2
694 # Make sure we
switch rounding modes correctly
697 # Test
for a bug found when a function was used in a non
-branching
698 # instruction
*without
* a plabel
(for portable runtime
model)
699 do_function_reloc_bug
701 # Test
for an
off-by
-one bug in the handling of
4-byte R_NO_RELOCATION
705 # Test a relocation problem which shows up when building shared
707 do_pic_relocation_test
709 # Test a problem with md_apply_fix that was introduced when fixing
710 # the pic relocation test.
713 # Make sure gas doesn
't resolve long-calls which are to be fixed
715 gas_test "longcall.s" "" "" "Avoid resolving long-calls"