summaryrefslogtreecommitdiff
path: root/gas/testsuite/gas/hppa/reloc/reloc.exp
blob: df6d09a74317b6d2dae03969fabc3c4b7fbdb86c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# Copyright (C) 1993-2019 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  

# Please email any bugs, comments, and/or additions to this file to:
# dejagnu@gnu.org

# Written by the Center for Software Science at the University of Utah
# and by Cygnus Support.

proc do_ble_relocation_test {} {
    set testname "blebug.s: Test for proper relocation for BLE (part 2)"
    set x 0

    if [gas_test_old "blebug.s" "" "Proper relocation for BLE (part 1)"] then {
	objdump_start_no_subdir "a.out" "-r"

        if {[istarget hppa*64*-*-*]
	    || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	    # At one time both versions of the assembler would incorrectly use 
	    # a PC-relative relocation for a BLE instruction.
	    while 1 {
		expect {
		    -re "^0+\[^\n\]*DIR21L\[^\n\]*\n"	{ set x 1 }
		    -re "^0+4\[^\n\]*DIR17R\[^\n\]*\n"	{ set x 1 }
		    -re "\[^\n\]*\n"				{ }
		    timeout			{ perror "timeout\n"; break }
		    eof				{ break }
		}
	    }
	} else {
	    # At one time both versions of the assembler would incorrectly use 
	    # a PC-relative relocation for a BLE instruction.
	    while 1 {
		expect {
		    -re "^0+4\[^\n\]*ABS_CALL\[^\n\]*\n"	{ set x 1 }
		    -re "\[^\n\]*\n"				{ }
		    timeout			{ perror "timeout\n"; break }
		    eof				{ break }
		}
	    }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    objdump_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==1] then { pass $testname } else { fail $testname }
}

proc do_relocation_reduction_tests {} {
    set testname "reduce.s: Test relocation reductions (part 2)"
    set x 0

    if {[istarget hppa*64*-*-*]
        || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
      return
    }

    if [gas_test_old "reduce.s" "" "Relocation reductions (part1)"] then {
	objdump_start_no_subdir "a.out" "-r"

	# Check to make sure relocations involving procedure labels 
	# are not reduced to a relocation involving some other symbol.
	# Doing so makes generating parameter relocation stubs impossible.
	while 1 {
	    expect {
		-re "^0+4\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "^0+14\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "\[^\n\]*\n"		{ }
		timeout				{ perror "timeout\n"; break }
		eof				{ break }
            }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    objdump_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==2] then { pass $testname } else { fail $testname }

    set testname "reduce2.s: More relocation reduction tests (part 2)"
    set x 0

    if [gas_test_old "reduce2.s" "" "More relocation  reductions (part1)"] then {
	objdump_start_no_subdir "a.out" "-r"

	# Check to make sure DLT relative relocs are not reduced to sym+addend
	# Doing so doesn't work as one might expect
	while 1 {
	    expect {
		-re "^0+4\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "^0+1c\[^\n\]*DLT\[^\n\]*L.C0000\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "^0+30\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "^0+48\[^\n\]*DLT\[^\n\]*L.C0001\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "\[^\n\]*\n"		{ }
		timeout				{ perror "timeout\n"; break }
		eof				{ break }
            }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    objdump_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==2] then { pass $testname } else { fail $testname }

    set testname "reduce3.s: Test even more relocation reductions (part 2)"
    set x 0

    if [gas_test_old "reduce3.s" "" "Even more relocation reductions (part1)"] then {
	objdump_start_no_subdir "a.out" "-r"

	# Check to make sure relocations involving procedure labels 
	# are not reduced to a relocation involving some other symbol.
	# Doing so makes generating parameter relocation stubs impossible.
	while 1 {
	    expect {
		-re "^0+c\[^\n\]*yabba\[^\n\+\]*\n"
		    { set x [expr $x+1] }
		-re "^0+c\[^\n\]*yabba\+\[^\n\]*\n"
		    { set x 0; break }
		-re "^0+10\[^\n\]*yabba\[^\n\+\]*\n"
		    { set x [expr $x+1] }
		-re "^0+10\[^\n\]*yabba\+\[^\n\]*\n"
		    { set x 0; break }
		-re "\[^\n\]*\n"		{ }
		timeout				{ perror "timeout\n"; break }
		eof				{ break }
            }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    objdump_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==2] then { pass $testname } else { fail $testname }
}

proc do_ble_mode_selector_test {} {
    set testname "blebug2.s: blebug2"
    set x 0

    gas_start "blebug2.s" "-al"

    # GAS uses too many bits on the BLE instruction.
    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    gas_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==2] then { pass $testname } else { fail $testname }
}

proc do_ble_relocation_test {} {
    set testname "blebug3.s: blebug3"
    set x 0

    gas_start "blebug3.s" "-al"

    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    gas_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==1] then { pass $testname } else { fail $testname }
}

proc do_plabel_relocation_test {} {
    set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
    set x 0

    if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Check that we make PLABEL relocation entries when they're needed.
	while 1 {
	    expect {
		-re "^0+\[^\n\]*PLABEL\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "^0+4\[^\n\]*PLABEL\[^\n\]*\n"
		    { set x [expr $x+1] }
		-re "\[^\n\]*\n"			{ }
		timeout				{ perror "timeout\n"; break }
		eof				{ break }
    	    }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==2] then { pass $testname } else { fail $testname }
    }
}

proc do_selector_scope_test {} {
    set testname "selectorbug.s: Test scope of field selector" 
    set x 0

    if [istarget hppa*64*-*-*] then {
      return
    }

    if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Check to make sure the relocation entry after the plabel is correct.
	# If an old field selector was incorrectly "carried" over, then 
	# this test will fail.
        if {[istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	    while 1 {
		expect {
	            -re "^0+14\[^\n\]*DIR32\[^\n\]*\n"
			{ set x 1 }
		    -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
			{ set x 0 }
	            -re "\[^\n\]*\n"		{ }
	            timeout			{ perror "timeout\n"; break }
	            eof				{ break }
		}
            }
	} else {
	    while 1 {
		expect {
	            -re "^0+14\[^\n\]*DATA_ONE\[^\n\]*\n"
			{ set x 1 }
		    -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
			{ set x 0 }
	            -re "\[^\n\]*\n"		{ }
	            timeout			{ perror "timeout\n"; break }
	            eof				{ break }
		}
            }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==1] then { pass $testname } else { fail $testname }
    }
}

proc do_local_label_as_operand_test {} {
    set testname "labelopbug.s: Test local label as operand (non-branching)"
    set x 0

    if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Check to make sure we handle difference of local labels as an operand
	# to a non-branching instruction correctly.  On hppa elf targets, the
	# R_PARISC_DIR21 and R_PARISC_DIR14R relocations are done with LR and
	# RR selectors, respectively.  As a result, we can't reduce these to
	# section offsets without risking incorrect rounding.  So, we just
	# check to see if the label hasn't been reduced.
	if {[istarget hppa*64*-*-*]
	    || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	    while 1 {
		expect {
	            -re "^0+2c\[^\n\]*L.0002\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "^0+30\[^\n\]*L.0002\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "\[^\n\]*\n"		{ }
	            timeout			{ perror "timeout\n"; break }
	            eof				{ break }
		}
	    }
	} else {
	    while 1 {
		expect {
	            -re "^0+2c\[^\n\]*0x0+24\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "^0+30\[^\n\]*0x0+24\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "\[^\n\]*\n"		{ }
	            timeout			{ perror "timeout\n"; break }
	            eof				{ break }
		}
	    }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==2] then { pass $testname } else { fail $testname }
    }
}

