# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-# 2004, 2006, 2007
+# 2004, 2006, 2007, 2009
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
verbose $line
fail "objcopy -O srec"
} else {
- set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${srecfile}"]
if ![regexp "file format srec" $got] then {
send_log "objdump failed\n"
fail "objcopy -O srec"
global subdir
global gcc_gas_flag
global test_prog
+ global host_triplet
set res [build_wrapper testglue.o]
set flags { debug }
set status [lindex $result 0]
if { $status != "pass" } {
- send_log "cannot run executable, status = ${status}\n"
- return 3
+ send_log "cannot run executable, status = ${status} on ${host_triplet}\n"
+ if { [istarget $host_triplet] } {
+ return 3
+ }
+ set status "pass"
}
return 0
proc copy_executable { prog flags test1 test2 } {
global test_prog
+ global host_triplet
if [is_remote host] {
set testfile [remote_download host tmpdir/$test_prog]
setup_xfail "arm*-*-pe"
setup_xfail "thumb*-*-coff"
setup_xfail "thumb*-*-pe"
+ setup_xfail "x86_64-*-mingw*"
+ setup_xfail "*-*-cygwin*"
fail $test1
}
set output [remote_load target tmpdir/copyprog]
set status [lindex $output 0]
+ if { ![istarget $host_triplet] } {
+ set status "pass"
+ }
if { $status != "pass" } {
fail $test2
} else {
proc strip_executable { prog flags test } {
global NM
global NMFLAGS
+ global host_triplet
+ remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
set result [remote_load target tmpdir/striprog]
set status [lindex $result 0]
+ if { ![istarget $host_triplet] } {
+ set status "pass"
+ }
if { $status != "pass" } {
fail $test
return
proc strip_executable_with_saving_a_symbol { prog flags test } {
global NM
global NMFLAGS
+ global host_triplet
+ remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
if [is_remote host] {
set copyfile [remote_download host tmpdir/striprog]
set result [remote_load target tmpdir/striprog]
set status [lindex $result 0]
+ if { ![istarget $host_triplet] } {
+ set status "pass"
+ }
if { $status != "pass" } {
fail $test
return
pass $test
}
+# Test keeping only debug symbols of an executable
+
+proc keep_debug_symbols_and_test_copy { prog1 flags1 test1 prog2 flags2 test2 } {
+ global NM
+ global NMFLAGS
+
+ remote_file build delete tmpdir/striprog
+ remote_download build tmpdir/copyprog tmpdir/striprog
+ if [is_remote host] {
+ set copyfile [remote_download host tmpdir/striprog]
+ } else {
+ set copyfile tmpdir/striprog
+ }
+
+ set exec_output [binutils_run $prog1 "$flags1 ${copyfile}"]
+ if ![string match "" $exec_output] {
+ fail $test1
+ return
+ }
+ pass $test1
+
+ set exec_output [binutils_run $prog2 "$flags2 ${copyfile}"]
+ if ![string match "" $exec_output] {
+ fail $test2
+ return
+ }
+ pass $test2
+}
+
set test1 "simple objcopy of executable"
set test2 "run objcopy of executable"
set test3 "run stripped executable"
set test4 "run stripped executable with saving a symbol"
+set test5 "keep only debug data"
+set test6 "simple objcopy of debug data"
switch [copy_setup] {
"1" {
untested $test2
untested $test3
untested $test4
+ untested $test5
+ untested $test6
}
"3" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" ""
unsupported $test2
unsupported $test3
unsupported $test4
+ unsupported $test5
+ unsupported $test6
}
"0" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2"
strip_executable "$STRIP" "$STRIPFLAGS" "$test3"
strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test4"
+ keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test5" \
+ "$OBJCOPY" "$OBJCOPYFLAGS" "$test6"
}
}
}
verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
- catch "exec $OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" exec_output
- if ![string match "" $exec_output] then {
+ set exec_output [remote_exec host "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"]
+ if { [lindex $exec_output 0] != 0
+ || ![string match "" [lindex $exec_output 1]] } then {
fail "objcopy ($testname)"
return
}
verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out"
- catch "exec $READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" exec_output
- set exec_output [prune_warnings $exec_output]
+ set exec_output [remote_exec host "$READELF -a tmpdir/bintest.o" "" "/dev/null" "tmpdir/bintest.o.out"]
+ if { [lindex $exec_output 0] != 0 } then {
+ unresolved "objcopy ($testname)"
+ return
+ }
+ set exec_output [prune_warnings [lindex $exec_output 1]]
if ![string match "" $exec_output] then {
unresolved "objcopy ($testname)"
return
}
verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out"
- catch "exec $READELF -a tmpdir/copy.o > tmpdir/copy.o.out" exec_output
- set exec_output [prune_warnings $exec_output]
+ set exec_output [remote_exec host "$READELF -a tmpdir/copy.o" "" "/dev/null" "tmpdir/copy.o.out"]
+ if { [lindex $exec_output 0] != 0 } then {
+ unresolved "objcopy ($testname)"
+ return
+ }
+ set exec_output [prune_warnings [lindex $exec_output 1]]
if ![string match "" $exec_output] then {
unresolved "objcopy ($testname)"
return
if [is_elf_format] {
objcopy_test "ELF unknown section type" unknown.s
objcopy_test_readelf "ELF group" group.s
+ objcopy_test_readelf "ELF group" group-2.s
+ objcopy_test_readelf "ELF group" group-3.s
+ objcopy_test_readelf "ELF group" group-4.s
run_dump_test "copy-1"
}
run_dump_test "copy-2"
run_dump_test "copy-3"
+run_dump_test "copy-4"
if [is_elf_format] {
run_dump_test "strip-1"
run_dump_test "strip-2"
run_dump_test "strip-3"
+ run_dump_test "strip-4"
+ run_dump_test "strip-5"
+ run_dump_test "strip-6"
+ run_dump_test "strip-7"
+ run_dump_test "strip-8"
+ run_dump_test "strip-9"
+ run_dump_test "strip-10"
if { [istarget "i*86-*"] || [istarget "x86_64-*-*"] } {
# Check to make sure we don't strip a symbol named in relocations.
}
run_dump_test "localize-hidden-1"
+ run_dump_test "testranges"
+ run_dump_test "testranges-ia64"
}
run_dump_test "localize-hidden-2"