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
"^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 "reduce.s: Test relocation reductions (part 2)"
68 if [gas_test_old "reduce.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
}
94 set testname
"reduce2.s: More relocation reduction tests (part 2)"
97 if [gas_test_old
"reduce2.s" "" "More relocatoin reductions (part1)"] then {
98 objdump_start_no_subdir
"a.out" "-r"
100 # Check to make sure DLT relative relocs are not reduced to sym
+addend
101 # Doing so doesn
't work as one might expect
104 -re "^00000004\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
105 { set x [expr $x+1] }
106 -re "^0000001c\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
107 { set x [expr $x+1] }
108 -re "^00000030\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
109 { set x [expr $x+1] }
110 -re "^00000048\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
111 { set x [expr $x+1] }
113 timeout { perror "timeout\n"; break }
119 # This was intended to do any cleanup necessary. It kinda looks like it
120 # isn't needed
, but just in case
, please keep it in
for now.
123 # Did we find what we were looking
for?
If not
, flunk it.
124 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
126 set testname
"reduce3.s: Test even more relocation reductions (part 2)"
129 if [gas_test_old
"reduce3.s" "" "Even more relocation reductions (part1)"] then {
130 objdump_start_no_subdir
"a.out" "-r"
132 # Check to make sure relocations involving procedure labels
133 # are not reduced to a relocation involving some other symbol.
134 # Doing so makes generating parameter relocation stubs impossible.
137 -re
"^0000000c\[^\n\]*yabba\[^\n\+\]*\n"
138 { set x
[expr $x
+1] }
139 -re
"^0000000c\[^\n\]*yabba\+\[^\n\]*\n"
141 -re
"^00000010\[^\n\]*yabba\[^\n\+\]*\n"
142 { set x
[expr $x
+1] }
143 -re
"^00000010\[^\n\]*yabba\+\[^\n\]*\n"
146 timeout
{ perror
"timeout\n"; break }
152 # This was intended to
do any cleanup necessary. It kinda looks like it
153 # isn
't needed, but just in case, please keep it in for now.
156 # Did we find what we were looking for? If not, flunk it.
157 if [expr $x==2] then { pass $testname } else { fail $testname }
160 proc do_ble_mode_selector_test {} {
161 set testname "blebug2.s: blebug2"
164 gas_start "blebug2.s" "-al"
166 # GAS uses too many bits on the BLE instruction.
169 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
170 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
172 timeout { perror "timeout\n"; break }
177 # This was intended to do any cleanup necessary. It kinda looks like it
178 # isn't needed
, but just in case
, please keep it in
for now.
181 # Did we find what we were looking
for?
If not
, flunk it.
182 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
185 proc do_ble_relocation_test
{} {
186 set testname
"blebug3.s: blebug3"
189 gas_start
"blebug3.s" "-al"
193 -re
"^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n" { set x [expr $x+1] }
195 timeout
{ perror
"timeout\n"; break }
200 # This was intended to
do any cleanup necessary. It kinda looks like it
201 # isn
't needed, but just in case, please keep it in for now.
204 # Did we find what we were looking for? If not, flunk it.
205 if [expr $x==1] then { pass $testname } else { fail $testname }
208 proc do_plabel_relocation_test {} {
209 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
212 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
213 objdump_start_no_subdir "a.out" "-r"
215 # Check that we make PLABEL relocation entries when they're needed.
218 -re
"^00000000\[^\n\]*PLABEL\[^\n\]*\n"
219 { set x
[expr $x
+1] }
220 -re
"^00000004\[^\n\]*PLABEL\[^\n\]*\n"
221 { set x
[expr $x
+1] }
223 timeout
{ perror
"timeout\n"; break }
228 # This was intended to
do any cleanup necessary. It kinda looks like it
229 # isn
't needed, but just in case, please keep it in for now.
232 # Did we find what we were looking for? If not, flunk it.
233 if [expr $x==2] then { pass $testname } else { fail $testname }
237 proc do_selector_scope_test {} {
238 set testname "selectorbug.s: Test scope of field selector"
241 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
242 objdump_start_no_subdir "a.out" "-r"
244 # Check to make sure the relocation entry after the plabel is correct.
245 # If an old field selector was incorrectly "carried" over, then
246 # this test will fail.
247 if [istarget hppa*-*-*elf*] then {
250 -re "^00000014\[^\n\]*DIR32\[^\n\]*\n"
252 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
255 timeout { perror "timeout\n"; break }
262 -re "^00000014\[^\n\]*DATA_ONE\[^\n\]*\n"
264 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
267 timeout { perror "timeout\n"; break }
273 # This was intended to do any cleanup necessary. It kinda looks like it
274 # isn't needed
, but just in case
, please keep it in
for now.
277 # Did we find what we were looking
for?
If not
, flunk it.
278 if [expr $x
==1] then { pass $testname
} else { fail $testname
}
282 proc do_local_label_as_operand_test
{} {
283 set testname
"labelopbug.s: Test local label as operand (non-branching)"
286 if [gas_test_old
"labelopbug.s" "" "Local label as operand (part 1)"] {
287 objdump_start_no_subdir
"a.out" "-r"
289 # Check to make sure we handle difference of local lables as an operand
290 # to a non
-branching instruction correctly.
293 -re
"^0000002c\[^\n\]*0x00000024\[^\n\]*\n"
294 { set x
[expr $x
+1] }
295 -re
"^00000030\[^\n\]*0x00000024\[^\n\]*\n"
296 { set x
[expr $x
+1] }
298 timeout
{ perror
"timeout\n"; break }
303 # This was intended to
do any cleanup necessary. It kinda looks like it
304 # isn
't needed, but just in case, please keep it in for now.
307 # Did we find what we were looking for? If not, flunk it.
308 if [expr $x==2] then { pass $testname } else { fail $testname }
312 proc do_exit_relocation_test {} {
313 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
316 # Elf (osf) does not use ENTRY/EXIT relocations.
317 # I guess we could look at the unwind subspaces it builds...
318 # Until then, make sure it still assembles.
319 if [istarget hppa*-*-*elf*] then {
320 gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
324 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
325 objdump_start_no_subdir "a.out" "-r"
327 # Note that a match here is really a FAILURE!
330 -re "^00000000\[^\n\]*R_EXIT\[^\n\]*\n"
331 { set x [expr $x+1] }
333 timeout { perror "timeout\n"; break }
338 # This was intended to do any cleanup necessary. It kinda looks like it
339 # isn't needed
, but just in case
, please keep it in
for now.
342 # Did we find what we were looking
for?
If not
, flunk it.
343 if [expr $x
==0] then { pass $testname
} else { fail $testname
}
347 proc do_cross_space_fixup_test_1
{} {
348 set testname
"fixupbug.s: Test cross space jump/call fixup bug (part 2)"
351 # ELF
(osf
) doesn
't really handle extra sections too well...
352 if [istarget hppa*-*-*elf*] then {
356 if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
357 objdump_start_no_subdir "a.out" "-r"
359 # Make sure GAS generated a fixup/relocation for the cross-space
363 -re "^00000000\[^\n\]*PCREL_CALL\[^\n\]*\n"
364 { set x [expr $x+1] }
366 timeout { perror "timeout\n"; break }
371 # This was intended to do any cleanup necessary. It kinda looks like it
372 # isn't needed
, but just in case
, please keep it in
for now.
375 # Did we find what we were looking
for?
If not
, flunk it.
376 if [expr $x
==1] then { pass $testname
} else { fail $testname
}
380 proc do_cross_space_fixup_test_2
{} {
381 set testname
"fixupbug.s: Test cross space jump/call fixup bug (part 3)"
384 # ELF
(osf
) doesn
't really handle extra sections too well...
385 if [istarget hppa*-*-*elf*] then {
389 gas_start "fixupbug.s" "-al"
393 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
395 timeout { perror "timeout\n"; break }
400 # This was intended to do any cleanup necessary. It kinda looks like it
401 # isn't needed
, but just in case
, please keep it in
for now.
404 # Did we find what we were looking
for?
If not
, flunk it.
405 if [expr $x
==1] then { pass $testname
} else { fail $testname
}
408 proc do_round_mode_test
{} {
409 set testname
"roundmode.s: Test switching of rounding modes (part 2)"
412 if [gas_test_old
"roundmode.s" "" "Test switch of rounding modes(part 1)"] {
413 objdump_start_no_subdir
"a.out" "-r"
415 # Make sure GAS generated correct relocations to
switch rounding modes.
416 # Also make sure
(for SOM
) that redundant rounding
mode relocations
418 if [istarget hppa
*-*-*elf
*] then {
421 -re
"^00000000\[^\n\]*DIR21L\[^\n\]*\n"
422 { set x
[expr $x
+1] }
423 -re
"^00000004\[^\n\]*DIR14R\[^\n\]*\n"
424 { set x
[expr $x
+1] }
425 -re
"^00000008\[^\n\]*DIR21L\[^\n\]*\n"
426 { set x
[expr $x
+1] }
427 -re
"^0000000c\[^\n\]*DIR14R\[^\n\]*\n"
428 { set x
[expr $x
+1] }
429 -re
"^00000010\[^\n\]*DIR21L\[^\n\]*\n"
430 { set x
[expr $x
+1] }
431 -re
"^00000014\[^\n\]*DIR14R\[^\n\]*\n"
432 { set x
[expr $x
+1] }
433 -re
"^00000018\[^\n\]*DIR21L\[^\n\]*\n"
434 { set x
[expr $x
+1] }
435 -re
"^0000001c\[^\n\]*DIR14R\[^\n\]*\n"
436 { set x
[expr $x
+1] }
438 timeout
{ perror
"timeout\n"; break }
445 -re
"^00000000\[^\n\]*R_R_MODE\[^\n\]*\n"
446 { set x
[expr $x
+1] }
447 -re
"^00000004\[^\n\]*R_R_MODE\[^\n\]*\n"
449 -re
"^00000008\[^\n\]*R_N_MODE\[^\n\]*\n"
450 { set x
[expr $x
+1] }
451 -re
"^0000000c\[^\n\]*R_N_MODE\[^\n\]*\n"
453 -re
"^00000010\[^\n\]*R_R_MODE\[^\n\]*\n"
454 { set x
[expr $x
+1] }
455 -re
"^00000014\[^\n\]*R_R_MODE\[^\n\]*\n"
457 -re
"^0000001c\[^\n\]*R_R_MODE\[^\n\]*\n"
460 timeout
{ perror
"timeout\n"; break }
466 # This was intended to
do any cleanup necessary. It kinda looks like it
467 # isn
't needed, but just in case, please keep it in for now.
470 # Did we find what we were looking for? If not, flunk it.
471 if [istarget hppa*-*-*elf*] then {
472 if [expr $x==8] then { pass $testname } else { fail $testname }
474 if [expr $x==3] then { pass $testname } else { fail $testname }
479 proc do_function_reloc_bug {} {
480 set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
483 if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
484 objdump_start_no_subdir "a.out" "-r"
486 # Make sure GAS generated a correct relocation for the reference.
490 -re "^000000cc\[^\n\]*f2___4\[^\n+\]*\n"
491 { set x [expr $x+1] }
492 -re "^000000d0\[^\n\]*f2___4\[^\n+\]*\n"
493 { set x [expr $x+1] }
495 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 [expr $x
==2] then { pass $testname
} else { fail $testname
}
507 set testname
"funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
510 objdump_start_no_subdir
"a.out" "--prefix-addresses -d"
511 # Make sure we didn
't put anything in the instruction itself!
514 -re "^000000cc\[^\n\]*ldil 0,r20\[^\n\]*\n"
515 { set x [expr $x+1] }
516 -re "^000000d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n"
517 { set x [expr $x+1] }
519 timeout { perror "timeout\n"; break }
524 # This was intended to do any cleanup necessary. It kinda looks like it
525 # isn't needed
, but just in case
, please keep it in
for now.
528 # Did we find what we were looking
for?
If not
, flunk it.
529 if [expr $x
==2] then { pass $testname
} else { fail $testname
}
534 proc do_r_no_reloc
{} {
535 set testname
"r_no_reloc.s: Test for reloc bug in 4-byte R_NO_RELCOATION fixups (part 2)"
538 if [gas_test_old
"r_no_reloc.s" "" "Test for reloc bug in 4-byte R_NO_RELOCATION fixups (part 1)"] {
539 objdump_start_no_subdir
"a.out" "-r"
541 # Make sure GAS generated a correct relocation
for the reference.
544 -re
"^000c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n"
545 { set x
[expr $x
+1] }
547 timeout
{ perror
"timeout\n"; break }
552 # This was intended to
do any cleanup necessary. It kinda looks like it
553 # isn
't needed, but just in case, please keep it in for now.
556 # Did we find what we were looking for? If not, flunk it.
557 if [expr $x==1] then { pass $testname } else { fail $testname }
562 proc do_pic_relocation_test {} {
563 set testname "picreloc.s: Test for proper PIC relocation (part 2)"
566 # ELF (osf) doesn't really handle extra sections too well...
567 if [istarget hppa
*-*-*elf
*] then {
571 gas_start
"picreloc.s" "-al"
575 -re
"^ +\[0-9\]+ 0000 00000004\[^\n\]*\n" { set x [expr $x+1] }
577 timeout
{ perror
"timeout\n"; break }
582 # This was intended to
do any cleanup necessary. It kinda looks like it
583 # isn
't needed, but just in case, please keep it in for now.
586 # Did we find what we were looking for? If not, flunk it.
587 if [expr $x==1] then { pass $testname } else { fail $testname }
590 proc do_apply_test {} {
591 set testname "applybug.s: Test for proper fixup appliation (part 2)"
594 # ELF (osf) doesn't really handle extra sections too well...
595 if [istarget hppa
*-*-*elf
*] then {
599 gas_start
"applybug.s" "-al"
603 -re
"^ +\[0-9\]+ 0000 00000000\[^\n\]*\n" { set x [expr $x+1] }
604 -re
"^ +\[0-9\]+ 0004 00000000\[^\n\]*\n" { set x [expr $x+1] }
605 -re
"^ +\[0-9\]+ 0008 00000000\[^\n\]*\n" { set x [expr $x+1] }
607 timeout
{ perror
"timeout\n"; break }
612 # This was intended to
do any cleanup necessary. It kinda looks like it
613 # isn
't needed, but just in case, please keep it in for now.
616 # Did we find what we were looking for? If not, flunk it.
617 if [expr $x==3] then { pass $testname } else { fail $testname }
619 if [istarget hppa*-*-*] then {
620 # Make sure we put the right relocation entry on a BLE instruction.
621 do_ble_relocation_test
623 # Make sure relocation reductions are not too agressive about
624 # adjusting relocations against some symbols.
625 do_relocation_reduction_tests
627 # Check that mode selectors on a ble instruction actually work.
628 do_ble_mode_selector_test
630 # Check that we take the -8 adjustment into account when zeroing
631 # out the displacement field in a ble instruction with a reloc
632 do_ble_relocation_test
634 # 1.36 simply didn't generate all the plabels it should have. Make
636 do_plabel_relocation_test
638 # Make sure a field selector only effects the current instruction
639 # or assembler directive.
640 do_selector_scope_test
642 # This should really generate a relocation. It would make life much
643 # easier
on the optimizing linker. Until
then just make sure the
644 # difference is computed correctly.
645 do_local_label_as_operand_test
647 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
648 # were not in the source code.
649 do_exit_relocation_test
651 # GAS2 incorrectly thought it could apply a fixup
for a pc
-relative
652 # branch
/call which crossed different subspaces.
653 # Also check that the assembled instruction is correct
654 do_cross_space_fixup_test_1
655 do_cross_space_fixup_test_2
657 # Make sure we
switch rounding modes correctly
660 # Test
for a bug found when a function was used in a non
-branching
661 # instruction
*without
* a plabel
(for portable runtime
model)
662 do_function_reloc_bug
664 # Test
for an
off-by
-one bug in the handling of
4-byte R_NO_RELOCATION
668 # Test a relocation problem which shows up when building shared
670 do_pic_relocation_test
672 # Test a problem with md_apply_fix that was introduced when fixing
673 # the pic relocation test.
676 # Make sure gas doesn
't resolve long-calls which are to be fixed
678 gas_test "longcall.s" "" "" "Avoid resolving long-calls"