proc do_exit_relocation_test {} {
    set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
    set x 0

    # Elf (osf) does not use ENTRY/EXIT relocations.
    # I guess we could look at the unwind subspaces it builds...
    # Until then, make sure it still assembles.
    if {[istarget hppa*64*-*-*]
	|| [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"
	return
    }

    if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Note that a match here is really a FAILURE!
	while 1 {
	    expect {
	        -re "^0+\[^\n\]*R_EXIT\[^\n\]*\n" 
		    { set x [expr $x+1] }
	        -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
            }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==0] then { pass $testname } else { fail $testname }
    }
}

proc do_cross_space_fixup_test_1 {} {
    set testname "fixupbug.s: Test cross space jump/call fixup bug (part 2)"
    set x 0

    # ELF doesn't really handle extra sections too well...
    if {[istarget hppa*64*-*-*]
	|| [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	return
    }

    if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Make sure GAS generated a fixup/relocation for the cross-space
	# branch/call
	while 1 {
	    expect {
	        -re "^0+\[^\n\]*PCREL_CALL\[^\n\]*\n" 
		    { set x [expr $x+1] }
	        -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
            }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==1] then { pass $testname } else { fail $testname }
    }
}

proc do_cross_space_fixup_test_2 {} {
    set testname "fixupbug.s: Test cross space jump/call fixup bug (part 3)"
    set x 0

    # ELF doesn't really handle extra sections too well...
    if {[istarget hppa*64*-*-*]
	|| [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	return
    }

    gas_start "fixupbug.s" "-al"

    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    gas_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==1] then { pass $testname } else { fail $testname }
}

