]>
Commit | Line | Data |
---|---|---|
a2c58332 | 1 | # Copyright (C) 1994-2022 Free Software Foundation, Inc. |
252b5132 RH |
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 | |
32866df7 | 5 | # the Free Software Foundation; either version 3 of the License, or |
252b5132 | 6 | # (at your option) any later version. |
21c40443 | 7 | # |
252b5132 RH |
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. | |
21c40443 | 12 | # |
252b5132 RH |
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 | |
b43b5d5f | 15 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
252b5132 RH |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-dejagnu@prep.ai.mit.edu | |
19 | ||
20 | # Written by Ian Lance Taylor <ian@cygnus.com> | |
21 | ||
22 | if ![is_remote host] { | |
23 | if {[which $OBJCOPY] == 0} then { | |
24 | perror "$OBJCOPY does not exist" | |
25 | return | |
26 | } | |
27 | } | |
28 | ||
29 | send_user "Version [binutil_version $OBJCOPY]" | |
30 | ||
252b5132 | 31 | if ![is_remote host] { |
8d263650 BE |
32 | set tempfile tmpdir/bintest.o |
33 | set copyfile tmpdir/copy | |
252b5132 RH |
34 | } else { |
35 | set tempfile [remote_download host tmpdir/bintest.o] | |
36 | set copyfile copy | |
37 | } | |
38 | ||
39 | # Test that objcopy does not modify a file when copying it. | |
1fafefd5 | 40 | # "object" or "executable" values for type are supported. |
252b5132 | 41 | |
1fafefd5 | 42 | proc objcopy_test {testname srcfile type asflags ldflags} { |
64bb95af L |
43 | global OBJCOPY |
44 | global OBJCOPYFLAGS | |
45 | global srcdir | |
46 | global subdir | |
47 | global tempfile | |
48 | global copyfile | |
1fafefd5 JL |
49 | set t_tempfile $tempfile |
50 | set t_copyfile ${copyfile}.o | |
252b5132 | 51 | |
1fafefd5 JL |
52 | if { $type != "object" && $type != "executable" } { |
53 | error "objcopy_test accepts only \"object\" or \"executable\" values for type" | |
54 | } | |
55 | ||
56 | if {![binutils_assemble_flags $srcdir/$subdir/${srcfile} $t_tempfile "$asflags"]} then { | |
17e04eff | 57 | unsupported "objcopy $type ($testname)" |
1fafefd5 | 58 | remote_file host delete $t_tempfile |
64bb95af | 59 | return |
252b5132 | 60 | } |
252b5132 | 61 | |
6a81c59b | 62 | set xflags "" |
1fafefd5 JL |
63 | if { $type == "executable" } { |
64 | global LD | |
65 | # Check that LD exists | |
66 | if {[which $LD] == 0} then { | |
67 | untested "objcopy $type ($testname)" | |
68 | return | |
69 | } | |
6a81c59b | 70 | |
1fafefd5 JL |
71 | # Use tempfile and copyfile without the .o extension for executable files |
72 | set t_tempfile [string range $tempfile 0 end-2] | |
73 | set t_copyfile $copyfile | |
74 | set got [binutils_run $LD "$tempfile -o $t_tempfile $ldflags"] | |
75 | if { ![string equal "" $got] } then { | |
17e04eff | 76 | unsupported "objcopy $type ($testname)" |
1fafefd5 JL |
77 | return |
78 | } | |
00386881 | 79 | set xflags "--preserve-dates" |
985e0264 | 80 | sleep 1 |
1fafefd5 JL |
81 | } |
82 | ||
6a81c59b | 83 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $xflags $t_tempfile $t_copyfile"] |
64bb95af | 84 | |
21c40443 | 85 | if ![string equal "" $got] then { |
64ec7c3f | 86 | send_log "$got\n" |
1fafefd5 | 87 | fail "objcopy $type ($testname)" |
252b5132 | 88 | } else { |
1fafefd5 JL |
89 | send_log "cmp $t_tempfile $t_copyfile\n" |
90 | verbose "cmp $t_tempfile $t_copyfile" | |
64bb95af | 91 | if [is_remote host] { |
1fafefd5 JL |
92 | set src1 tmpdir/bintest |
93 | set src2 tmpdir/copy | |
94 | remote_upload host $t_tempfile $src1 | |
95 | remote_upload host $t_copyfile $src2 | |
64bb95af | 96 | } else { |
1fafefd5 JL |
97 | set src1 $t_tempfile |
98 | set src2 $t_copyfile | |
64bb95af L |
99 | } |
100 | set status [remote_exec build cmp "${src1} ${src2}"] | |
101 | set exec_output [lindex $status 1] | |
102 | set exec_output [prune_warnings $exec_output] | |
103 | ||
21c40443 | 104 | if [string equal "" $exec_output] then { |
1fafefd5 | 105 | pass "objcopy $type ($testname)" |
985e0264 AM |
106 | if { $type == "executable" } { |
107 | set dir [file dirname $t_copyfile] | |
108 | set f2 [file tail $t_copyfile] | |
109 | set status [remote_exec host find "$dir -name $f2 -newer $t_tempfile -print"] | |
110 | set exec_output [lindex $status 1] | |
111 | if [string equal "" $exec_output] then { | |
112 | pass "objcopy $type ($testname) timestamp" | |
113 | } else { | |
114 | fail "objcopy $type ($testname) timestamp" | |
115 | } | |
116 | } | |
64bb95af L |
117 | } else { |
118 | send_log "$exec_output\n" | |
119 | verbose "$exec_output" 1 | |
252b5132 | 120 | |
64bb95af L |
121 | # On OSF/1, this succeeds with gas and fails with /bin/as. |
122 | setup_xfail "alpha*-*-osf*" | |
252b5132 | 123 | |
1fafefd5 | 124 | fail "objcopy $type ($testname)" |
64bb95af | 125 | } |
252b5132 RH |
126 | } |
127 | } | |
128 | ||
6a81c59b AM |
129 | setup_xfail "hppa*-*-*" |
130 | setup_xfail "sh-*-coff*" | |
131 | setup_xfail "tic54x-*-*" | |
132 | clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*" | |
0a6a8b59 | 133 | clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*" |
1fafefd5 | 134 | objcopy_test "simple copy" bintest.s object "" "" |
64bb95af | 135 | |
37d0d091 JH |
136 | # Test verilog data width |
137 | proc objcopy_test_verilog {testname} { | |
138 | global OBJCOPY | |
139 | global OBJCOPYFLAGS | |
140 | global srcdir | |
141 | global subdir | |
142 | global copyfile | |
143 | set binfile tmpdir/verilogtest.o | |
144 | set verilog tmpdir/verilog | |
145 | ||
146 | set got [binutils_assemble $srcdir/$subdir/verilogtest.s $binfile] | |
147 | if {![binutils_assemble $srcdir/$subdir/verilogtest.s $binfile]} then { | |
17e04eff | 148 | unsupported "objcopy ($testname)" |
37d0d091 JH |
149 | return |
150 | } | |
151 | ||
152 | set got [binutils_run $OBJCOPY "-O verilog $binfile $verilog"] | |
153 | if ![string equal "" $got] then { | |
154 | fail "objcopy ($testname)" | |
155 | } | |
156 | ||
157 | set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width 0 $binfile $verilog-0.hex"] | |
6ef35c04 | 158 | if ![regexp "error: verilog data width must be 1, 2, 4, 8 or 16" $got] then { |
37d0d091 JH |
159 | fail "objcopy ($testname 0) {$got}" |
160 | } else { | |
161 | pass "objcopy ($testname 0)" | |
162 | } | |
163 | ||
6ef35c04 | 164 | foreach width {1 2} { |
37d0d091 JH |
165 | set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width $width $binfile $verilog-$width.hex"] |
166 | if ![string equal "" $got] then { | |
167 | fail "objcopy ($testname $width)" | |
168 | } | |
169 | send_log "regexp_diff $verilog-$width.hex $srcdir/$subdir/verilog-$width.hex\n" | |
170 | if {! [regexp_diff "$verilog-$width.hex" "$srcdir/$subdir/verilog-$width.hex"]} { | |
171 | pass "objcopy ($testname $width)" | |
172 | } else { | |
173 | fail "objcopy ($testname $width)" | |
174 | } | |
175 | } | |
6ef35c04 NC |
176 | |
177 | # 16-bit little-endian targets fail the following tests because the | |
178 | # verilog backend does not convert from 16-bits to 32-bits before it | |
179 | # converts from internal format to little endian format. | |
180 | if { [istarget tic54*-*-*] || [istarget pdp11-*-*] } { | |
181 | untested "verilog width-4 and width-8 tests" | |
182 | return | |
183 | } | |
184 | ||
185 | foreach width {4 8} { | |
186 | set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width $width $binfile $verilog-$width.hex"] | |
187 | if ![string equal "" $got] then { | |
188 | fail "objcopy ($testname $width)" | |
189 | } | |
190 | send_log "regexp_diff $verilog-$width.hex $srcdir/$subdir/verilog-$width.hex\n" | |
191 | if {! [regexp_diff "$verilog-$width.hex" "$srcdir/$subdir/verilog-$width.hex"]} { | |
192 | pass "objcopy ($testname $width)" | |
193 | } else { | |
194 | fail "objcopy ($testname $width)" | |
195 | } | |
196 | } | |
197 | ||
198 | # Test generating endian correct output. | |
199 | set testname "objcopy (verilog output endian-ness == input endian-ness)" | |
200 | set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width 4 $binfile $verilog-I4.hex"] | |
201 | if ![string equal "" $got] then { | |
202 | fail $testname | |
203 | } | |
204 | send_log "regexp_diff $verilog-I4.hex $srcdir/$subdir/verilog-I4.hex\n" | |
205 | if {! [regexp_diff "$verilog-I4.hex" "$srcdir/$subdir/verilog-I4.hex"]} { | |
206 | pass $testname | |
207 | } else { | |
208 | fail $testname | |
209 | } | |
37d0d091 JH |
210 | } |
211 | ||
212 | objcopy_test_verilog "verilog data width" | |
213 | ||
96037eb0 NC |
214 | if { [file exists $tempfile] } { |
215 | # Test reversing bytes in a section. | |
9e48b4c6 | 216 | |
96037eb0 NC |
217 | set reversed ${tempfile}-reversed |
218 | set sect_names [get_standard_section_names] | |
219 | if { $sect_names != "" } { | |
9e7ed8b0 JDA |
220 | if { [istarget hppa*-*-hpux*] } { |
221 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j \$PRIVATE\$ -j [lindex $sect_names 1] --reverse-bytes=4 $tempfile $reversed"] | |
222 | } else { | |
223 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j [lindex $sect_names 1] --reverse-bytes=4 $tempfile $reversed"] | |
224 | } | |
96037eb0 NC |
225 | } else { |
226 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j .data --reverse-bytes=4 $tempfile $reversed"] | |
9e48b4c6 NC |
227 | } |
228 | ||
96037eb0 NC |
229 | if ![string equal "" $got] then { |
230 | fail "objcopy --reverse-bytes" | |
231 | } else { | |
232 | if [is_remote host] { | |
233 | remote_upload host ${reversed} tmpdir/copy-reversed.o | |
234 | set reversed tmpdir/copy-reversed.o | |
235 | } | |
9e48b4c6 | 236 | |
96037eb0 NC |
237 | set origdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $tempfile"] |
238 | set revdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $reversed"] | |
9e48b4c6 | 239 | |
96037eb0 NC |
240 | set want "^ \[0-9\]+ (\[0-9\]+)" |
241 | set found_orig [regexp -lineanchor $want $origdata -> origdata] | |
242 | set found_rev [regexp -lineanchor $want $revdata -> revdata] | |
8941d5e8 | 243 | |
96037eb0 | 244 | if {$found_orig == 0 || $found_rev == 0} then { |
96037eb0 NC |
245 | fail "objcopy --reverse-bytes" |
246 | } else { | |
247 | scan $origdata "%2x%2x%2x%2x" b1 b2 b3 b4 | |
248 | scan $revdata "%2x%2x%2x%2x" c4 c3 c2 c1 | |
249 | ||
250 | if {$b1 == $c1 && $b2 == $c2 && $b3 == $c3 && $b4 == $c4} then { | |
251 | pass "objcopy --reverse-bytes" | |
252 | } else { | |
253 | fail "objcopy --reverse-bytes" | |
254 | } | |
255 | } | |
9e48b4c6 NC |
256 | } |
257 | } | |
258 | ||
b7dd81f7 NC |
259 | # Test interleaved copy of multiple byte width |
260 | ||
261 | set sequence_file sequence_file | |
262 | set file [open ${sequence_file} w] | |
263 | puts ${file} "12345678" | |
264 | close ${file} | |
265 | ||
266 | if [is_remote host] { | |
267 | remote_upload host ${sequence_file} tmpdir/sequence_file | |
268 | set sequence_file tmpdir/sequence_file | |
269 | } | |
270 | ||
271 | set got [binutils_run $OBJCOPY "-I binary -i 4 -b 0 --interleave-width 2 ${sequence_file} ${copyfile}"] | |
272 | ||
21c40443 | 273 | if ![string equal "" $got] then { |
b7dd81f7 NC |
274 | fail "objcopy -i --interleave-width" |
275 | } else { | |
276 | if [is_remote host] { | |
277 | remote_upload host ${copyfile} tmpdir/interleave_output | |
278 | set interleave_output tmpdir/interleave_output | |
279 | } else { | |
280 | set interleave_output ${copyfile} | |
281 | } | |
282 | ||
283 | set file [open ${interleave_output} r] | |
284 | gets $file line | |
285 | send_log "$line\n" | |
286 | verbose $line | |
287 | ||
21c40443 | 288 | if ![string equal "1256" $line] then { |
b7dd81f7 NC |
289 | fail "objcopy -i --interleave-width" |
290 | } | |
291 | pass "objcopy -i --interleave-width" | |
292 | ||
293 | close $file | |
294 | } | |
295 | ||
252b5132 RH |
296 | # Test generating S records. |
297 | ||
96037eb0 NC |
298 | if { [file exists $tempfile] } { |
299 | # We make the srec filename 8.3 compatible. Note that the header string | |
300 | # matched against depends on the name of the file. Ugh. | |
252b5132 | 301 | |
252b5132 | 302 | if [is_remote host] { |
96037eb0 NC |
303 | set srecfile copy.sre |
304 | set header_string S00B0000636F70792E737265C1 | |
305 | } else { | |
306 | set srecfile ${copyfile}.srec | |
307 | set header_string S0130000746D706469722F636F70792E7372656397 | |
252b5132 | 308 | } |
252b5132 | 309 | |
96037eb0 NC |
310 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${srecfile}"] |
311 | ||
312 | if ![string equal "" $got] then { | |
252b5132 RH |
313 | fail "objcopy -O srec" |
314 | } else { | |
96037eb0 NC |
315 | if [is_remote host] { |
316 | remote_upload host ${srecfile} tmpdir/copy.srec | |
317 | set srecfile tmpdir/copy.srec | |
252b5132 | 318 | } |
96037eb0 NC |
319 | set file [open ${srecfile} r] |
320 | ||
321 | # The first S record is fixed by the file name we are using. | |
322 | gets $file line | |
252b5132 RH |
323 | send_log "$line\n" |
324 | verbose $line | |
96037eb0 NC |
325 | if ![regexp "$header_string.*" $line] { |
326 | send_log "bad header\n" | |
252b5132 RH |
327 | fail "objcopy -O srec" |
328 | } else { | |
96037eb0 NC |
329 | while {[gets $file line] != -1 \ |
330 | && [regexp "^S\[123\]\[0-9a-fA-F\]+\[\r\n\]*$" $line]} { | |
252b5132 RH |
331 | send_log "$line\n" |
332 | verbose $line | |
96037eb0 NC |
333 | set line "**EOF**" |
334 | } | |
335 | send_log "$line\n" | |
336 | verbose $line | |
337 | if ![regexp "^S\[789\]\[0-9a-fA-F\]+\[\r\n\]*$" $line] then { | |
338 | send_log "bad trailer\n" | |
252b5132 RH |
339 | fail "objcopy -O srec" |
340 | } else { | |
96037eb0 NC |
341 | if {[gets $file line] != -1} then { |
342 | send_log "garbage at end\n" | |
343 | send_log "$line\n" | |
344 | verbose $line | |
252b5132 RH |
345 | fail "objcopy -O srec" |
346 | } else { | |
96037eb0 NC |
347 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${srecfile}"] |
348 | if ![regexp "file format srec" $got] then { | |
349 | send_log "objdump failed\n" | |
350 | fail "objcopy -O srec" | |
351 | } else { | |
352 | pass "objcopy -O srec" | |
353 | } | |
252b5132 RH |
354 | } |
355 | } | |
356 | } | |
252b5132 | 357 | |
96037eb0 NC |
358 | close $file |
359 | } | |
252b5132 RH |
360 | } |
361 | ||
362 | # Test setting and adjusting the start address. We only test this | |
363 | # while generating S records, because we may not be able to set the | |
364 | # start address for other object file formats, and the S record case | |
365 | # is the only useful one anyhow. | |
366 | ||
367 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $tempfile"] | |
368 | if ![regexp "start address (\[0-9a-fA-FxX\]+)" $got all origstart] then { | |
369 | perror "objdump can not recognize bintest.o" | |
370 | set origstart "" | |
371 | } else { | |
627fe3fb | 372 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --set-start 0x7654 $tempfile ${copyfile}.srec"] |
21c40443 | 373 | if ![string equal "" $got] then { |
252b5132 RH |
374 | fail "objcopy --set-start" |
375 | } else { | |
376 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"] | |
377 | if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then { | |
378 | fail "objcopy --set-start" | |
379 | } else { | |
380 | if {$srecstart != 0x7654} then { | |
381 | send_log "$srecstart != 0x7654\n" | |
382 | fail "objcopy --set-start" | |
383 | } else { | |
384 | pass "objcopy --set-start" | |
385 | } | |
386 | } | |
387 | } | |
388 | ||
627fe3fb | 389 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-start 0x123 $tempfile ${copyfile}.srec"] |
21c40443 | 390 | if ![string equal "" $got] then { |
252b5132 RH |
391 | fail "objcopy --adjust-start" |
392 | } else { | |
393 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"] | |
394 | if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then { | |
395 | fail "objcopy --adjust-start" | |
396 | } else { | |
397 | if {$srecstart != $origstart + 0x123} then { | |
398 | send_log "$srecstart != $origstart + 0x123\n" | |
399 | fail "objcopy --adjust-start" | |
400 | } else { | |
401 | pass "objcopy --adjust-start" | |
402 | } | |
403 | } | |
404 | } | |
405 | } | |
406 | ||
407 | # Test adjusting the overall VMA, and adjusting the VMA of a | |
408 | # particular section. We again only test this when generating S | |
409 | # records. | |
410 | ||
411 | set low "" | |
412 | set lowname "" | |
413 | ||
414 | set headers [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $tempfile"] | |
415 | ||
416 | set headers_regexp "\[ 0-9\]+(\[^ \]+)\[ \]*(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+2\[*\]\[*\]\[0-9\]+(.*)" | |
417 | ||
418 | set got $headers | |
419 | while {[regexp $headers_regexp $got all name size vma rest]} { | |
420 | set vma 0x$vma | |
421 | set size 0x$size | |
422 | if {$size != 0} { | |
423 | if {$low == "" || $vma < $low} { | |
424 | set low $vma | |
425 | set lowname $name | |
426 | } | |
427 | } | |
428 | set got $rest | |
429 | } | |
430 | ||
431 | if {$low == "" || $origstart == ""} then { | |
432 | perror "objdump can not recognize bintest.o" | |
433 | } else { | |
627fe3fb | 434 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-vma 0x123 $tempfile ${copyfile}.srec"] |
21c40443 | 435 | if ![string equal "" $got] then { |
252b5132 RH |
436 | fail "objcopy --adjust-vma" |
437 | } else { | |
438 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -fh ${copyfile}.srec"] | |
439 | set want "file format srec.*start address\[ \]*(\[0-9a-fA-FxX\]+).*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)" | |
440 | if ![regexp $want $got all start vma] then { | |
441 | fail "objcopy --adjust-vma" | |
442 | } else { | |
443 | set vma 0x$vma | |
444 | if {$vma != $low + 0x123} then { | |
445 | send_log "$vma != $low + 0x123\n" | |
446 | fail "objcopy --adjust-vma" | |
447 | } else { | |
448 | if {$start != $origstart + 0x123} then { | |
449 | send_log "$start != $origstart + 0x123\n" | |
450 | fail "objcopy --adjust-vma" | |
451 | } else { | |
452 | pass "objcopy --adjust-vma" | |
453 | } | |
454 | } | |
455 | } | |
456 | } | |
457 | ||
458 | set arg "" | |
459 | set got $headers | |
460 | while {[regexp $headers_regexp $got all name size vma rest]} { | |
461 | set vma 0x$vma | |
462 | if {$vma == $low} then { | |
463 | set arg "$arg --adjust-section-vma $name+4" | |
464 | } | |
465 | set got $rest | |
466 | } | |
467 | ||
627fe3fb | 468 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $arg $tempfile ${copyfile}.srec"] |
21c40443 | 469 | if ![string equal "" $got] then { |
252b5132 RH |
470 | fail "objcopy --adjust-section-vma +" |
471 | } else { | |
472 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"] | |
473 | set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)" | |
474 | if ![regexp $want $got all vma] then { | |
475 | fail "objcopy --adjust-section-vma +" | |
476 | } else { | |
477 | set vma 0x$vma | |
478 | if {$vma != $low + 4} then { | |
479 | send_log "$vma != $low + 4\n" | |
480 | fail "objcopy --adjust-section-vma +" | |
481 | } else { | |
482 | pass "objcopy --adjust-section-vma +" | |
483 | } | |
484 | } | |
485 | } | |
486 | ||
487 | regsub -all "\\+4" $arg "=[expr $low + 4]" argeq | |
627fe3fb | 488 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $argeq $tempfile ${copyfile}.srec"] |
21c40443 | 489 | if ![string equal "" $got] then { |
252b5132 RH |
490 | fail "objcopy --adjust-section-vma =" |
491 | } else { | |
492 | set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"] | |
493 | set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)" | |
494 | if ![regexp $want $got all vma] then { | |
495 | fail "objcopy --adjust-section-vma =" | |
496 | } else { | |
497 | set vma 0x$vma | |
498 | if {$vma != $low + 4} then { | |
499 | send_log "$vma != $low + 4\n" | |
500 | fail "objcopy --adjust-section-vma =" | |
501 | } else { | |
502 | pass "objcopy --adjust-section-vma =" | |
503 | } | |
504 | } | |
505 | } | |
506 | } | |
507 | ||
508 | # Test stripping an object. | |
509 | ||
510 | proc strip_test { } { | |
1983fbac | 511 | global AR |
252b5132 RH |
512 | global CC |
513 | global STRIP | |
514 | global STRIPFLAGS | |
515 | global NM | |
516 | global NMFLAGS | |
517 | global srcdir | |
518 | global subdir | |
28902555 | 519 | global READELF |
252b5132 RH |
520 | |
521 | set test "strip" | |
522 | ||
523 | if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { | |
524 | untested $test | |
525 | return | |
526 | } | |
527 | ||
28902555 BS |
528 | set osabi_fail "false" |
529 | if [is_elf_format] { | |
530 | verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.in" | |
531 | set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.in"] | |
532 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 533 | fail "$test preserving OS/ABI" |
28902555 BS |
534 | set osabi_fail "true" |
535 | } else { | |
536 | verbose -log "grep OS/ABI tmpdir/osabi.in" | |
537 | catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in | |
538 | } | |
539 | } | |
540 | ||
252b5132 | 541 | if [is_remote host] { |
1983fbac | 542 | set archive libstrip.a |
8d263650 | 543 | set objfile [remote_download host tmpdir/testprog.o] |
1983fbac L |
544 | remote_file host delete $archive |
545 | } else { | |
546 | set archive tmpdir/libstrip.a | |
547 | set objfile tmpdir/testprog.o | |
548 | } | |
549 | ||
550 | remote_file build delete tmpdir/libstrip.a | |
551 | ||
552 | set exec_output [binutils_run $AR "rc $archive ${objfile}"] | |
7dd36a6f | 553 | set exec_output [prune_warnings $exec_output] |
21c40443 | 554 | if ![string equal "" $exec_output] { |
1983fbac | 555 | fail $test |
21c40443 | 556 | unresolved "$test preserving OS/ABI" |
1983fbac L |
557 | return |
558 | } | |
559 | ||
8648f88f | 560 | set exec_output [binutils_run $STRIP "-g $archive"] |
7dd36a6f | 561 | set exec_output [prune_warnings $exec_output] |
21c40443 | 562 | if ![string equal "" $exec_output] { |
8648f88f | 563 | fail $test |
21c40443 | 564 | unresolved "$test preserving OS/ABI" |
8648f88f L |
565 | return |
566 | } | |
567 | ||
1983fbac | 568 | set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"] |
7dd36a6f | 569 | set exec_output [prune_warnings $exec_output] |
21c40443 | 570 | if ![string equal "" $exec_output] { |
1983fbac | 571 | fail $test |
21c40443 | 572 | unresolved "$test preserving OS/ABI" |
1983fbac L |
573 | return |
574 | } | |
575 | ||
28902555 BS |
576 | if { $osabi_fail != "true" && [is_elf_format] } { |
577 | verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.out" | |
578 | set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.out"] | |
579 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 580 | fail "$test preserving OS/ABI" |
28902555 BS |
581 | } else { |
582 | verbose -log "grep OS/ABI tmpdir/osabi.out" | |
583 | catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out | |
584 | if { "$osabi_in" == "$osabi_out" } { | |
585 | pass "$test preserving OS/ABI" | |
586 | } else { | |
587 | fail "$test preserving OS/ABI" | |
588 | } | |
589 | } | |
590 | } | |
591 | ||
1983fbac L |
592 | if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { |
593 | untested $test | |
594 | return | |
595 | } | |
596 | ||
597 | if [is_remote host] { | |
8d263650 | 598 | set objfile [remote_download host tmpdir/testprog.o] |
252b5132 RH |
599 | } else { |
600 | set objfile tmpdir/testprog.o | |
601 | } | |
602 | ||
603 | set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"] | |
7dd36a6f | 604 | set exec_output [prune_warnings $exec_output] |
21c40443 | 605 | if ![string equal "" $exec_output] { |
252b5132 RH |
606 | fail $test |
607 | return | |
608 | } | |
609 | ||
610 | set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"] | |
7dd36a6f | 611 | set exec_output [prune_warnings $exec_output] |
68a4c073 | 612 | if ![string match "*: no symbols*" $exec_output] { |
252b5132 RH |
613 | fail $test |
614 | return | |
615 | } | |
616 | ||
617 | pass $test | |
618 | } | |
619 | ||
620 | strip_test | |
621 | ||
622 | # Test stripping an object file with saving a symbol | |
623 | ||
624 | proc strip_test_with_saving_a_symbol { } { | |
625 | global CC | |
626 | global STRIP | |
627 | global STRIPFLAGS | |
628 | global NM | |
629 | global NMFLAGS | |
630 | global srcdir | |
631 | global subdir | |
632 | ||
633 | set test "strip with saving a symbol" | |
634 | ||
635 | if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { | |
636 | untested $test | |
637 | return | |
638 | } | |
639 | ||
640 | if [is_remote host] { | |
8d263650 | 641 | set objfile [remote_download host tmpdir/testprog.o] |
252b5132 RH |
642 | } else { |
643 | set objfile tmpdir/testprog.o | |
644 | } | |
645 | ||
646 | set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"] | |
7dd36a6f | 647 | set exec_output [prune_warnings $exec_output] |
21c40443 | 648 | if ![string equal "" $exec_output] { |
252b5132 RH |
649 | fail $test |
650 | return | |
651 | } | |
652 | ||
653 | set exec_output [binutils_run $NM "$NMFLAGS $objfile"] | |
7dd36a6f | 654 | set exec_output [prune_warnings $exec_output] |
195fe636 | 655 | if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \ |
252b5132 RH |
656 | && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} { |
657 | fail $test | |
658 | return | |
659 | } | |
660 | ||
661 | pass $test | |
662 | } | |
663 | ||
664 | strip_test_with_saving_a_symbol | |
665 | ||
666 | # Build a final executable. | |
667 | ||
d4f5b5e2 AM |
668 | set exe [exeext] |
669 | set test_prog "testprog${exe}" | |
f8a7038a | 670 | |
252b5132 RH |
671 | proc copy_setup { } { |
672 | global srcdir | |
673 | global subdir | |
9a580d9a | 674 | global gcc_gas_flag |
f8a7038a | 675 | global test_prog |
72d4c02f | 676 | global host_triplet |
21c40443 | 677 | |
b5375c5d AM |
678 | if {[target_info exists needs_status_wrapper] && \ |
679 | [target_info needs_status_wrapper] != "0"} { | |
680 | set res [build_wrapper testglue.o] | |
681 | } else { | |
682 | set res "" | |
683 | } | |
8d263650 | 684 | set flags { debug } |
21c40443 | 685 | |
f1ac0afe | 686 | if { [istarget *-*-uclinux*] && ![istarget tic6x-*-*] && ![istarget arm*-*-uclinuxfdpiceabi] } { |
903b1f5b NS |
687 | return 1 |
688 | } | |
21c40443 | 689 | |
252b5132 | 690 | if { $res != "" } { |
8d263650 BE |
691 | lappend flags "additional_flags=[lindex $res 1]" |
692 | set add_libs "testglue.o" | |
252b5132 | 693 | } else { |
8d263650 | 694 | set add_libs "" |
252b5132 RH |
695 | } |
696 | ||
5940a93c TS |
697 | if { [istarget *-*-linux*] |
698 | || [istarget *-*-gnu*] } { | |
9a580d9a L |
699 | foreach i $gcc_gas_flag { |
700 | set flags "additional_flags=$i $flags" | |
701 | } | |
702 | } | |
f8a7038a | 703 | if { [target_compile "$srcdir/$subdir/testprog.c $add_libs" tmpdir/$test_prog executable $flags] != "" } { |
252b5132 RH |
704 | return 2 |
705 | } | |
706 | ||
8d263650 BE |
707 | set result [remote_load target tmpdir/$test_prog] |
708 | set status [lindex $result 0] | |
252b5132 RH |
709 | |
710 | if { $status != "pass" } { | |
72d4c02f | 711 | send_log "cannot run executable, status = ${status} on ${host_triplet}\n" |
21c40443 | 712 | return 3 |
252b5132 RH |
713 | } |
714 | ||
715 | return 0 | |
716 | } | |
717 | ||
718 | # Test copying an executable. | |
719 | ||
720 | proc copy_executable { prog flags test1 test2 } { | |
f8a7038a | 721 | global test_prog |
252b5132 RH |
722 | |
723 | if [is_remote host] { | |
8d263650 | 724 | set testfile [remote_download host tmpdir/$test_prog] |
252b5132 RH |
725 | set testcopy copyprog |
726 | } else { | |
f8a7038a | 727 | set testfile tmpdir/$test_prog |
252b5132 RH |
728 | set testcopy tmpdir/copyprog |
729 | } | |
8d263650 | 730 | remote_file host delete $testcopy |
252b5132 RH |
731 | |
732 | set exec_output [binutils_run $prog "$flags $testfile $testcopy"] | |
733 | ||
21c40443 | 734 | if ![string equal "" $exec_output] { |
252b5132 | 735 | fail $test1 |
21c40443 | 736 | if [string equal "" $test2] { |
0d063f63 AM |
737 | return |
738 | } | |
252b5132 RH |
739 | fail $test2 |
740 | return | |
741 | } | |
742 | ||
743 | if [is_remote host] { | |
744 | remote_upload host $testcopy tmpdir/copyprog | |
745 | } | |
746 | ||
f8a7038a | 747 | set status [remote_exec build "cmp" "tmpdir/$test_prog tmpdir/copyprog"] |
8d263650 | 748 | set exec_output [lindex $status 1] |
252b5132 | 749 | |
21c40443 | 750 | if [string equal "" $exec_output] then { |
252b5132 RH |
751 | pass $test1 |
752 | } else { | |
753 | send_log "$exec_output\n" | |
754 | verbose "$exec_output" | |
755 | ||
756 | # This will fail for many reasons. For example, it will most | |
757 | # likely fail if a non-GNU linker is used. Therefore, we do | |
758 | # not insist that it pass. If you are using an assembler and | |
759 | # linker based on the same BFD as objcopy, it is worth | |
760 | # investigating to see why this failure occurs. If we are | |
761 | # cross compiling, we assume that a GNU linker is being used, | |
762 | # and expect it to succeed. | |
763 | if {[isnative]} then { | |
764 | setup_xfail "*-*-*" | |
765 | } | |
766 | ||
9cc0123f | 767 | # This also fails for some mips targets. See elf32-mips.c |
252b5132 | 768 | # mips_elf_sym_is_global. |
9cc0123f AM |
769 | if { [is_bad_symtab] } then { |
770 | setup_xfail "*-*-*" | |
771 | } | |
252b5132 | 772 | |
11d47adc | 773 | setup_xfail "arm*-*-pe" |
88f14853 | 774 | setup_xfail "*-*-mingw*" |
899396fe | 775 | setup_xfail "*-*-cygwin*" |
21c40443 | 776 | |
252b5132 RH |
777 | fail $test1 |
778 | } | |
779 | ||
21c40443 | 780 | if [string equal "" $test2] { |
0d063f63 AM |
781 | return |
782 | } | |
783 | ||
252b5132 | 784 | set output [remote_load target tmpdir/copyprog] |
8d263650 | 785 | set status [lindex $output 0] |
252b5132 RH |
786 | if { $status != "pass" } { |
787 | fail $test2 | |
788 | } else { | |
789 | pass $test2 | |
790 | } | |
791 | } | |
792 | ||
793 | # Test stripping an executable | |
794 | ||
21c40443 | 795 | proc strip_executable { prog flags test1 test2 } { |
252b5132 RH |
796 | global NM |
797 | global NMFLAGS | |
28902555 | 798 | global READELF |
252b5132 | 799 | |
0fcc17f8 | 800 | remote_file build delete tmpdir/striprog |
252b5132 RH |
801 | remote_download build tmpdir/copyprog tmpdir/striprog |
802 | if [is_remote host] { | |
8d263650 | 803 | set copyfile [remote_download host tmpdir/striprog] |
252b5132 RH |
804 | } else { |
805 | set copyfile tmpdir/striprog | |
806 | } | |
807 | ||
28902555 BS |
808 | set osabi_fail "false" |
809 | if [is_elf_format] { | |
810 | verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.in" | |
811 | set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.in"] | |
812 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 813 | fail "$test1 preserving OS/ABI" |
28902555 BS |
814 | set osabi_fail "true" |
815 | } else { | |
816 | verbose -log "grep OS/ABI tmpdir/osabi.in" | |
817 | catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in | |
818 | } | |
819 | } | |
820 | ||
252b5132 | 821 | set exec_output [binutils_run $prog "$flags ${copyfile}"] |
21c40443 AM |
822 | if ![string equal "" $exec_output] { |
823 | fail $test1 | |
824 | if [string equal "" $test2] { | |
825 | return | |
826 | } | |
827 | fail $test2 | |
252b5132 RH |
828 | return |
829 | } | |
830 | ||
831 | if [is_remote host] { | |
8d263650 | 832 | remote_upload host ${copyfile} tmpdir/striprog |
252b5132 RH |
833 | } |
834 | ||
28902555 BS |
835 | if { $osabi_fail != "true" && [is_elf_format] } { |
836 | verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.out" | |
837 | set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.out"] | |
838 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 839 | fail "$test1 preserving OS/ABI" |
28902555 BS |
840 | } else { |
841 | verbose -log "grep OS/ABI tmpdir/osabi.out" | |
842 | catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out | |
843 | if { "$osabi_in" == "$osabi_out" } { | |
21c40443 | 844 | pass "$test1 preserving OS/ABI" |
28902555 | 845 | } else { |
21c40443 | 846 | fail "$test1 preserving OS/ABI" |
28902555 BS |
847 | } |
848 | } | |
849 | } | |
850 | ||
252b5132 | 851 | set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"] |
68a4c073 | 852 | if ![string match "*: no symbols*" $exec_output] { |
21c40443 | 853 | fail $test1 |
252b5132 RH |
854 | return |
855 | } | |
21c40443 AM |
856 | |
857 | if [string equal "" $test2] { | |
858 | return | |
859 | } | |
860 | ||
861 | set result [remote_load target tmpdir/striprog] | |
862 | set status [lindex $result 0] | |
863 | if { $status != "pass" } { | |
864 | fail $test2 | |
865 | return | |
866 | } | |
867 | ||
868 | pass $test2 | |
252b5132 RH |
869 | } |
870 | ||
871 | # Test stripping an executable with saving a symbol | |
872 | ||
21c40443 | 873 | proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } { |
252b5132 RH |
874 | global NM |
875 | global NMFLAGS | |
876 | ||
0fcc17f8 | 877 | remote_file build delete tmpdir/striprog |
252b5132 RH |
878 | remote_download build tmpdir/copyprog tmpdir/striprog |
879 | if [is_remote host] { | |
8d263650 | 880 | set copyfile [remote_download host tmpdir/striprog] |
252b5132 RH |
881 | } else { |
882 | set copyfile tmpdir/striprog | |
883 | } | |
884 | ||
885 | set exec_output [binutils_run $prog "$flags ${copyfile}"] | |
21c40443 AM |
886 | if ![string equal "" $exec_output] { |
887 | fail $test1 | |
888 | if [string equal "" $test2] { | |
889 | return | |
890 | } | |
891 | fail $test2 | |
252b5132 RH |
892 | return |
893 | } | |
894 | ||
252b5132 | 895 | set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"] |
edc45ab9 HPN |
896 | if { [istarget mmix-knuth-mmixware] } { |
897 | # Whenever there's a symbol in the mmo format, there's the symbol | |
898 | # Main, so remove it manually from the expected output for sake of | |
899 | # this test. | |
900 | ||
901 | # Using "" not {} to get the \n and \r translated. | |
902 | regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output | |
903 | } | |
904 | ||
adacfc81 JJ |
905 | if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \ |
906 | && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} { | |
21c40443 | 907 | fail $test1 |
252b5132 RH |
908 | return |
909 | } | |
21c40443 AM |
910 | |
911 | if [string equal "" $test2] { | |
912 | return | |
913 | } | |
914 | ||
915 | if [is_remote host] { | |
916 | remote_upload host ${copyfile} tmpdir/striprog | |
917 | } | |
918 | ||
919 | set result [remote_load target tmpdir/striprog] | |
920 | set status [lindex $result 0] | |
921 | if { $status != "pass" } { | |
922 | fail $test2 | |
923 | return | |
924 | } | |
925 | ||
926 | pass $test2 | |
252b5132 RH |
927 | } |
928 | ||
11701589 JK |
929 | # Test keeping only debug symbols of an executable |
930 | ||
931 | proc keep_debug_symbols_and_test_copy { prog1 flags1 test1 prog2 flags2 test2 } { | |
0fcc17f8 | 932 | remote_file build delete tmpdir/striprog |
11701589 JK |
933 | remote_download build tmpdir/copyprog tmpdir/striprog |
934 | if [is_remote host] { | |
935 | set copyfile [remote_download host tmpdir/striprog] | |
936 | } else { | |
937 | set copyfile tmpdir/striprog | |
938 | } | |
939 | ||
940 | set exec_output [binutils_run $prog1 "$flags1 ${copyfile}"] | |
21c40443 | 941 | if ![string equal "" $exec_output] { |
11701589 JK |
942 | fail $test1 |
943 | return | |
944 | } | |
945 | pass $test1 | |
946 | ||
947 | set exec_output [binutils_run $prog2 "$flags2 ${copyfile}"] | |
21c40443 | 948 | if ![string equal "" $exec_output] { |
11701589 JK |
949 | fail $test2 |
950 | return | |
951 | } | |
952 | pass $test2 | |
953 | } | |
954 | ||
63b9bbb7 | 955 | # Tests that in a debug only copy of a file the sections |
de194d85 | 956 | # headers whose types have been changed to NOBITS still |
63b9bbb7 NC |
957 | # retain their sh_link fields. |
958 | ||
959 | proc keep_debug_symbols_and_check_links { prog flags test } { | |
960 | global READELF | |
961 | ||
962 | remote_file build delete tmpdir/striprog | |
963 | remote_download build tmpdir/copyprog tmpdir/striprog | |
964 | if [is_remote host] { | |
965 | set copyfile [remote_download host tmpdir/striprog] | |
966 | } else { | |
967 | set copyfile tmpdir/striprog | |
968 | } | |
969 | ||
970 | set exec_output [binutils_run $prog "$flags ${copyfile}"] | |
21c40443 | 971 | if ![string equal "" $exec_output] { |
63b9bbb7 NC |
972 | fail $test |
973 | return | |
974 | } | |
975 | ||
976 | set got [binutils_run $READELF "-S --wide ${copyfile}"] | |
977 | ||
978 | set fails 0 | |
979 | # Regexp to match a section with NOBITS type and extract its name and sh_link fields | |
980 | while {[regexp \ | |
981 | {[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ ]+NOBITS[ ]+[0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9]+[ A]+([0-9]+)(.*)} \ | |
982 | $got all name link rest]} { | |
983 | set sh_link 0x$link | |
984 | if {$sh_link == 0} { | |
985 | # Only some NOBITS sections should have a non-zero sh_link field. | |
986 | # Look for them by name. | |
987 | verbose "NOBITS section .$name has a 0 sh_link field\n" | |
988 | switch $name { | |
989 | "rela.*" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
990 | "rel.*" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
991 | "hash" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
992 | "gnu_version" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
993 | "dynsym" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
994 | "gnu.version_r" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
995 | "dynamic" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
996 | "symtab" { set fails 1 ; send_log "Expected non-zero sh_link for .$name\n" } | |
997 | } | |
998 | } | |
999 | set got $rest | |
1000 | } | |
1001 | ||
1002 | if {$fails == 0} { | |
1003 | pass $test | |
1004 | } else { | |
1005 | fail $test | |
1006 | } | |
1007 | } | |
1008 | ||
5049d00e PY |
1009 | # For ELF relocatables, test that --only-keep-debug |
1010 | # marks non-debug output sections as NOBITS. | |
1011 | ||
1012 | proc keep_debug_symbols_for_elf_relocatable { prog flags test } { | |
1013 | global srcdir | |
1014 | global subdir | |
1015 | global READELF | |
1016 | ||
1017 | if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { | |
1018 | untested $test | |
1019 | return | |
1020 | } | |
1021 | ||
1022 | if [is_remote host] { | |
1023 | set relocatable [remote_download host tmpdir/testprog.o] | |
1024 | } else { | |
1025 | set relocatable tmpdir/testprog.o | |
1026 | } | |
1027 | ||
1028 | set non_debug_sections {} | |
1029 | set got [binutils_run $READELF "-S --wide ${relocatable}"] | |
1030 | while { [regexp \ | |
1031 | {[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ \t]+([A-Z]+)[ \t]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9]+[ \t]+([A-Z]*)[ \t]+[0-9]+(.*)} \ | |
1032 | $got all name type flag rest] } { | |
1033 | if { $type != "NOTE" && [regexp {[AG]} $flag] } { | |
1034 | lappend non_debug_sections $name | |
1035 | } | |
1036 | set got $rest | |
1037 | } | |
1038 | ||
1039 | set exec_output [binutils_run $prog "$flags ${relocatable}"] | |
1040 | if ![string equal "" $exec_output] { | |
1041 | fail $test | |
1042 | return | |
1043 | } | |
1044 | ||
1045 | set fails 0 | |
1046 | set got [binutils_run $READELF "-S --wide ${relocatable}"] | |
1047 | while { [regexp \ | |
1048 | {[^a-zA-Z]+([a-zA-Z0-9_\.]+)[ \t]+([A-Z]+)[ \t]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9]+[ \t]+[A-Z]*[ \t]+[0-9]+(.*)} \ | |
1049 | $got all name type rest] } { | |
1050 | if { [lsearch -exact $non_debug_sections $name] >= 0 && $type != "NOBITS" } { | |
1051 | set fails 1 | |
1052 | send_log "Expected SHT_NOBITS type for .$name\n" | |
1053 | } | |
1054 | set got $rest | |
1055 | } | |
1056 | if { $fails == 1 } { | |
1057 | fail $test | |
1058 | return | |
1059 | } | |
1060 | ||
1061 | pass $test | |
1062 | } | |
63b9bbb7 | 1063 | |
252b5132 | 1064 | set test1 "simple objcopy of executable" |
21c40443 AM |
1065 | set test1r "run objcopy of executable" |
1066 | set test2 "strip executable" | |
1067 | set test2r "run stripped executable" | |
1068 | set test3 "strip executable with saving a symbol" | |
1069 | set test3r "run stripped executable with saving a symbol" | |
1070 | set test4 "keep only debug data" | |
1071 | set test5 "simple objcopy of debug data" | |
63b9bbb7 | 1072 | if [is_elf_format] { |
21c40443 | 1073 | set test6 "NOBITS sections retain sh_link field" |
5049d00e | 1074 | set test7 "--only-keep-debug for ELF relocatables" |
63b9bbb7 | 1075 | } |
252b5132 RH |
1076 | |
1077 | switch [copy_setup] { | |
1078 | "1" { | |
1079 | # do nothing | |
1080 | } | |
1081 | "2" { | |
1082 | untested $test1 | |
21c40443 | 1083 | untested $test1r |
252b5132 | 1084 | untested $test2 |
21c40443 | 1085 | untested $test2r |
252b5132 | 1086 | untested $test3 |
21c40443 | 1087 | untested $test3r |
252b5132 | 1088 | untested $test4 |
11701589 | 1089 | untested $test5 |
63b9bbb7 | 1090 | if [is_elf_format] { |
21c40443 | 1091 | untested $test6 |
63b9bbb7 | 1092 | } |
252b5132 RH |
1093 | } |
1094 | "3" { | |
0d063f63 | 1095 | copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "" |
21c40443 AM |
1096 | unsupported $test1r |
1097 | strip_executable "$STRIP" "$STRIPFLAGS" "$test2" "" | |
1098 | unsupported $test2r | |
1099 | strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" "" | |
1100 | unsupported $test3r | |
1101 | keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \ | |
1102 | "$OBJCOPY" "$OBJCOPYFLAGS" "$test5" | |
63b9bbb7 | 1103 | if [is_elf_format] { |
21c40443 | 1104 | keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test6" |
5049d00e | 1105 | keep_debug_symbols_for_elf_relocatable "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test7" |
63b9bbb7 | 1106 | } |
252b5132 RH |
1107 | } |
1108 | "0" { | |
21c40443 AM |
1109 | copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test1r" |
1110 | strip_executable "$STRIP" "$STRIPFLAGS" "$test2" "$test2r" | |
1111 | strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" "$test3r" | |
1112 | keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \ | |
1113 | "$OBJCOPY" "$OBJCOPYFLAGS" "$test5" | |
63b9bbb7 | 1114 | if [is_elf_format] { |
21c40443 | 1115 | keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test6" |
5049d00e | 1116 | keep_debug_symbols_for_elf_relocatable "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test7" |
63b9bbb7 | 1117 | } |
252b5132 RH |
1118 | } |
1119 | } | |
ad2fb2cd | 1120 | |
6a0d0afd L |
1121 | proc objcopy_test_readelf {testname srcfile} { |
1122 | global OBJCOPY | |
1123 | global OBJCOPYFLAGS | |
1124 | global READELF | |
1125 | global srcdir | |
1126 | global subdir | |
1127 | ||
1128 | if {![binutils_assemble $srcdir/$subdir/${srcfile} tmpdir/bintest.o]} then { | |
17e04eff | 1129 | unsupported "objcopy ($testname)" |
6a0d0afd L |
1130 | return |
1131 | } | |
1132 | ||
1133 | verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" | |
7f6a71ff JM |
1134 | set exec_output [remote_exec host "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"] |
1135 | if { [lindex $exec_output 0] != 0 | |
21c40443 | 1136 | || ![string equal "" [lindex $exec_output 1]] } then { |
6a0d0afd | 1137 | fail "objcopy ($testname)" |
004314cc | 1138 | return |
6a0d0afd L |
1139 | } |
1140 | ||
1141 | verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" | |
7f6a71ff JM |
1142 | set exec_output [remote_exec host "$READELF -a tmpdir/bintest.o" "" "/dev/null" "tmpdir/bintest.o.out"] |
1143 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 1144 | fail "objcopy ($testname)" |
7f6a71ff JM |
1145 | return |
1146 | } | |
1147 | set exec_output [prune_warnings [lindex $exec_output 1]] | |
21c40443 | 1148 | if ![string equal "" $exec_output] then { |
6a0d0afd L |
1149 | unresolved "objcopy ($testname)" |
1150 | return | |
1151 | } | |
1152 | ||
1153 | verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out" | |
7f6a71ff JM |
1154 | set exec_output [remote_exec host "$READELF -a tmpdir/copy.o" "" "/dev/null" "tmpdir/copy.o.out"] |
1155 | if { [lindex $exec_output 0] != 0 } then { | |
17e04eff | 1156 | fail "objcopy ($testname)" |
7f6a71ff JM |
1157 | return |
1158 | } | |
1159 | set exec_output [prune_warnings [lindex $exec_output 1]] | |
21c40443 | 1160 | if ![string equal "" $exec_output] then { |
6a0d0afd L |
1161 | unresolved "objcopy ($testname)" |
1162 | return | |
1163 | } | |
1164 | ||
1165 | verbose -log "diff tmpdir/bintest.o.out tmpdir/copy.o.out" | |
1166 | catch "exec diff tmpdir/bintest.o.out tmpdir/copy.o.out" exec_output | |
1167 | set exec_output [prune_warnings $exec_output] | |
1168 | ||
21c40443 | 1169 | if [string equal "" $exec_output] then { |
6a0d0afd L |
1170 | pass "objcopy ($testname)" |
1171 | } else { | |
1172 | fail "objcopy ($testname)" | |
1173 | } | |
1174 | } | |
1175 | ||
0b45135e AB |
1176 | proc objcopy_test_symbol_manipulation {} { |
1177 | global srcdir | |
1178 | global subdir | |
1179 | ||
1180 | set test_list [lsort [glob -nocomplain $srcdir/$subdir/symbols-*.d]] | |
1181 | foreach t $test_list { | |
1182 | # We need to strip the ".d", but can leave the dirname. | |
1183 | verbose [file rootname $t] | |
1184 | run_dump_test [file rootname $t] | |
1185 | } | |
260ecdce FS |
1186 | |
1187 | if { [supports_gnu_unique] } { | |
1188 | run_dump_test "weaken-gnu-unique" | |
1189 | } | |
0b45135e AB |
1190 | } |
1191 | ||
b8871f35 L |
1192 | proc objcopy_test_elf_common_symbols {} { |
1193 | global srcdir | |
1194 | global subdir | |
1195 | ||
1196 | # hpux has a non-standard common directive. | |
1197 | if { [istarget "*-*-hpux*"] } then { | |
1198 | return | |
1199 | } | |
1200 | ||
1201 | set test_list [lsort [glob -nocomplain $srcdir/$subdir/common-*.d]] | |
1202 | foreach t $test_list { | |
1203 | # We need to strip the ".d", but can leave the dirname. | |
1204 | verbose [file rootname $t] | |
1205 | run_dump_test [file rootname $t] | |
1206 | } | |
1207 | } | |
1208 | ||
ad2fb2cd L |
1209 | # ia64 specific tests |
1210 | if { ([istarget "ia64-*-elf*"] | |
1211 | || [istarget "ia64-*-linux*"]) } { | |
1fafefd5 | 1212 | objcopy_test "ia64 link order" link-order.s object "" "" |
64bb95af | 1213 | } |
ad2fb2cd | 1214 | |
64bb95af | 1215 | # ELF specific tests |
506b86a4 | 1216 | set elf64 "" |
64bb95af | 1217 | if [is_elf_format] { |
0b45135e | 1218 | objcopy_test_symbol_manipulation |
b8871f35 | 1219 | objcopy_test_elf_common_symbols |
6a81c59b AM |
1220 | |
1221 | setup_xfail "hppa*-*-*" | |
1222 | setup_xfail "sh-*-coff*" | |
1223 | setup_xfail "tic54x-*-*" | |
1224 | clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*" | |
0a6a8b59 | 1225 | clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*" |
1fafefd5 | 1226 | objcopy_test "ELF unknown section type" unknown.s object "" "" |
6a81c59b | 1227 | |
a0a8a934 NC |
1228 | objcopy_test_readelf "ELF group 1" group.s |
1229 | objcopy_test_readelf "ELF group 2" group-2.s | |
1230 | objcopy_test_readelf "ELF group 3" group-3.s | |
1231 | objcopy_test_readelf "ELF group 4" group-4.s | |
a91e1603 | 1232 | objcopy_test_readelf "GNU_MBIND section" mbind1.s |
b2fc24d4 | 1233 | run_dump_test "group-5" |
4c8e8a7e | 1234 | run_dump_test "group-6" |
6e5e9d58 AM |
1235 | run_dump_test "group-7a" |
1236 | run_dump_test "group-7b" | |
1237 | run_dump_test "group-7c" | |
85d7f0b9 | 1238 | run_dump_test "copy-1" |
0930eddd | 1239 | run_dump_test "note-1" |
acea835f AM |
1240 | # Use copytest.o from the note-1 test to determine ELF32 or ELF64 |
1241 | if [is_elf64 tmpdir/copytest.o] { | |
506b86a4 | 1242 | set elf64 "--defsym ELF64=1" |
9ef920e9 | 1243 | run_dump_test "note-2-64" |
714da62f | 1244 | run_dump_test "note-3-64" |
6f156d7a | 1245 | run_dump_test "note-4-64" |
5c49f2cd | 1246 | run_dump_test "note-6-64" |
9ef920e9 NC |
1247 | } else { |
1248 | run_dump_test "note-2-32" | |
714da62f | 1249 | run_dump_test "note-3-32" |
6f156d7a | 1250 | run_dump_test "note-4-32" |
5c49f2cd | 1251 | run_dump_test "note-6-32" |
9ef920e9 | 1252 | } |
0df8ad28 | 1253 | run_dump_test "note-5" |
ad2fb2cd | 1254 | } |
af3c5dea | 1255 | |
af3c5dea | 1256 | run_dump_test "copy-2" |
81fc501a | 1257 | run_dump_test "copy-3" |
0691f7af | 1258 | run_dump_test "copy-4" |
de564eb5 | 1259 | run_dump_test "copy-5" |
e3ecd631 | 1260 | run_dump_test "copy-6" |
de564eb5 | 1261 | |
506b86a4 AM |
1262 | # Use bintest.o from the copy-4 test to determine ELF reloc type |
1263 | set reloc_format rel | |
1264 | if { [is_elf_format] && [is_rela tmpdir/bintest.o] } { | |
1265 | set reloc_format rela | |
1266 | } | |
cbd44e24 L |
1267 | run_dump_test "pr19020a" |
1268 | run_dump_test "pr19020b" | |
d58c2e3a RS |
1269 | |
1270 | if [is_elf_format] { | |
748fc5e9 L |
1271 | run_dump_test "strip-1" |
1272 | run_dump_test "strip-2" | |
1aa9ef63 | 1273 | run_dump_test "strip-3" |
eb3980ce L |
1274 | run_dump_test "strip-4" |
1275 | run_dump_test "strip-5" | |
f206e905 L |
1276 | run_dump_test "strip-6" |
1277 | run_dump_test "strip-7" | |
e1e87d1e L |
1278 | run_dump_test "strip-8" |
1279 | run_dump_test "strip-9" | |
d4ac1f87 | 1280 | run_dump_test "strip-12" |
2f8ceb38 MR |
1281 | |
1282 | if { [istarget "mips64*-*-openbsd*"] } { | |
1283 | set reloc_format mips64 | |
2f8ceb38 | 1284 | } |
506b86a4 | 1285 | # A relocation type not supported by any target |
fbaf61ad NC |
1286 | if { [istarget "nds32*-*"] } { |
1287 | set reloc 255 | |
1288 | } else { | |
1289 | set reloc 215 | |
1290 | } | |
506b86a4 AM |
1291 | run_dump_test "strip-13" [list \ |
1292 | [list source strip-13${reloc_format}.s] \ | |
1293 | [list as "${elf64} --defsym RELOC=${reloc}"]] | |
3f97ba9f MR |
1294 | # Select a relocation number that corresponds to one actually |
1295 | # supported by the target and ABI being tested. | |
1296 | if { [istarget "aarch64*-*"] } { | |
1297 | set reloc 259 | |
1298 | } elseif { [istarget "ia64*-*"] \ | |
1299 | || [istarget "m32r*-*"] \ | |
d4ae1932 | 1300 | || [istarget "nds32*-*"] \ |
3f97ba9f MR |
1301 | || [istarget "v850*-*"] } { |
1302 | set reloc 50 | |
d4ae1932 AM |
1303 | } elseif { [istarget "pru-*"] } { |
1304 | set reloc 11 | |
3f97ba9f MR |
1305 | } else { |
1306 | set reloc 1 | |
1307 | } | |
1308 | run_dump_test "strip-14" [list \ | |
506b86a4 AM |
1309 | [list source strip-14${reloc_format}.s] \ |
1310 | [list as "${elf64} --defsym RELOC=${reloc}"]] | |
d52e3d06 | 1311 | run_dump_test "strip-15" [list \ |
506b86a4 AM |
1312 | [list source strip-15${reloc_format}.s] \ |
1313 | [list as "${elf64} --defsym RELOC=${reloc}"]] | |
f3185997 | 1314 | |
a43942db MR |
1315 | # This requires STB_GNU_UNIQUE support with OSABI set to GNU. |
1316 | if { [supports_gnu_unique] } { | |
4cd28456 AM |
1317 | run_dump_test "strip-10" |
1318 | } | |
211dc24b | 1319 | run_dump_test "strip-11" |
312aaa3c | 1320 | |
b8b6abe0 AM |
1321 | if { [istarget "i*86-*"] || [istarget "x86_64-*-*"] } { |
1322 | # Check to make sure we don't strip a symbol named in relocations. | |
1323 | set test "objcopy keeps symbols needed by relocs" | |
312aaa3c | 1324 | |
b8b6abe0 | 1325 | set srcfile $srcdir/$subdir/needed-by-reloc.s |
312aaa3c | 1326 | |
b8b6abe0 | 1327 | if {![binutils_assemble $srcfile tmpdir/bintest.o]} then { |
17e04eff | 1328 | unsupported $test |
b8b6abe0 AM |
1329 | } else { |
1330 | set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS --strip-symbol=foo tmpdir/bintest.o ${copyfile}.o"] | |
312aaa3c | 1331 | |
b8b6abe0 AM |
1332 | if [regexp "not stripping symbol `foo' because it is named in a relocation" $got] { |
1333 | pass $test | |
1334 | } else { | |
1335 | fail $test | |
1336 | } | |
1337 | } | |
312aaa3c | 1338 | } |
b8b6abe0 | 1339 | |
8560e02a HPN |
1340 | # The symbol table for some MIPS targets is sorted differently than |
1341 | # the ELF canonical order, so the regexps in localize-hidden-1.d fail | |
9cc0123f AM |
1342 | # to match. |
1343 | if { [is_bad_symtab] } then { | |
1344 | setup_xfail "*-*-*" | |
8560e02a | 1345 | } |
b8b6abe0 | 1346 | run_dump_test "localize-hidden-1" |
afeb3d7f L |
1347 | run_dump_test "testranges" |
1348 | run_dump_test "testranges-ia64" | |
500ee42e ILT |
1349 | |
1350 | run_dump_test "add-section" | |
2b35fb28 | 1351 | run_dump_test "add-symbol" |
500ee42e | 1352 | run_dump_test "add-empty-section" |
18ae9cc1 L |
1353 | |
1354 | run_dump_test "exclude-1a" | |
1355 | run_dump_test "exclude-1b" | |
e511c9b1 AB |
1356 | |
1357 | run_dump_test "only-section-01" | |
1358 | run_dump_test "remove-section-01" | |
d3e5f6c8 | 1359 | |
64f52b3e FS |
1360 | run_dump_test "keep-section-1" |
1361 | run_dump_test "keep-section-2" | |
1362 | ||
d3e5f6c8 AB |
1363 | # Test the remove relocation functionality |
1364 | set test_list [lsort [glob -nocomplain $srcdir/$subdir/remove-relocs-*.d]] | |
1365 | foreach t $test_list { | |
1366 | # We need to strip the ".d", but can leave the dirname. | |
1367 | verbose [file rootname $t] | |
1368 | run_dump_test [file rootname $t] | |
1369 | } | |
312aaa3c | 1370 | } |
b8b6abe0 | 1371 | run_dump_test "localize-hidden-2" |
14f2c699 L |
1372 | |
1373 | # Test objcopying an object file without global symbol | |
1374 | ||
1375 | proc objcopy_test_without_global_symbol { } { | |
1376 | global OBJCOPY | |
1377 | global OBJCOPYFLAGS | |
1378 | global OBJDUMP | |
1379 | global OBJDUMPFLAGS | |
1380 | global srcdir | |
1381 | global subdir | |
1382 | ||
1383 | set test "strip without global symbol " | |
1384 | ||
1385 | if { [target_compile $srcdir/$subdir/pr19547.c tmpdir/pr19547.o object debug] != "" } { | |
1386 | untested $test | |
1387 | return | |
1388 | } | |
1389 | ||
1390 | if [is_remote host] { | |
1391 | set objfile [remote_download host tmpdir/pr19547.o] | |
1392 | } else { | |
1393 | set objfile tmpdir/pr19547.o | |
1394 | } | |
1395 | ||
1396 | set exec_output [binutils_run $OBJCOPY "$OBJCOPYFLAGS --strip-unneeded $objfile"] | |
7dd36a6f | 1397 | set exec_output [prune_warnings $exec_output] |
14f2c699 L |
1398 | if ![string equal "" $exec_output] { |
1399 | fail $test | |
1400 | return | |
1401 | } | |
1402 | ||
1403 | set exec_output [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $objfile"] | |
7dd36a6f | 1404 | set exec_output [prune_warnings $exec_output] |
14f2c699 L |
1405 | if {![regexp "no symbols" $exec_output]} { |
1406 | fail $test | |
1407 | return | |
1408 | } | |
1409 | ||
1410 | pass $test | |
1411 | } | |
1412 | ||
41699fa4 NC |
1413 | # The AArch64 and ARM targets preserve mapping symbols |
1414 | # in object files, so they will fail this test. | |
1415 | setup_xfail aarch64*-*-* arm*-*-* | |
1416 | ||
14f2c699 | 1417 | objcopy_test_without_global_symbol |
f9853190 AM |
1418 | |
1419 | # objcopy remove relocation from executable test | |
1420 | ||
1421 | proc objcopy_remove_relocations_from_executable { } { | |
1422 | global OBJCOPY | |
1423 | global srcdir | |
1424 | global subdir | |
1425 | global READELF | |
1426 | ||
1427 | set test "remove-section relocation sections" | |
1428 | ||
1429 | if { [target_compile $srcdir/$subdir/testprog.c tmpdir/pr23611 executable debug] != "" } { | |
1430 | untested $test | |
1431 | return | |
1432 | } | |
1433 | ||
1434 | if [is_remote host] { | |
1435 | set objfile [remote_download host tmpdir/pr23611] | |
1436 | } else { | |
1437 | set objfile tmpdir/pr23611 | |
1438 | } | |
1439 | set out tmpdir/pr23611.out | |
1440 | ||
1441 | set exec_output1 [binutils_run $OBJCOPY "-R .rela.plt -R .rela.dyn -R .rel.plt -R .rel.dyn $objfile $out"] | |
d4f5b5e2 AM |
1442 | |
1443 | set exec_output1 [prune_warnings $exec_output1] | |
1444 | if ![string equal "" $exec_output1] { | |
1445 | fail $test | |
1446 | return | |
1447 | } | |
1448 | ||
f9853190 AM |
1449 | set exec_output2 [binutils_run $READELF "-S $out"] |
1450 | if { [string match "*.rel.plt*" $exec_output2] || [string match "*.rela.plt*" $exec_output2] || [string match "*.rel.dyn*" $exec_output2] || [string match "*.rela.dyn*" $exec_output2] } { | |
1451 | fail $test | |
1452 | return | |
1453 | } | |
1454 | pass $test | |
1455 | } | |
1456 | ||
d4f5b5e2 AM |
1457 | if [is_elf_format] { |
1458 | objcopy_remove_relocations_from_executable | |
1459 | } | |
319dbdfb L |
1460 | |
1461 | run_dump_test "pr23633" | |
de4859ea NC |
1462 | |
1463 | run_dump_test "set-section-alignment" | |
1fafefd5 | 1464 | |
6a81c59b AM |
1465 | setup_xfail "hppa*-*-*" |
1466 | setup_xfail "sh-*-coff*" | |
0a6a8b59 | 1467 | setup_xfail "spu-*-*" |
6a81c59b | 1468 | clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*" |
0a6a8b59 | 1469 | clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "hppa*-*-*elf*" |
8eca5c7d SC |
1470 | if { [istarget pdp11-*-*] } { |
1471 | set src "pr25662-pdp11.s" | |
1472 | } else { | |
1473 | set src "pr25662.s" | |
1474 | } | |
1475 | ||
790147a9 L |
1476 | set ldflags "-T$srcdir/$subdir/pr25662.ld" |
1477 | if { [istarget *-*-cygwin] || [istarget *-*-mingw*] } { | |
1478 | append ldflags " --disable-reloc-section" | |
1479 | } | |
1480 | ||
efd0ed58 AM |
1481 | #xcoff doesn't support arbitrary sections |
1482 | if { ![is_xcoff_format] } { | |
790147a9 | 1483 | objcopy_test "pr25662" $src executable "" $ldflags |
efd0ed58 | 1484 | } |
4f5c4fce AM |
1485 | |
1486 | run_dump_test "rename-section-01" |