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