proc do_round_mode_test {} {
    set testname "roundmode.s: Test switching of rounding modes (part 2)"
    set x 0

    if [gas_test_old "roundmode.s" "" "Test switch of rounding modes(part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Make sure GAS generated correct relocations to switch rounding modes.
	# Also make sure (for SOM) that redundant rounding mode relocations
	# were eliminated.
	if {[istarget hppa*64*-*-*]
	    || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	    while 1 {
		expect {
	            -re "^0+\[^\n\]*DIR21L\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+4\[^\n\]*DIR14R\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "^0+8\[^\n\]*DIR21L\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+c\[^\n\]*DIR14R\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "^0+10\[^\n\]*DIR21L\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+14\[^\n\]*DIR14R\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "^0+18\[^\n\]*DIR21L\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+1c\[^\n\]*DIR14R\[^\n\]*\n" 
			{ set x [expr $x+1] }
	            -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
		}
            }
	} else {
	    while 1 {
		expect {
	            -re "^0+\[^\n\]*R_R_MODE\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+4\[^\n\]*R_R_MODE\[^\n\]*\n" 
			{ fail $testname }
	            -re "^0+8\[^\n\]*R_N_MODE\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+c\[^\n\]*R_N_MODE\[^\n\]*\n" 
			{ fail $testname }
	            -re "^0+10\[^\n\]*R_R_MODE\[^\n\]*\n"
			{ set x [expr $x+1] }
	            -re "^0+14\[^\n\]*R_R_MODE\[^\n\]*\n" 
			{ fail $testname }
	            -re "^0+1c\[^\n\]*R_R_MODE\[^\n\]*\n" 
			{ fail $testname }
	            -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
		}
	    }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if {[istarget hppa*64*-*-*]
	    || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	    if [expr $x==8] then { pass $testname } else { fail $testname }
	} else {
	    if [expr $x==3] then { pass $testname } else { fail $testname }
	}
    }
}

proc do_function_reloc_bug {} {
    set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
    set x 0

    if [gas_test_old "funcrelocbug.s" "" "Test for reloc bug in non-plabel function reference (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Make sure GAS generated a correct relocation for the reference.
	# branch/call
	while 1 {
	    expect {
	        -re "^0+cc\[^\n\]*f2___4\[^\n+\]*\n" 
		    { set x [expr $x+1] }
	        -re "^0+d0\[^\n\]*f2___4\[^\n+\]*\n"  
		    { set x [expr $x+1] }
	        -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
            }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==2] then { pass $testname } else { fail $testname }

	set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
	set x 0

	objdump_start_no_subdir "a.out" "--prefix-addresses -d"
	# Make sure we didn't put anything in the instruction itself!
	while 1 {
	    expect {
	        -re "^0+cc\[^\n\]*ldil L%0,r20\[^\n\]*\n" 
		    { set x [expr $x+1] }
	        -re "^0+d0\[^\n\]*ldo 0\[\(\]+r20\[\)\]+,r19\[^\n\]*\n" 
		    { set x [expr $x+1] }
	        -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
	    }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==2] then { pass $testname } else { fail $testname }
    }

}

proc do_r_no_reloc {} {
    set testname "r_no_reloc.s: Test for reloc bug in 4-byte R_NO_RELCOATION fixups (part 2)"
    set x 0

    if [gas_test_old "r_no_reloc.s" "" "Test for reloc bug in 4-byte R_NO_RELOCATION fixups (part 1)"] {
	objdump_start_no_subdir "a.out" "-r"

	# Make sure GAS generated a correct relocation for the reference.
	while 1 {
	    expect {
	        -re "^0+c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n" 
		    { set x [expr $x+1] }
	        -re "\[^\n\]*\n"		{ }
	        timeout				{ perror "timeout\n"; break }
	        eof				{ break }
            }
	}

	# This was intended to do any cleanup necessary.  It kinda looks like it
	# isn't needed, but just in case, please keep it in for now.
	objdump_finish

	# Did we find what we were looking for?  If not, flunk it.
	if [expr $x==1] then { pass $testname } else { fail $testname }

    }
}

proc do_pic_relocation_test {} {
    set testname "picreloc.s: Test for proper PIC relocation (part 2)"
    set x 0

    # ELF doesn't really handle extra sections too well...
    if {[istarget hppa*64*-*-*]
	|| [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	return
    }

    gas_start "picreloc.s" "-al"

    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 00000004\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    gas_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==1] then { pass $testname } else { fail $testname }
}

proc do_apply_test {} {
    set testname "applybug.s: Test for proper fixup application (part 2)"
    set x 0

    # ELF doesn't really handle extra sections too well...
    if {[istarget hppa*64*-*-*]
	|| [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
	return
    }

    gas_start "applybug.s" "-al"

    while 1 {
	expect {
	    -re "^ +\[0-9\]+ 0000 00000044\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "^ +\[0-9\]+ 0004 00000058\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "^ +\[0-9\]+ 0008 0000006C\[^\n\]*\n"	{ set x [expr $x+1] }
	    -re "\[^\n\]*\n"				{ }
	    timeout				{ perror "timeout\n"; break }
	    eof					{ break }
	}
    }

    # This was intended to do any cleanup necessary.  It kinda looks like it
    # isn't needed, but just in case, please keep it in for now.
    gas_finish

    # Did we find what we were looking for?  If not, flunk it.
    if [expr $x==3] then { pass $testname } else { fail $testname }
}

if [istarget hppa*-*-*] then {
    # Make sure we put the right relocation entry on a BLE instruction.
    do_ble_relocation_test

    # Make sure relocation reductions are not too aggressive about
    # adjusting relocations against some symbols.
    do_relocation_reduction_tests

    # Check that mode selectors on a ble instruction actually work.
    do_ble_mode_selector_test

    # Check that we take the -8 adjustment into account when zeroing
    # out the displacement field in a ble instruction with a reloc
    do_ble_relocation_test

    # 1.36 simply didn't generate all the plabels it should have.  Make
    # sure gas-2 does.
    do_plabel_relocation_test

    # Make sure a field selector only effects the current instruction
    # or assembler directive.
    do_selector_scope_test

    # This should really generate a relocation.  It would make life much
    # easier on the optimizing linker.  Until then just make sure the 
    # difference is computed correctly.
    do_local_label_as_operand_test

    # GAS2 incorrectly generated R_EXIT relocations when .exit directives
    # were not in the source code.
    do_exit_relocation_test

    # GAS2 incorrectly thought it could apply a fixup for a pc-relative
    # branch/call which crossed different subspaces.
    # Also check that the assembled instruction is correct
    do_cross_space_fixup_test_1
    do_cross_space_fixup_test_2

    # Make sure we switch rounding modes correctly
    do_round_mode_test

    # Test for a bug found when a function was used in a non-branching
    # instruction *without* a plabel (for portable runtime model)
    do_function_reloc_bug

    # Test for an off-by-one bug in the handling of 4-byte R_NO_RELOCATION
    # fixups.
    do_r_no_reloc

    # Test a relocation problem which shows up when building shared
    # libraries in SOM
    do_pic_relocation_test

    # Test a problem with md_apply_fix that was introduced when fixing
    # the pic relocation test.
    do_apply_test

    # Make sure gas doesn't resolve long-calls which are to be fixed
    # by the linker
    gas_test "longcall.s" "" "" "Avoid resolving long-calls"
}