# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile ${copyfile}.o"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy ($testname)"
} else {
send_log "cmp $tempfile ${copyfile}.o\n"
clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "*-*-*elf*"
clear_xfail "m68*-*-sysv4*"
- if [string match "" $exec_output] then {
+ if [string equal "" $exec_output] then {
pass "objcopy ($testname)"
} else {
send_log "$exec_output\n"
set reversed ${tempfile}-reversed
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -j .data --reverse-bytes=4 $tempfile $reversed"]
-if ![string match "" $got] then {
+if ![string equal "" $got] then {
fail "objcopy --reverse-bytes"
} else {
if [is_remote host] {
set got [binutils_run $OBJCOPY "-I binary -i 4 -b 0 --interleave-width 2 ${sequence_file} ${copyfile}"]
-if ![string match "" $got] then {
+if ![string equal "" $got] then {
fail "objcopy -i --interleave-width"
} else {
if [is_remote host] {
send_log "$line\n"
verbose $line
- if ![string match "1256" $line] then {
+ if ![string equal "1256" $line] then {
fail "objcopy -i --interleave-width"
}
pass "objcopy -i --interleave-width"
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${srecfile}"]
-if ![string match "" $got] then {
+if ![string equal "" $got] then {
fail "objcopy -O srec"
} else {
if [is_remote host] {
set origstart ""
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --set-start 0x7654 $tempfile ${copyfile}.srec"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy --set-start"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-start 0x123 $tempfile ${copyfile}.srec"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy --adjust-start"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
perror "objdump can not recognize bintest.o"
} else {
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec --adjust-vma 0x123 $tempfile ${copyfile}.srec"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy --adjust-vma"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -fh ${copyfile}.srec"]
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $arg $tempfile ${copyfile}.srec"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy --adjust-section-vma +"
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
regsub -all "\\+4" $arg "=[expr $low + 4]" argeq
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $argeq $tempfile ${copyfile}.srec"]
- if ![string match "" $got] then {
+ if ![string equal "" $got] then {
fail "objcopy --adjust-section-vma ="
} else {
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.in"
set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.in"]
if { [lindex $exec_output 0] != 0 } then {
- unresolved "$test preserving OS/ABI"
+ unresolved "$test preserving OS/ABI"
set osabi_fail "true"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.in"
remote_file build delete tmpdir/libstrip.a
set exec_output [binutils_run $AR "rc $archive ${objfile}"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
- unresolved "$test preserving OS/ABI"
+ unresolved "$test preserving OS/ABI"
return
}
set exec_output [binutils_run $STRIP "-g $archive"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
- unresolved "$test preserving OS/ABI"
+ unresolved "$test preserving OS/ABI"
return
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
- unresolved "$test preserving OS/ABI"
+ unresolved "$test preserving OS/ABI"
return
}
verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.out"
set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.out"]
if { [lindex $exec_output 0] != 0 } then {
- unresolved "$test preserving OS/ABI"
+ unresolved "$test preserving OS/ABI"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.out"
catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
return
}
}
set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
return
}
global gcc_gas_flag
global test_prog
global host_triplet
-
+
set res [build_wrapper testglue.o]
set flags { debug }
-
+
if { [istarget *-*-uclinux*] && ![istarget tic6x-*-*] } {
return 1
}
-
+
if { $res != "" } {
lappend flags "additional_flags=[lindex $res 1]"
set add_libs "testglue.o"
if { $status != "pass" } {
send_log "cannot run executable, status = ${status} on ${host_triplet}\n"
- if { [istarget $host_triplet] } {
- return 3
- }
- set status "pass"
+ return 3
}
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]
set exec_output [binutils_run $prog "$flags $testfile $testcopy"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test1
- if [string match "" $test2] {
+ if [string equal "" $test2] {
return
}
fail $test2
set status [remote_exec build "cmp" "tmpdir/$test_prog tmpdir/copyprog"]
set exec_output [lindex $status 1]
- if [string match "" $exec_output] then {
+ if [string equal "" $exec_output] then {
pass $test1
} else {
send_log "$exec_output\n"
setup_xfail "arm*-*-pe"
setup_xfail "*-*-mingw*"
setup_xfail "*-*-cygwin*"
-
+
fail $test1
}
- if [string match "" $test2] {
+ if [string equal "" $test2] {
return
}
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 {
# Test stripping an executable
-proc strip_executable { prog flags test } {
+proc strip_executable { prog flags test1 test2 } {
global NM
global NMFLAGS
global READELF
- global host_triplet
remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.in"
set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.in"]
if { [lindex $exec_output 0] != 0 } then {
- unresolved "$test preserving OS/ABI"
+ unresolved "$test1 preserving OS/ABI"
set osabi_fail "true"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.in"
}
set exec_output [binutils_run $prog "$flags ${copyfile}"]
- if ![string match "" $exec_output] {
- fail $test
+ if ![string equal "" $exec_output] {
+ fail $test1
+ if [string equal "" $test2] {
+ return
+ }
+ fail $test2
return
}
remote_upload host ${copyfile} 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
- }
-
if { $osabi_fail != "true" && [is_elf_format] } {
verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.out"
set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.out"]
if { [lindex $exec_output 0] != 0 } then {
- unresolved "$test preserving OS/ABI"
+ unresolved "$test1 preserving OS/ABI"
} else {
verbose -log "grep OS/ABI tmpdir/osabi.out"
catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
if { "$osabi_in" == "$osabi_out" } {
- pass "$test preserving OS/ABI"
+ pass "$test1 preserving OS/ABI"
} else {
- fail "$test preserving OS/ABI"
+ fail "$test1 preserving OS/ABI"
}
}
}
set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
if ![string match "*: no symbols*" $exec_output] {
- fail $test
+ fail $test1
return
}
- pass $test
+
+ if [string equal "" $test2] {
+ return
+ }
+
+ set result [remote_load target tmpdir/striprog]
+ set status [lindex $result 0]
+ if { $status != "pass" } {
+ fail $test2
+ return
+ }
+
+ pass $test2
}
# Test stripping an executable with saving a symbol
-proc strip_executable_with_saving_a_symbol { prog flags test } {
+proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } {
global NM
global NMFLAGS
- global host_triplet
remote_file build delete tmpdir/striprog
remote_download build tmpdir/copyprog tmpdir/striprog
}
set exec_output [binutils_run $prog "$flags ${copyfile}"]
- if ![string match "" $exec_output] {
- fail $test
+ if ![string equal "" $exec_output] {
+ fail $test1
+ if [string equal "" $test2] {
+ return
+ }
+ fail $test2
return
}
- if [is_remote host] {
- remote_upload host ${copyfile} 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
- }
-
set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
if { [istarget mmix-knuth-mmixware] } {
# Whenever there's a symbol in the mmo format, there's the symbol
if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
&& ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
- fail $test
+ fail $test1
return
}
- pass $test
+
+ if [string equal "" $test2] {
+ return
+ }
+
+ if [is_remote host] {
+ remote_upload host ${copyfile} tmpdir/striprog
+ }
+
+ set result [remote_load target tmpdir/striprog]
+ set status [lindex $result 0]
+ if { $status != "pass" } {
+ fail $test2
+ return
+ }
+
+ pass $test2
}
# 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 exec_output [binutils_run $prog1 "$flags1 ${copyfile}"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test1
return
}
pass $test1
set exec_output [binutils_run $prog2 "$flags2 ${copyfile}"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test2
return
}
}
set exec_output [binutils_run $prog "$flags ${copyfile}"]
- if ![string match "" $exec_output] {
+ if ![string equal "" $exec_output] {
fail $test
return
}
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"
+set test1r "run objcopy of executable"
+set test2 "strip executable"
+set test2r "run stripped executable"
+set test3 "strip executable with saving a symbol"
+set test3r "run stripped executable with saving a symbol"
+set test4 "keep only debug data"
+set test5 "simple objcopy of debug data"
if [is_elf_format] {
- set test7 "NOBITS sections retain sh_link field"
+ set test6 "NOBITS sections retain sh_link field"
}
switch [copy_setup] {
}
"2" {
untested $test1
+ untested $test1r
untested $test2
+ untested $test2r
untested $test3
+ untested $test3r
untested $test4
untested $test5
- untested $test6
if [is_elf_format] {
- untested $test7
+ untested $test6
}
}
"3" {
copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" ""
- unsupported $test2
- unsupported $test3
- unsupported $test4
- unsupported $test5
- unsupported $test6
+ unsupported $test1r
+ strip_executable "$STRIP" "$STRIPFLAGS" "$test2" ""
+ unsupported $test2r
+ strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" ""
+ unsupported $test3r
+ keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \
+ "$OBJCOPY" "$OBJCOPYFLAGS" "$test5"
if [is_elf_format] {
- unsupported $test7
+ keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$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"
+ copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test1r"
+ strip_executable "$STRIP" "$STRIPFLAGS" "$test2" "$test2r"
+ strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test3" "$test3r"
+ keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test4" \
+ "$OBJCOPY" "$OBJCOPYFLAGS" "$test5"
if [is_elf_format] {
- keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test7"
+ keep_debug_symbols_and_check_links "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test6"
}
}
}
verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
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 {
+ || ![string equal "" [lindex $exec_output 1]] } then {
fail "objcopy ($testname)"
return
}
return
}
set exec_output [prune_warnings [lindex $exec_output 1]]
- if ![string match "" $exec_output] then {
+ if ![string equal "" $exec_output] then {
unresolved "objcopy ($testname)"
return
}
return
}
set exec_output [prune_warnings [lindex $exec_output 1]]
- if ![string match "" $exec_output] then {
+ if ![string equal "" $exec_output] then {
unresolved "objcopy ($testname)"
return
}
catch "exec diff tmpdir/bintest.o.out tmpdir/copy.o.out" exec_output
set exec_output [prune_warnings $exec_output]
- if [string match "" $exec_output] then {
+ if [string equal "" $exec_output] then {
pass "objcopy ($testname)"
} else {
fail "objcopy ($testname)"