]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/hppa/reloc/reloc.exp
* gas/hppa/reloc/exitbug.s: New test.
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / hppa / reloc / reloc.exp
1 # Copyright (C) 1993 Free Software Foundation, Inc.
2
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.
12 #
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # DejaGnu@cygnus.com
19
20 # Written by the Center for Software Science at the University of Utah
21 # and by Cygnus Support.
22
23 proc do_ble_relocation_test {} {
24 set testname "blebug.s: Test for proper relocation for BLE (part 2)"
25 set x 0
26
27 if [gas_test_old "blebug.s" "" "Proper relocation for BLE (part 1)"] then {
28 objdump_start_no_subdir "a.out" "-r"
29
30 # At one time both versions of the assembler would incorrectly use
31 # a PC-relative relocation for a BLE instruction.
32 while 1 {
33 expect {
34 -re "^00000004\[^\n\]*ABS_CALL\[^\n\]*\n" { set x 1 }
35 -re "\[^\n\]*\n" { }
36 timeout { error "timeout\n"; break }
37 eof { break }
38 }
39 }
40 }
41
42 # This was intended to do any cleanup necessary. It kinda looks like it
43 # isn't needed, but just in case, please keep it in for now.
44 objdump_finish
45
46 # Did we find what we were looking for? If not, flunk it.
47 if [expr $x==1] then { pass $testname } else { fail $testname }
48 }
49
50 proc do_relocation_reduction_tests {} {
51 set testname "relocreduce.s: Test relocation reductions (part 2)"
52 set x 0
53
54 if [gas_test_old "relocreduce.s" "" "Relocation reductions (part1)"] then {
55 objdump_start_no_subdir "a.out" "-r"
56
57 # Check to make sure relocations involving procedure labels
58 # are not reduced to a relocation involving some other symbol.
59 # Doing so makes generating parameter relocation stubs impossible.
60 while 1 {
61 expect {
62 -re "^00000004\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
63 { set x [expr $x+1] }
64 -re "^00000014\[^\n\]*PCREL_CALL\[^\n\]*foo\[^\n\]*\n"
65 { set x [expr $x+1] }
66 -re "\[^\n\]*\n" { }
67 timeout { error "timeout\n"; break }
68 eof { break }
69 }
70 }
71 }
72
73 # This was intended to do any cleanup necessary. It kinda looks like it
74 # isn't needed, but just in case, please keep it in for now.
75 objdump_finish
76
77 # Did we find what we were looking for? If not, flunk it.
78 if [expr $x==2] then { pass $testname } else { fail $testname }
79 }
80
81 proc do_ble_mode_selector_test {} {
82 set testname "blebug2.s: blebug2"
83 set x 0
84
85 gas_start "blebug2.s" "-al"
86
87 # GAS uses too many bits on the BLE instruction.
88 while 1 {
89 expect {
90 -re "^ +\[0-9\]+ 0000 20202801\[^\n\]*\n" { set x [expr $x+1] }
91 -re "^ +\[0-9\]+ 0004 E420E008\[^\n\]*\n" { set x [expr $x+1] }
92 -re "\[^\n\]*\n" { }
93 timeout { error "timeout\n"; break }
94 eof { break }
95 }
96 }
97
98 # This was intended to do any cleanup necessary. It kinda looks like it
99 # isn't needed, but just in case, please keep it in for now.
100 gas_finish
101
102 # Did we find what we were looking for? If not, flunk it.
103 if [expr $x==2] then { pass $testname } else { fail $testname }
104 }
105
106 proc do_plabel_relocation_test {} {
107 set testname "plabelbug.s: Old gas-1.36 plabel bug (part 2)"
108 set x 0
109
110 if [gas_test_old "plabelbug.s" "" "Old gas-1.36 plabel bug (part 1)"] {
111 objdump_start_no_subdir "a.out" "-r"
112
113 # Check that we make PLABEL relocation entries when they're needed.
114 while 1 {
115 expect {
116 -re "^\[04\]0000000\[^\n\]*PLABEL\[^\n\]*\n"
117 { set x [expr $x+1] }
118 -re "^\[04\]0000004\[^\n\]*PLABEL\[^\n\]*\n"
119 { set x [expr $x+1] }
120 -re "\[^\n\]*\n" { }
121 timeout { error "timeout\n"; break }
122 eof { break }
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 }
134
135 proc do_selector_scope_test {} {
136 set testname "selectorbug.s: Test scope of field selector"
137 set x 0
138
139 if [gas_test_old "selectorbug.s" "" "Test scope of field selector (part 1)"] {
140 objdump_start_no_subdir "a.out" "-r"
141
142 # Check to make sure the relocation entry after the plabel is correct.
143 # If an old field selector was incorrectly "carried" over, then
144 # this test will fail.
145 if [istarget hppa*-*-osf] then {
146 while 1 {
147 expect {
148 -re "^00000014\[^\n\]*HPPA_32\[^\n\]*\n"
149 { set x 1 }
150 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
151 { set x 0 }
152 -re "\[^\n\]*\n" { }
153 timeout { error "timeout\n"; break }
154 eof { break }
155 }
156 }
157 } else {
158 while 1 {
159 expect {
160 -re "^00000014\[^\n\]*DATA_ONE\[^\n\]*\n"
161 { set x 1 }
162 -re "^00000014\[^\n\]*PLABEL\[^\n\]*foo\[^\n\]*\n"
163 { set x 0 }
164 -re "\[^\n\]*\n" { }
165 timeout { error "timeout\n"; break }
166 eof { break }
167 }
168 }
169 }
170
171 # This was intended to do any cleanup necessary. It kinda looks like it
172 # isn't needed, but just in case, please keep it in for now.
173 objdump_finish
174
175 # Did we find what we were looking for? If not, flunk it.
176 if [expr $x==1] then { pass $testname } else { fail $testname }
177 }
178 }
179
180 proc do_local_label_as_operand_test {} {
181 set testname "labelopbug.s: Test local label as operand (non-branching)"
182 set x 0
183
184 if [gas_test_old "labelopbug.s" "" "Local label as operand (part 1)"] {
185 objdump_start_no_subdir "a.out" "-r"
186
187 # Check to make sure we handle difference of local lables as an operand
188 # to a non-branching instruction correctly.
189 while 1 {
190 expect {
191 -re "^0000002c\[^\n\]*0x00000024\[^\n\]*\n"
192 { set x [expr $x+1] }
193 -re "^00000030\[^\n\]*0x00000024\[^\n\]*\n"
194 { set x [expr $x+1] }
195 -re "\[^\n\]*\n" { }
196 timeout { error "timeout\n"; break }
197 eof { break }
198 }
199 }
200
201 # This was intended to do any cleanup necessary. It kinda looks like it
202 # isn't needed, but just in case, please keep it in for now.
203 objdump_finish
204
205 # Did we find what we were looking for? If not, flunk it.
206 if [expr $x==2] then { pass $testname } else { fail $testname }
207 }
208 }
209
210 proc do_exit_relocation_test {} {
211 set testname "exitbug.s: Test for bogus R_EXIT relocation (part 2)"
212 set x 0
213
214 # Elf (osf) does not use ENTRY/EXIT relocations.
215 # I guess we could look at the unwind subspaces it builds...
216 if [istarget hppa*-*-osf*] then {
217 return;
218 }
219
220 if [gas_test_old "exitbug.s" "" "Test for bogus R_EXIT relocation (part 1)"] {
221 objdump_start_no_subdir "a.out" "-r"
222
223 # Note that a match here is really a FAILURE!
224 while 1 {
225 expect {
226 -re "^00000000\[^\n\]*R_EXIT\[^\n\]*\n"
227 { set x [expr $x+1] }
228 -re "\[^\n\]*\n" { }
229 timeout { error "timeout\n"; break }
230 eof { break }
231 }
232 }
233
234 # This was intended to do any cleanup necessary. It kinda looks like it
235 # isn't needed, but just in case, please keep it in for now.
236 objdump_finish
237
238 # Did we find what we were looking for? If not, flunk it.
239 if [expr $x==0] then { pass $testname } else { fail $testname }
240 }
241 }
242
243 if [istarget hppa*-*-*] then {
244 # Make sure we put the right relocation entry on a BLE instruction.
245 do_ble_relocation_test
246
247 # Make sure relocation reductions are not too agressive about
248 # adjusting relocations against some symbols.
249 do_relocation_reduction_tests
250
251 # Check that mode selectors on a ble instruction actually work.
252 do_ble_mode_selector_test
253
254 # 1.36 simply didn't generate all the plabels it should have. Make
255 # sure gas-2 does.
256 do_plabel_relocation_test
257
258 # Make sure a field selector only effects the current instruction
259 # or assembler directive.
260 do_selector_scope_test
261
262 # This should really generate a relocation. It would make life much
263 # easier on the optimizing linker. Until then just make sure the
264 # difference is computed correctly.
265 do_local_label_as_operand_test
266
267 # GAS2 incorrectly generated R_EXIT relocations when .exit directives
268 # were not in the source code.
269 do_exit_relocation_test
270 }