@ -26,8 +26,8 @@ if {[which $OBJCOPY] == 0} then {
send_user "Version [binutil_version $OBJCOPY]"
if {![binutils_assemble $AS $srcdir$subdir/bintest.s tmpdir/bintest.o]} then {
unresolved "objcopy (simple copy)"
return
}
@ -51,7 +51,7 @@ if ![string match "" $got] then {
setup_xfail "sh-*-coff" "sh-*-hms"
setup_xfail "arm-*-pe"
setup_xfail "m68*-*-hpux*" "m68*-*-sunos*" "m68*-*-coff" "m68*-*-vxworks*"
setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv3 *"
setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv*"
setup_xfail "i*86-*-linuxaout*" "i*86-*-aout*"
setup_xfail "i*86-*-sysv*" "i*86-*-isc*" "i*86-*-sco*" "i*86-*-coff"
setup_xfail "i*86-*-aix*" "i*86-*-go32*"
@ -61,7 +61,7 @@ if ![string match "" $got] then {
setup_xfail "h8500-*-hms" "h8500-*-coff"
setup_xfail "hppa*-*-*"
clear_xfail "hppa*-*-*elf*"
setup_xfail "m88*-*-coff" "m88*-motorola-sysv3 *"
setup_xfail "m88*-*-coff" "m88*-motorola-sysv*"
setup_xfail "z8*-*-coff"
if [string match "" $exec_output] then {
@ -255,3 +255,147 @@ if {$low == "" || $origstart == ""} then {
}
}
}
# Test stripping an object.
proc strip_test { } {
global CC
global STRIP
global STRIPFLAGS
global NM
global NMFLAGS
global srcdir
global subdir
set test "strip"
if { [which $CC] == 0 } {
untested $test
return
}
if ![binutils_compile $CC "-g -c" $srcdir/$subdir/testprog.c tmpdir/testprog.o] {
unresolved $test
return
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS tmpdir/testprog.o"]
if ![string match "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run $NM "-a $NMFLAGS tmpdir/testprog.o"]
if ![string match "No symbols in *" $exec_output] {
fail $test
return
}
pass $test
}
strip_test
# Build a final executable.
proc copy_setup { } {
global CC
global srcdir
global subdir
if ![isnative] {
return 1
}
if { [which $CC] == 0 } {
return 2
}
if ![binutils_compile $CC "-g" $srcdir/$subdir/testprog.c tmpdir/testprog] {
return 3
}
set exec_output [binutils_run tmpdir/testprog ""]
if ![string match "ok" $exec_output] {
return 3
}
return 0
}
# Test copying an executable.
proc copy_executable { prog flags test1 test2 } {
set exec_output [binutils_run $prog "$flags tmpdir/testprog tmpdir/copyprog"]
if ![string match "" $exec_output] {
fail $test1
fail $test2
return
}
set exec_output [binutils_run "cmp" "tmpdir/testprog tmpdir/copyprog"]
if [string match "" $exec_output] then {
pass $test1
} else {
send_log "$exec_output\n"
verbose "$exec_output"
# This will fail for many reasons. For example, it will most
# likely fail if the system linker is used. Therefore, we do
# not insist that it pass. If you are using an assembler and
# linker based on the same BFD as objcopy, it is worth
# investigating to see why this failure occurs.
setup_xfail "*-*-*"
fail $test1
}
set exec_output [binutils_run tmpdir/copyprog ""]
if ![string match "ok" $exec_output] {
fail $test2
} else {
pass $test2
}
}
# Test stripping an executable
proc strip_executable { prog flags test } {
set exec_output [binutils_run $prog "$flags tmpdir/copyprog"]
if ![string match "" $exec_output] {
fail $test
return
}
set exec_output [binutils_run tmpdir/copyprog ""]
if ![string match "ok" $exec_output] {
fail $test
} else {
pass $test
}
}
set test1 "simple objcopy of executable"
set test2 "run objcopy of executable"
set test3 "run stripped executable"
switch [copy_setup] {
"1" {
# do nothing
}
"2" {
untested $test1
untested $test2
untested $test3
}
"3" {
unresolved $test1
unresolved $test2
unresolved $test3
}
"0" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2"
strip_executable "$STRIP" "$STRIPFLAGS" "$test3"
}
}