510f6cedbe57d2bc3fba54ee70ed1a4de9c8203f
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / objcopy.exp
1 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2 # 2004, 2006
3 # Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # Please email any bugs, comments, and/or additions to this file to:
20 # bug-dejagnu@prep.ai.mit.edu
21
22 # Written by Ian Lance Taylor <ian@cygnus.com>
23
24 if ![is_remote host] {
25 if {[which $OBJCOPY] == 0} then {
26 perror "$OBJCOPY does not exist"
27 return
28 }
29 }
30
31 send_user "Version [binutil_version $OBJCOPY]"
32
33 if ![is_remote host] {
34 set tempfile tmpdir/bintest.o
35 set copyfile tmpdir/copy
36 } else {
37 set tempfile [remote_download host tmpdir/bintest.o]
38 set copyfile copy
39 }
40
41 # Test that objcopy does not modify a file when copying it.
42
43 proc objcopy_test {testname srcfile} {
44 global OBJCOPY
45 global OBJCOPYFLAGS
46 global srcdir
47 global subdir
48 global tempfile
49 global copyfile
50
51 if {![binutils_assemble $srcdir/$subdir/${srcfile} tmpdir/bintest.o]} then {
52 perror "unresolved $testname"
53 unresolved "objcopy ($testname)"
54 return
55 }
56
57 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile ${copyfile}.o"]
58
59 if ![string match "" $got] then {
60 fail "objcopy ($testname)"
61 } else {
62 send_log "cmp $tempfile ${copyfile}.o\n"
63 verbose "cmp $tempfile ${copyfile}.o"
64 if [is_remote host] {
65 set src1 tmpdir/bintest.o
66 set src2 tmpdir/copy.o
67 remote_upload host $tempfile $src1
68 remote_upload host ${copyfile}.o $src2
69 } else {
70 set src1 ${tempfile}
71 set src2 ${copyfile}.o
72 }
73 set status [remote_exec build cmp "${src1} ${src2}"]
74 set exec_output [lindex $status 1]
75 set exec_output [prune_warnings $exec_output]
76
77 # On some systems the result of objcopy will not be identical.
78 # Usually this is just because gas isn't using bfd to write the
79 # files in the first place, and may order things a little
80 # differently. Those systems should use setup_xfail here.
81
82 setup_xfail "h8300-*-rtems*" "h8300-*-coff"
83 setup_xfail "h8500-*-rtems*" "h8500-*-coff"
84 setup_xfail "hppa*-*-*"
85 setup_xfail "i960-*"
86 setup_xfail "m68*-*-*coff" "m68*-*-hpux*" "m68*-*-lynxos*"
87 setup_xfail "m68*-*-sysv*" "m68*-apple-aux*"
88 setup_xfail "m8*-*"
89 setup_xfail "or32-*-rtems*" "or32-*-coff"
90 setup_xfail "sh-*-coff*" "sh-*-rtems*"
91 setup_xfail "tic4x-*-*" "tic80-*-*" "w65-*"
92
93 clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*"
94 clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "*-*-*elf*"
95 clear_xfail "m68*-*-sysv4*"
96
97 if [string match "" $exec_output] then {
98 pass "objcopy ($testname)"
99 } else {
100 send_log "$exec_output\n"
101 verbose "$exec_output" 1
102
103 # On OSF/1, this succeeds with gas and fails with /bin/as.
104 setup_xfail "alpha*-*-osf*"
105
106 # This fails for COFF i960-vxworks targets.
107 setup_xfail "i960-*-vxworks*"
108
109 fail "objcopy ($testname)"
110 }
111 }
112 }
113
114 objcopy_test "simple copy" bintest.s
115
116 # Test reversing bytes in a section.
117
118 set reversed ${tempfile}-reversed
119 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j .data --reverse-bytes=4 $tempfile $reversed"]
120
121 if ![string match "" $got] then {
122 fail "objcopy --reverse-bytes"
123 } else {
124 if [is_remote host] {
125 remote_upload host ${reversed} tmpdir/copy-reversed.o
126 set reversed tmpdir/copy-reversed.o
127 }
128
129 set origdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $tempfile"]
130 set revdata [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s -j .data $reversed"]
131
132 set want "^ \[0-9\]+ (\[0-9\]+)"
133 set found_orig [regexp -lineanchor $want $origdata -> origdata]
134 set found_rev [regexp -lineanchor $want $revdata -> revdata]
135
136 if {$found_orig == 0 || $found_rev == 0} then {
137 fail "objcopy --reverse-bytes"
138 } else {
139 scan $origdata "%2x%2x%2x%2x" b1 b2 b3 b4
140 scan $revdata "%2x%2x%2x%2x" c4 c3 c2 c1
141
142 if {$b1 == $c1 && $b2 == $c2 && $b3 == $c3 && $b4 == $c4} then {
143 pass "objcopy --reverse-bytes"
144 } else {
145 fail "objcopy --reverse-bytes"
146 }
147 }
148 }
149
150 # Test generating S records.
151
152 # We make the srec filename 8.3 compatible. Note that the header string
153 # matched against depends on the name of the file. Ugh.
154
155 if [is_remote host] {
156 set srecfile copy.sre
157 set header_string S00B0000636F70792E737265C1
158 } else {
159 set srecfile ${copyfile}.srec
160 set header_string S0130000746D706469722F636F70792E7372656397
161 }
162
163 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${srecfile}"]
164
165 if ![string match "" $got] then {
166 fail "objcopy -O srec"
167 } else {
168 if [is_remote host] {
169 remote_upload host ${srecfile} tmpdir/copy.srec
170 set srecfile tmpdir/copy.srec
171 }
172 set file [open ${srecfile} r]
173
174 # The first S record is fixed by the file name we are using.
175 gets $file line
176 send_log "$line\n"
177 verbose $line
178 if ![regexp "$header_string.*" $line] {
179 send_log "bad header\n"
180 fail "objcopy -O srec"
181 } else {
182 while {[gets $file line] != -1 \
183 && [regexp "^S\[123\]\[0-9a-fA-F\]+\[\r\n\]*$" $line]} {
184 send_log "$line\n"
185 verbose $line
186 set line "**EOF**"
187 }
188 send_log "$line\n"
189 verbose $line
190 if ![regexp "^S\[789\]\[0-9a-fA-F\]+\[\r\n\]*$" $line] then {
191 send_log "bad trailer\n"
192 fail "objcopy -O srec"
193 } else {
194 if {[gets $file line] != -1} then {
195 send_log "garbage at end\n"
196 send_log "$line\n"
197 verbose $line
198 fail "objcopy -O srec"
199 } else {
200 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
201 if ![regexp "file format srec" $got] then {
202 send_log "objdump failed\n"
203 fail "objcopy -O srec"
204 } else {
205 pass "objcopy -O srec"
206 }
207 }
208 }
209 }
210
211 close $file
212 }
213
214 # Test setting and adjusting the start address. We only test this
215 # while generating S records, because we may not be able to set the
216 # start address for other object file formats, and the S record case
217 # is the only useful one anyhow.
218
219 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $tempfile"]
220 if ![regexp "start address (\[0-9a-fA-FxX\]+)" $got all origstart] then {
221 perror "objdump can not recognize bintest.o"
222 set origstart ""
223 } else {
224 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --set-start 0x7654 $tempfile ${copyfile}.srec"]
225 if ![string match "" $got] then {
226 fail "objcopy --set-start"
227 } else {
228 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
229 if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
230 fail "objcopy --set-start"
231 } else {
232 if {$srecstart != 0x7654} then {
233 send_log "$srecstart != 0x7654\n"
234 fail "objcopy --set-start"
235 } else {
236 pass "objcopy --set-start"
237 }
238 }
239 }
240
241 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-start 0x123 $tempfile ${copyfile}.srec"]
242 if ![string match "" $got] then {
243 fail "objcopy --adjust-start"
244 } else {
245 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
246 if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
247 fail "objcopy --adjust-start"
248 } else {
249 if {$srecstart != $origstart + 0x123} then {
250 send_log "$srecstart != $origstart + 0x123\n"
251 fail "objcopy --adjust-start"
252 } else {
253 pass "objcopy --adjust-start"
254 }
255 }
256 }
257 }
258
259 # Test adjusting the overall VMA, and adjusting the VMA of a
260 # particular section. We again only test this when generating S
261 # records.
262
263 set low ""
264 set lowname ""
265
266 set headers [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $tempfile"]
267
268 set headers_regexp "\[ 0-9\]+(\[^ \]+)\[ \]*(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+2\[*\]\[*\]\[0-9\]+(.*)"
269
270 set got $headers
271 while {[regexp $headers_regexp $got all name size vma rest]} {
272 set vma 0x$vma
273 set size 0x$size
274 if {$size != 0} {
275 if {$low == "" || $vma < $low} {
276 set low $vma
277 set lowname $name
278 }
279 }
280 set got $rest
281 }
282
283 if {$low == "" || $origstart == ""} then {
284 perror "objdump can not recognize bintest.o"
285 } else {
286 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-vma 0x123 $tempfile ${copyfile}.srec"]
287 if ![string match "" $got] then {
288 fail "objcopy --adjust-vma"
289 } else {
290 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -fh ${copyfile}.srec"]
291 set want "file format srec.*start address\[ \]*(\[0-9a-fA-FxX\]+).*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
292 if ![regexp $want $got all start vma] then {
293 fail "objcopy --adjust-vma"
294 } else {
295 set vma 0x$vma
296 if {$vma != $low + 0x123} then {
297 send_log "$vma != $low + 0x123\n"
298 fail "objcopy --adjust-vma"
299 } else {
300 if {$start != $origstart + 0x123} then {
301 send_log "$start != $origstart + 0x123\n"
302 fail "objcopy --adjust-vma"
303 } else {
304 pass "objcopy --adjust-vma"
305 }
306 }
307 }
308 }
309
310 set arg ""
311 set got $headers
312 while {[regexp $headers_regexp $got all name size vma rest]} {
313 set vma 0x$vma
314 if {$vma == $low} then {
315 set arg "$arg --adjust-section-vma $name+4"
316 }
317 set got $rest
318 }
319
320 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $arg $tempfile ${copyfile}.srec"]
321 if ![string match "" $got] then {
322 fail "objcopy --adjust-section-vma +"
323 } else {
324 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
325 set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
326 if ![regexp $want $got all vma] then {
327 fail "objcopy --adjust-section-vma +"
328 } else {
329 set vma 0x$vma
330 if {$vma != $low + 4} then {
331 send_log "$vma != $low + 4\n"
332 fail "objcopy --adjust-section-vma +"
333 } else {
334 pass "objcopy --adjust-section-vma +"
335 }
336 }
337 }
338
339 regsub -all "\\+4" $arg "=[expr $low + 4]" argeq
340 set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $argeq $tempfile ${copyfile}.srec"]
341 if ![string match "" $got] then {
342 fail "objcopy --adjust-section-vma ="
343 } else {
344 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
345 set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
346 if ![regexp $want $got all vma] then {
347 fail "objcopy --adjust-section-vma ="
348 } else {
349 set vma 0x$vma
350 if {$vma != $low + 4} then {
351 send_log "$vma != $low + 4\n"
352 fail "objcopy --adjust-section-vma ="
353 } else {
354 pass "objcopy --adjust-section-vma ="
355 }
356 }
357 }
358 }
359
360 # Test stripping an object.
361
362 proc strip_test { } {
363 global AR
364 global CC
365 global STRIP
366 global STRIPFLAGS
367 global NM
368 global NMFLAGS
369 global srcdir
370 global subdir
371
372 set test "strip"
373
374 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
375 untested $test
376 return
377 }
378
379 if [is_remote host] {
380 set archive libstrip.a
381 set objfile [remote_download host tmpdir/testprog.o]
382 remote_file host delete $archive
383 } else {
384 set archive tmpdir/libstrip.a
385 set objfile tmpdir/testprog.o
386 }
387
388 remote_file build delete tmpdir/libstrip.a
389
390 set exec_output [binutils_run $AR "rc $archive ${objfile}"]
391 if ![string match "" $exec_output] {
392 fail $test
393 return
394 }
395
396 set exec_output [binutils_run $STRIP "-g $archive"]
397 if ![string match "" $exec_output] {
398 fail $test
399 return
400 }
401
402 set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"]
403 if ![string match "" $exec_output] {
404 fail $test
405 return
406 }
407
408 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
409 untested $test
410 return
411 }
412
413 if [is_remote host] {
414 set objfile [remote_download host tmpdir/testprog.o]
415 } else {
416 set objfile tmpdir/testprog.o
417 }
418
419 set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
420 if ![string match "" $exec_output] {
421 fail $test
422 return
423 }
424
425 set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
426 if ![string match "*: no symbols*" $exec_output] {
427 fail $test
428 return
429 }
430
431 pass $test
432 }
433
434 strip_test
435
436 # Test stripping an object file with saving a symbol
437
438 proc strip_test_with_saving_a_symbol { } {
439 global CC
440 global STRIP
441 global STRIPFLAGS
442 global NM
443 global NMFLAGS
444 global srcdir
445 global subdir
446
447 set test "strip with saving a symbol"
448
449 if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
450 untested $test
451 return
452 }
453
454 if [is_remote host] {
455 set objfile [remote_download host tmpdir/testprog.o]
456 } else {
457 set objfile tmpdir/testprog.o
458 }
459
460 set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"]
461 if ![string match "" $exec_output] {
462 fail $test
463 return
464 }
465
466 set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
467 if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
468 && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
469 fail $test
470 return
471 }
472
473 pass $test
474 }
475
476 strip_test_with_saving_a_symbol
477
478 # Build a final executable.
479
480 if { [istarget *-*-cygwin] || [istarget *-*-mingw*] } {
481 set test_prog "testprog.exe"
482 } else {
483 set test_prog "testprog"
484 }
485
486 proc copy_setup { } {
487 global srcdir
488 global subdir
489 global gcc_gas_flag
490 global test_prog
491
492 set res [build_wrapper testglue.o]
493 set flags { debug }
494
495 if { [istarget *-*-uclinux*] } {
496 return 1
497 }
498
499 if { $res != "" } {
500 lappend flags "additional_flags=[lindex $res 1]"
501 set add_libs "testglue.o"
502 } else {
503 set add_libs ""
504 }
505
506 if { [istarget *-*-linux*] } {
507 foreach i $gcc_gas_flag {
508 set flags "additional_flags=$i $flags"
509 }
510 }
511 if { [target_compile "$srcdir/$subdir/testprog.c $add_libs" tmpdir/$test_prog executable $flags] != "" } {
512 return 2
513 }
514
515 set result [remote_load target tmpdir/$test_prog]
516 set status [lindex $result 0]
517
518 if { $status != "pass" } {
519 perror "unresolved setup, status = $status"
520 return 3
521 }
522
523 return 0
524 }
525
526 # Test copying an executable.
527
528 proc copy_executable { prog flags test1 test2 } {
529 global test_prog
530
531 if [is_remote host] {
532 set testfile [remote_download host tmpdir/$test_prog]
533 set testcopy copyprog
534 } else {
535 set testfile tmpdir/$test_prog
536 set testcopy tmpdir/copyprog
537 }
538 remote_file host delete $testcopy
539
540 set exec_output [binutils_run $prog "$flags $testfile $testcopy"]
541
542 if ![string match "" $exec_output] {
543 fail $test1
544 fail $test2
545 return
546 }
547
548 if [is_remote host] {
549 remote_upload host $testcopy tmpdir/copyprog
550 }
551
552 set status [remote_exec build "cmp" "tmpdir/$test_prog tmpdir/copyprog"]
553 set exec_output [lindex $status 1]
554
555 if [string match "" $exec_output] then {
556 pass $test1
557 } else {
558 send_log "$exec_output\n"
559 verbose "$exec_output"
560
561 # This will fail for many reasons. For example, it will most
562 # likely fail if a non-GNU linker is used. Therefore, we do
563 # not insist that it pass. If you are using an assembler and
564 # linker based on the same BFD as objcopy, it is worth
565 # investigating to see why this failure occurs. If we are
566 # cross compiling, we assume that a GNU linker is being used,
567 # and expect it to succeed.
568 if {[isnative]} then {
569 setup_xfail "*-*-*"
570 }
571
572 # This also fails for mips*-*-elf targets. See elf32-mips.c
573 # mips_elf_sym_is_global.
574 setup_xfail "mips*-*-elf"
575
576 setup_xfail "*arm*-*-coff"
577 setup_xfail "xscale-*-coff"
578 setup_xfail "arm*-*-pe"
579 setup_xfail "thumb*-*-coff"
580 setup_xfail "thumb*-*-pe"
581
582 fail $test1
583 }
584
585 set output [remote_load target tmpdir/copyprog]
586 set status [lindex $output 0]
587 if { $status != "pass" } {
588 fail $test2
589 } else {
590 pass $test2
591 }
592 }
593
594 # Test stripping an executable
595
596 proc strip_executable { prog flags test } {
597 global NM
598 global NMFLAGS
599
600 remote_download build tmpdir/copyprog tmpdir/striprog
601 if [is_remote host] {
602 set copyfile [remote_download host tmpdir/striprog]
603 } else {
604 set copyfile tmpdir/striprog
605 }
606
607 set exec_output [binutils_run $prog "$flags ${copyfile}"]
608 if ![string match "" $exec_output] {
609 fail $test
610 return
611 }
612
613 if [is_remote host] {
614 remote_upload host ${copyfile} tmpdir/striprog
615 }
616
617 set result [remote_load target tmpdir/striprog]
618 set status [lindex $result 0]
619 if { $status != "pass" } {
620 fail $test
621 return
622 }
623
624 set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
625 if ![string match "*: no symbols*" $exec_output] {
626 fail $test
627 return
628 }
629 pass $test
630 }
631
632 # Test stripping an executable with saving a symbol
633
634 proc strip_executable_with_saving_a_symbol { prog flags test } {
635 global NM
636 global NMFLAGS
637
638 remote_download build tmpdir/copyprog tmpdir/striprog
639 if [is_remote host] {
640 set copyfile [remote_download host tmpdir/striprog]
641 } else {
642 set copyfile tmpdir/striprog
643 }
644
645 set exec_output [binutils_run $prog "$flags ${copyfile}"]
646 if ![string match "" $exec_output] {
647 fail $test
648 return
649 }
650
651 if [is_remote host] {
652 remote_upload host ${copyfile} tmpdir/striprog
653 }
654
655 set result [remote_load target tmpdir/striprog]
656 set status [lindex $result 0]
657 if { $status != "pass" } {
658 fail $test
659 return
660 }
661
662 set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
663 if { [istarget mmix-knuth-mmixware] } {
664 # Whenever there's a symbol in the mmo format, there's the symbol
665 # Main, so remove it manually from the expected output for sake of
666 # this test.
667
668 # Using "" not {} to get the \n and \r translated.
669 regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output
670 }
671
672 if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
673 && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
674 fail $test
675 return
676 }
677 pass $test
678 }
679
680 set test1 "simple objcopy of executable"
681 set test2 "run objcopy of executable"
682 set test3 "run stripped executable"
683 set test4 "run stripped executable with saving a symbol"
684
685 switch [copy_setup] {
686 "1" {
687 # do nothing
688 }
689 "2" {
690 untested $test1
691 untested $test2
692 untested $test3
693 untested $test4
694 }
695 "3" {
696 unresolved $test1
697 unresolved $test2
698 unresolved $test3
699 unresolved $test4
700 }
701 "0" {
702 copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2"
703 strip_executable "$STRIP" "$STRIPFLAGS" "$test3"
704 strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test4"
705 }
706 }
707
708 proc objcopy_test_readelf {testname srcfile} {
709 global OBJCOPY
710 global OBJCOPYFLAGS
711 global READELF
712 global srcdir
713 global subdir
714
715 if {![binutils_assemble $srcdir/$subdir/${srcfile} tmpdir/bintest.o]} then {
716 unresolved "objcopy ($testname)"
717 return
718 }
719
720 verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
721 catch "exec $OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" exec_output
722 if ![string match "" $exec_output] then {
723 fail "objcopy ($testname)"
724 return
725 }
726
727 verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out"
728 catch "exec $READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" exec_output
729 set exec_output [prune_warnings $exec_output]
730 if ![string match "" $exec_output] then {
731 unresolved "objcopy ($testname)"
732 return
733 }
734
735 verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out"
736 catch "exec $READELF -a tmpdir/copy.o > tmpdir/copy.o.out" exec_output
737 set exec_output [prune_warnings $exec_output]
738 if ![string match "" $exec_output] then {
739 unresolved "objcopy ($testname)"
740 return
741 }
742
743 verbose -log "diff tmpdir/bintest.o.out tmpdir/copy.o.out"
744 catch "exec diff tmpdir/bintest.o.out tmpdir/copy.o.out" exec_output
745 set exec_output [prune_warnings $exec_output]
746
747 if [string match "" $exec_output] then {
748 pass "objcopy ($testname)"
749 } else {
750 fail "objcopy ($testname)"
751 }
752 }
753
754 # ia64 specific tests
755 if { ([istarget "ia64-*-elf*"]
756 || [istarget "ia64-*-linux*"]) } {
757 objcopy_test "ia64 link order" link-order.s
758 }
759
760 # ELF specific tests
761 if [is_elf_format] {
762 objcopy_test "ELF unknown section type" unknown.s
763 objcopy_test_readelf "ELF group" group.s
764 run_dump_test "copy-1"
765 }
766
767 run_dump_test "copy-2"
768 run_dump_test "copy-3"
769
770 if [is_elf_format] {
771 run_dump_test "localize-hidden-1"
772 run_dump_test "strip-1"
773 run_dump_test "strip-2"
774 run_dump_test "strip-3"
775 }
776 run_dump_test "localize-hidden-2"
This page took 0.047594 seconds and 4 git commands to generate.