Upload Tizen:Base source
[external/binutils.git] / gas / testsuite / gas / hppa / reloc / reloc.exp
1 # Copyright 1993, 1996, 1997, 2002, 2004, 2005, 2007
2 # Free Software Foundation, Inc.
3
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.
8
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.
13
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.  
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # dejagnu@gnu.org
20
21 # Written by the Center for Software Science at the University of Utah
22 # and by Cygnus Support.
23
24 proc do_ble_relocation_test {} {
25     set testname "blebug.s: Test for proper relocation for BLE (part 2)"
26     set x 0
27
28     if [gas_test_old "blebug.s" "" "Proper relocation for BLE (part 1)"] then {
29         objdump_start_no_subdir "a.out" "-r"
30
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.
35             while 1 {
36                 expect {
37                     -re "^0+\[^\n\]*DIR21L\[^\n\]*\n"   { set x 1 }
38                     -re "^0+4\[^\n\]*DIR17R\[^\n\]*\n"  { set x 1 }
39                     -re "\[^\n\]*\n"                            { }
40                     timeout                     { perror "timeout\n"; break }
41                     eof                         { break }
42                 }
43             }
44         } else {
45             # At one time both versions of the assembler would incorrectly use 
46             # a PC-relative relocation for a BLE instruction.
47             while 1 {
48                 expect {
49                     -re "^0+4\[^\n\]*ABS_CALL\[^\n\]*\n"        { set x 1 }
50                     -re "\[^\n\]*\n"                            { }
51                     timeout                     { perror "timeout\n"; break }
52                     eof                         { break }
53                 }
54             }
55         }
56     }
57
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.
60     objdump_finish
61
62     # Did we find what we were looking for?  If not, flunk it.
63     if [expr $x==1] then { pass $testname } else { fail $testname }
64 }
65
66 proc do_relocation_reduction_tests {} {
67     set testname "reduce.s: Test relocation reductions (part 2)"
68     set x 0
69
70     if {[istarget hppa*64*-*-*]
71         || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
72       return
73     }
74
75     if [gas_test_old "reduce.s" "" "Relocation reductions (part1)"] then {
76         objdump_start_no_subdir "a.out" "-r"
77
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.
81         while 1 {
82             expect {
83                 -re "^0+4\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
84                     { set x [expr $x+1] }
85                 -re "^0+14\[^\n\]*PCREL\[^\n\]*foo\[^\n\]*\n"
86                     { set x [expr $x+1] }
87                 -re "\[^\n\]*\n"                { }
88                 timeout                         { perror "timeout\n"; break }
89                 eof                             { break }
90             }
91         }
92     }
93
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.
96     objdump_finish
97
98     # Did we find what we were looking for?  If not, flunk it.
99     if [expr $x==2] then { pass $testname } else { fail $testname }
100
101     set testname "reduce2.s: More relocation reduction tests (part 2)"
102     set x 0
103
104     if [gas_test_old "reduce2.s" "" "More relocation  reductions (part1)"] then {
105         objdump_start_no_subdir "a.out" "-r"
106
107         # Check to make sure DLT relative relocs are not reduced to sym+addend
108         # Doing so doesn't work as one might expect
109         while 1 {
110             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] }
119                 -re "\[^\n\]*\n"                { }
120                 timeout                         { perror "timeout\n"; break }
121                 eof                             { break }
122             }
123         }
124     }
125
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.
128     objdump_finish
129
130     # Did we find what we were looking for?  If not, flunk it.
131     if [expr $x==2] then { pass $testname } else { fail $testname }
132
133     set testname "reduce3.s: Test even more relocation reductions (part 2)"
134     set x 0
135
136     if [gas_test_old "reduce3.s" "" "Even more relocation reductions (part1)"] then {
137         objdump_start_no_subdir "a.out" "-r"
138
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.
142         while 1 {
143             expect {
144                 -re "^0+c\[^\n\]*yabba\[^\n\+\]*\n"
145                     { set x [expr $x+1] }
146                 -re "^0+c\[^\n\]*yabba\+\[^\n\]*\n"
147                     { set x 0; break }
148                 -re "^0+10\[^\n\]*yabba\[^\n\+\]*\n"
149                     { set x [expr $x+1] }
150                 -re "^0+10\[^\n\]*yabba\+\[^\n\]*\n"
151                     { set x 0; break }
152                 -re "\[^\n\]*\n"                { }
153                 timeout                         { perror "timeout\n"; break }
154                 eof                             { break }
155             }
156         }
157     }
158
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.
161     objdump_finish
162
163     # Did we find what we were looking for?  If not, flunk it.
164     if [expr $x==2] then { pass $testname } else { fail $testname }
165 }
166
167 proc do_ble_mode_selector_test {} {
168     set testname "blebug2.s: blebug2"
169     set x 0
170
171     gas_start "blebug2.s" "-al"
172
173     # GAS uses too many bits on the BLE instruction.
174     while 1 {
175         expect {
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] }
178             -re "\[^\n\]*\n"                            { }
179             timeout                             { perror "timeout\n"; break }
180             eof                                 { break }
181         }
182     }
183
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.
186     gas_finish
187
188     # Did we find what we were looking for?  If not, flunk it.
189     if [expr $x==2] then { pass $testname } else { fail $testname }
190 }
191
192 proc do_ble_relocation_test {} {
193     set testname "blebug3.s: blebug3"
194     set x 0
195
196     gas_start "blebug3.s" "-al"
197
198     while 1 {
199         expect {
200             -re "^ +\[0-9\]+ 0000 E4002000\[^\n\]*\n"   { set x [expr $x+1] }
201             -re "\[^\n\]*\n"                            { }
202             timeout                             { perror "timeout\n"; break }
203             eof                                 { break }
204         }
205     }
206
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.
209     gas_finish
210
211     # Did we find what we were looking for?  If not, flunk it.
212     if [expr $x==1] then { pass $testname } else { fail $testname }
213 }
214
215 proc do_plabel_relocation_test {} {
216     set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
217     set x 0
218
219     if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
220         objdump_start_no_subdir "a.out" "-r"
221
222         # Check that we make PLABEL relocation entries when they're needed.
223         while 1 {
224             expect {
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] }
229                 -re "\[^\n\]*\n"                        { }
230                 timeout                         { perror "timeout\n"; break }
231                 eof                             { break }
232             }
233         }
234
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.
237         objdump_finish
238
239         # Did we find what we were looking for?  If not, flunk it.
240         if [expr $x==2] then { pass $testname } else { fail $testname }
241     }
242 }
243
244 proc do_selector_scope_test {} {
245     set testname "selectorbug.s: Test scope of field selector" 
246     set x 0
247
248     if [istarget hppa*64*-*-*] then {
249       return
250     }
251
252     if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
253         objdump_start_no_subdir "a.out" "-r"
254
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 {
259             while 1 {
260                 expect {
261                     -re "^0+14\[^\n\]*DIR32\[^\n\]*\n"
262                         { set x 1 }
263                     -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
264                         { set x 0 }
265                     -re "\[^\n\]*\n"            { }
266                     timeout                     { perror "timeout\n"; break }
267                     eof                         { break }
268                 }
269             }
270         } else {
271             while 1 {
272                 expect {
273                     -re "^0+14\[^\n\]*DATA_ONE\[^\n\]*\n"
274                         { set x 1 }
275                     -re "^0+14\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
276                         { set x 0 }
277                     -re "\[^\n\]*\n"            { }
278                     timeout                     { perror "timeout\n"; break }
279                     eof                         { break }
280                 }
281             }
282         }
283
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.
286         objdump_finish
287
288         # Did we find what we were looking for?  If not, flunk it.
289         if [expr $x==1] then { pass $testname } else { fail $testname }
290     }
291 }
292
293 proc do_local_label_as_operand_test {} {
294     set testname "labelopbug.s: Test local label as operand (non-branching)"
295     set x 0
296
297     if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
298         objdump_start_no_subdir "a.out" "-r"
299
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 {
308             while 1 {
309                 expect {
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] }
314                     -re "\[^\n\]*\n"            { }
315                     timeout                     { perror "timeout\n"; break }
316                     eof                         { break }
317                 }
318             }
319         } else {
320             while 1 {
321                 expect {
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] }
326                     -re "\[^\n\]*\n"            { }
327                     timeout                     { perror "timeout\n"; break }
328                     eof                         { break }
329                 }
330             }
331         }
332
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.
335         objdump_finish
336
337         # Did we find what we were looking for?  If not, flunk it.
338         if [expr $x==2] then { pass $testname } else { fail $testname }
339     }
340 }
341
342 proc do_exit_relocation_test {} {
343     set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
344     set x 0
345
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)"
352         return
353     }
354
355     if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
356         objdump_start_no_subdir "a.out" "-r"
357
358         # Note that a match here is really a FAILURE!
359         while 1 {
360             expect {
361                 -re "^0+\[^\n\]*R_EXIT\[^\n\]*\n" 
362                     { set x [expr $x+1] }
363                 -re "\[^\n\]*\n"                { }
364                 timeout                         { perror "timeout\n"; break }
365                 eof                             { break }
366             }
367         }
368
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.
371         objdump_finish
372
373         # Did we find what we were looking for?  If not, flunk it.
374         if [expr $x==0] then { pass $testname } else { fail $testname }
375     }
376 }
377
378 proc do_cross_space_fixup_test_1 {} {
379     set testname "fixupbug.s: Test cross space jump/call fixup bug (part 2)"
380     set x 0
381
382     # ELF doesn't really handle extra sections too well...
383     if {[istarget hppa*64*-*-*]
384         || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
385         return
386     }
387
388     if [gas_test_old "fixupbug.s" "" "Test cross space jump/call fixup bug (part 1)"] {
389         objdump_start_no_subdir "a.out" "-r"
390
391         # Make sure GAS generated a fixup/relocation for the cross-space
392         # branch/call
393         while 1 {
394             expect {
395                 -re "^0+\[^\n\]*PCREL_CALL\[^\n\]*\n" 
396                     { set x [expr $x+1] }
397                 -re "\[^\n\]*\n"                { }
398                 timeout                         { perror "timeout\n"; break }
399                 eof                             { break }
400             }
401         }
402
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.
405         objdump_finish
406
407         # Did we find what we were looking for?  If not, flunk it.
408         if [expr $x==1] then { pass $testname } else { fail $testname }
409     }
410 }
411
412 proc do_cross_space_fixup_test_2 {} {
413     set testname "fixupbug.s: Test cross space jump/call fixup bug (part 3)"
414     set x 0
415
416     # ELF doesn't really handle extra sections too well...
417     if {[istarget hppa*64*-*-*]
418         || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
419         return
420     }
421
422     gas_start "fixupbug.s" "-al"
423
424     while 1 {
425         expect {
426             -re "^ +\[0-9\]+ 0000 E8000002\[^\n\]*\n"   { set x [expr $x+1] }
427             -re "\[^\n\]*\n"                            { }
428             timeout                             { perror "timeout\n"; break }
429             eof                                 { break }
430         }
431     }
432
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.
435     gas_finish
436
437     # Did we find what we were looking for?  If not, flunk it.
438     if [expr $x==1] then { pass $testname } else { fail $testname }
439 }
440
441 proc do_round_mode_test {} {
442     set testname "roundmode.s: Test switching of rounding modes (part 2)"
443     set x 0
444
445     if [gas_test_old "roundmode.s" "" "Test switch of rounding modes(part 1)"] {
446         objdump_start_no_subdir "a.out" "-r"
447
448         # Make sure GAS generated correct relocations to switch rounding modes.
449         # Also make sure (for SOM) that redundant rounding mode relocations
450         # were eliminated.
451         if {[istarget hppa*64*-*-*]
452             || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
453             while 1 {
454                 expect {
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] }
471                     -re "\[^\n\]*\n"            { }
472                 timeout                         { perror "timeout\n"; break }
473                 eof                             { break }
474                 }
475             }
476         } else {
477             while 1 {
478                 expect {
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" 
482                         { fail $testname }
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" 
486                         { fail $testname }
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" 
490                         { fail $testname }
491                     -re "^0+1c\[^\n\]*R_R_MODE\[^\n\]*\n" 
492                         { fail $testname }
493                     -re "\[^\n\]*\n"            { }
494                 timeout                         { perror "timeout\n"; break }
495                 eof                             { break }
496                 }
497             }
498         }
499
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
503
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 }
508         } else {
509             if [expr $x==3] then { pass $testname } else { fail $testname }
510         }
511     }
512 }
513
514 proc do_function_reloc_bug {} {
515     set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part 2)"
516     set x 0
517
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"
520
521         # Make sure GAS generated a correct relocation for the reference.
522         # branch/call
523         while 1 {
524             expect {
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] }
529                 -re "\[^\n\]*\n"                { }
530                 timeout                         { perror "timeout\n"; break }
531                 eof                             { break }
532             }
533         }
534
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.
537         objdump_finish
538
539         # Did we find what we were looking for?  If not, flunk it.
540         if [expr $x==2] then { pass $testname } else { fail $testname }
541
542         set testname "funcrelocbug.s: Test for reloc bug in non-plabel function reference (part3)"
543         set x 0
544
545         objdump_start_no_subdir "a.out" "--prefix-addresses -d"
546         # Make sure we didn't put anything in the instruction itself!
547         while 1 {
548             expect {
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] }
553                 -re "\[^\n\]*\n"                { }
554                 timeout                         { perror "timeout\n"; break }
555                 eof                             { break }
556             }
557         }
558
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.
561         objdump_finish
562
563         # Did we find what we were looking for?  If not, flunk it.
564         if [expr $x==2] then { pass $testname } else { fail $testname }
565     }
566
567 }
568
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)"
571     set x 0
572
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"
575
576         # Make sure GAS generated a correct relocation for the reference.
577         while 1 {
578             expect {
579                 -re "^0+c0004\[^\n\]*PLABEL\[^\n]*g\[^\n\]*\n" 
580                     { set x [expr $x+1] }
581                 -re "\[^\n\]*\n"                { }
582                 timeout                         { perror "timeout\n"; break }
583                 eof                             { break }
584             }
585         }
586
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.
589         objdump_finish
590
591         # Did we find what we were looking for?  If not, flunk it.
592         if [expr $x==1] then { pass $testname } else { fail $testname }
593
594     }
595 }
596
597 proc do_pic_relocation_test {} {
598     set testname "picreloc.s: Test for proper PIC relocation (part 2)"
599     set x 0
600
601     # ELF doesn't really handle extra sections too well...
602     if {[istarget hppa*64*-*-*]
603         || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
604         return
605     }
606
607     gas_start "picreloc.s" "-al"
608
609     while 1 {
610         expect {
611             -re "^ +\[0-9\]+ 0000 00000004\[^\n\]*\n"   { set x [expr $x+1] }
612             -re "\[^\n\]*\n"                            { }
613             timeout                             { perror "timeout\n"; break }
614             eof                                 { break }
615         }
616     }
617
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.
620     gas_finish
621
622     # Did we find what we were looking for?  If not, flunk it.
623     if [expr $x==1] then { pass $testname } else { fail $testname }
624 }
625
626 proc do_apply_test {} {
627     set testname "applybug.s: Test for proper fixup application (part 2)"
628     set x 0
629
630     # ELF doesn't really handle extra sections too well...
631     if {[istarget hppa*64*-*-*]
632         || [istarget hppa*-*-*elf*] || [istarget hppa*-*-linux*]} then {
633         return
634     }
635
636     gas_start "applybug.s" "-al"
637
638     while 1 {
639         expect {
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] }
643             -re "\[^\n\]*\n"                            { }
644             timeout                             { perror "timeout\n"; break }
645             eof                                 { break }
646         }
647     }
648
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.
651     gas_finish
652
653     # Did we find what we were looking for?  If not, flunk it.
654     if [expr $x==3] then { pass $testname } else { fail $testname }
655 }
656
657 if [istarget hppa*-*-*] then {
658     # Make sure we put the right relocation entry on a BLE instruction.
659     do_ble_relocation_test
660
661     # Make sure relocation reductions are not too agressive about
662     # adjusting relocations against some symbols.
663     do_relocation_reduction_tests
664
665     # Check that mode selectors on a ble instruction actually work.
666     do_ble_mode_selector_test
667
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
671
672     # 1.36 simply didn't generate all the plabels it should have.  Make
673     # sure gas-2 does.
674     do_plabel_relocation_test
675
676     # Make sure a field selector only effects the current instruction
677     # or assembler directive.
678     do_selector_scope_test
679
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
684
685     # GAS2 incorrectly generated R_EXIT relocations when .exit directives
686     # were not in the source code.
687     do_exit_relocation_test
688
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
694
695     # Make sure we switch rounding modes correctly
696     do_round_mode_test
697
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
701
702     # Test for an off-by-one bug in the handling of 4-byte R_NO_RELOCATION
703     # fixups.
704     do_r_no_reloc
705
706     # Test a relocation problem which shows up when building shared
707     # libraries in SOM
708     do_pic_relocation_test
709
710     # Test a problem with md_apply_fix that was introduced when fixing
711     # the pic relocation test.
712     do_apply_test
713
714     # Make sure gas doesn't resolve long-calls which are to be fixed
715     # by the linker
716     gas_test "longcall.s" "" "" "Avoid resolving long-calls"
717 }