Initial revision
[binutils.git] / gas / testsuite / gas / hppa / reloc / reloc.exp
blobccb236cba7184b40ee8b0fe95739c14381d76535
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.
7 #
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:
18 # DejaGnu@cygnus.com
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)"
25 set x 0
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.
33 while 1 {
34 expect {
35 -re "^00000004\[^\n\]*ABS_CALL\[^\n\]*\n" { set x 1 }
36 -re "\[^\n\]*\n" { }
37 timeout { perror "timeout\n"; break }
38 eof { break }
41 } else {
42 # At one time both versions of the assembler would incorrectly use
43 # a PC-relative relocation for a BLE instruction.
44 while 1 {
45 expect {
46 -re "^00000000\[^\n\]*DIR21L\[^\n\]*\n" { set x 1 }
47 -re "^00000004\[^\n\]*DIR17R\[^\n\]*\n" { set x 1 }
48 -re "\[^\n\]*\n" { }
49 timeout { perror "timeout\n"; break }
50 eof { 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.
58 objdump_finish
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)"
66 set x 0
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.
74 while 1 {
75 expect {
76 -re "^00000004\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
77 { set x [expr $x+1] }
78 -re "^00000014\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
79 { set x [expr $x+1] }
80 -re "\[^\n\]*\n" { }
81 timeout { perror "timeout\n"; break }
82 eof { 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.
89 objdump_finish
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)"
95 set x 0
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
102 while 1 {
103 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] }
112 -re "\[^\n\]*\n" { }
113 timeout { perror "timeout\n"; break }
114 eof { 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.
121 objdump_finish
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)"
127 set x 0
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.
135 while 1 {
136 expect {
137 -re "^0000000c\[^\n\]*yabba\[^\n\+\]*\n"
138 { set x [expr $x+1] }
139 -re "^0000000c\[^\n\]*yabba\+\[^\n\]*\n"
140 { set x 0; break }
141 -re "^00000010\[^\n\]*yabba\[^\n\+\]*\n"
142 { set x [expr $x+1] }
143 -re "^00000010\[^\n\]*yabba\+\[^\n\]*\n"
144 { set x 0; break }
145 -re "\[^\n\]*\n" { }
146 timeout { perror "timeout\n"; break }
147 eof { 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.
154 objdump_finish
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"
162 set x 0
164 gas_start "blebug2.s" "-al"
166 # GAS uses too many bits on the BLE instruction.
167 while 1 {
168 expect {
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] }
171 -re "\[^\n\]*\n" { }
172 timeout { perror "timeout\n"; break }
173 eof { 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.
179 gas_finish
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"
187 set x 0
189 gas_start "blebug3.s" "-al"
191 while 1 {
192 expect {
193 -re "^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n" { set x [expr $x+1] }
194 -re "\[^\n\]*\n" { }
195 timeout { perror "timeout\n"; break }
196 eof { 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.
202 gas_finish
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)"
210 set x 0
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.
216 while 1 {
217 expect {
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] }
222 -re "\[^\n\]*\n" { }
223 timeout { perror "timeout\n"; break }
224 eof { 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.
230 objdump_finish
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"
239 set x 0
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 {
248 while 1 {
249 expect {
250 -re "^00000014\[^\n\]*DIR32\[^\n\]*\n"
251 { set x 1 }
252 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
253 { set x 0 }
254 -re "\[^\n\]*\n" { }
255 timeout { perror "timeout\n"; break }
256 eof { break }
259 } else {
260 while 1 {
261 expect {
262 -re "^00000014\[^\n\]*DATA_ONE\[^\n\]*\n"
263 { set x 1 }
264 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
265 { set x 0 }
266 -re "\[^\n\]*\n" { }
267 timeout { perror "timeout\n"; break }
268 eof { 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.
275 objdump_finish
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)"
284 set x 0
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.
291 while 1 {
292 expect {
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] }
297 -re "\[^\n\]*\n" { }
298 timeout { perror "timeout\n"; break }
299 eof { 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.
305 objdump_finish
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)"
314 set x 0
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)"
321 return;
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!
328 while 1 {
329 expect {
330 -re "^00000000\[^\n\]*R_EXIT\[^\n\]*\n"
331 { set x [expr $x+1] }
332 -re "\[^\n\]*\n" { }
333 timeout { perror "timeout\n"; break }
334 eof { 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.
340 objdump_finish
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)"
349 set x 0
351 # ELF (osf) doesn't really handle extra sections too well...
352 if [istarget hppa*-*-*elf*] then {
353 return;
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
360 # branch/call
361 while 1 {
362 expect {
363 -re "^00000000\[^\n\]*PCREL_CALL\[^\n\]*\n"
364 { set x [expr $x+1] }
365 -re "\[^\n\]*\n" { }
366 timeout { perror "timeout\n"; break }
367 eof { 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.
373 objdump_finish
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)"
382 set x 0
384 # ELF (osf) doesn't really handle extra sections too well...
385 if [istarget hppa*-*-*elf*] then {
386 return;
389 gas_start "fixupbug.s" "-al"
391 while 1 {
392 expect {
393 -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n" { set x [expr $x+1] }
394 -re "\[^\n\]*\n" { }
395 timeout { perror "timeout\n"; break }
396 eof { 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.
402 gas_finish
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)"
410 set x 0
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
417 # were eliminated.
418 if [istarget hppa*-*-*elf*] then {
419 while 1 {
420 expect {
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] }
437 -re "\[^\n\]*\n" { }
438 timeout { perror "timeout\n"; break }
439 eof { break }
442 } else {
443 while 1 {
444 expect {
445 -re "^00000000\[^\n\]*R_R_MODE\[^\n\]*\n"
446 { set x [expr $x+1] }
447 -re "^00000004\[^\n\]*R_R_MODE\[^\n\]*\n"
448 { fail $testname }
449 -re "^00000008\[^\n\]*R_N_MODE\[^\n\]*\n"
450 { set x [expr $x+1] }
451 -re "^0000000c\[^\n\]*R_N_MODE\[^\n\]*\n"
452 { fail $testname }
453 -re "^00000010\[^\n\]*R_R_MODE\[^\n\]*\n"
454 { set x [expr $x+1] }
455 -re "^00000014\[^\n\]*R_R_MODE\[^\n\]*\n"
456 { fail $testname }
457 -re "^0000001c\[^\n\]*R_R_MODE\[^\n\]*\n"
458 { fail $testname }
459 -re "\[^\n\]*\n" { }
460 timeout { perror "timeout\n"; break }
461 eof { 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.
468 objdump_finish
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 }
473 } else {
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)"
481 set x 0
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.
487 # branch/call
488 while 1 {
489 expect {
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] }
494 -re "\[^\n\]*\n" { }
495 timeout { perror "timeout\n"; break }
496 eof { 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.
502 objdump_finish
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)"
508 set x 0
510 objdump_start_no_subdir "a.out" "--prefix-addresses -d"
511 # Make sure we didn't put anything in the instruction itself!
512 while 1 {
513 expect {
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] }
518 -re "\[^\n\]*\n" { }
519 timeout { perror "timeout\n"; break }
520 eof { 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.
526 objdump_finish
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)"
536 set x 0
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.
542 while 1 {
543 expect {
544 -re "^000c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n"
545 { set x [expr $x+1] }
546 -re "\[^\n\]*\n" { }
547 timeout { perror "timeout\n"; break }
548 eof { 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.
554 objdump_finish
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)"
564 set x 0
566 # ELF (osf) doesn't really handle extra sections too well...
567 if [istarget hppa*-*-*elf*] then {
568 return;
571 gas_start "picreloc.s" "-al"
573 while 1 {
574 expect {
575 -re "^ +\[0-9\]+ 0000 00000004\[^\n\]*\n" { set x [expr $x+1] }
576 -re "\[^\n\]*\n" { }
577 timeout { perror "timeout\n"; break }
578 eof { 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.
584 gas_finish
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)"
592 set x 0
594 # ELF (osf) doesn't really handle extra sections too well...
595 if [istarget hppa*-*-*elf*] then {
596 return;
599 gas_start "applybug.s" "-al"
601 while 1 {
602 expect {
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] }
606 -re "\[^\n\]*\n" { }
607 timeout { perror "timeout\n"; break }
608 eof { 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.
614 gas_finish
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
635 # sure gas-2 does.
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
658 do_round_mode_test
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
665 # fixups.
666 do_r_no_reloc
668 # Test a relocation problem which shows up when building shared
669 # libraries in SOM
670 do_pic_relocation_test
672 # Test a problem with md_apply_fix that was introduced when fixing
673 # the pic relocation test.
674 do_apply_test
676 # Make sure gas doesn't resolve long-calls which are to be fixed
677 # by the linker
678 gas_test "longcall.s" "" "" "Avoid resolving long-calls"