mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 07:53:51 +08:00
Test binutils_assemble return value
This is a followup to "binutils nm testsuite tidy". Since the perror in binutils_assemble has been removed, we need to take more care in failure paths. The patch also fixed a number of .exp files that have multiple tests, where an assembly failure returns from the .exp file. In most cases it is nicer to attempt all tests. * testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR if assembly fails. * testsuite/binutils-all/arc/objdump.exp (check_assembly): If objfile is empty, fail test. * testsuite/binutils-all/arm/objdump.exp: Don't return if assembly fails for a test, continue on to other tests. * testsuite/binutils-all/bfin/objdump.exp: Likewise. * testsuite/binutils-all/hppa/objdump.exp: Likewise. * testsuite/binutils-all/m68k/objdump.exp: Likewise. * testsuite/binutils-all/vax/objdump.exp: Likewise. * testsuite/binutils-all/size.exp: Likewise. * testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test. * testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail. * testsuite/binutils-all/objdump.exp: Report assembly fails.
This commit is contained in:
@ -1,3 +1,20 @@
|
||||
2017-12-19 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR
|
||||
if assembly fails.
|
||||
* testsuite/binutils-all/arc/objdump.exp (check_assembly): If
|
||||
objfile is empty, fail test.
|
||||
* testsuite/binutils-all/arm/objdump.exp: Don't return if assembly
|
||||
fails for a test, continue on to other tests.
|
||||
* testsuite/binutils-all/bfin/objdump.exp: Likewise.
|
||||
* testsuite/binutils-all/hppa/objdump.exp: Likewise.
|
||||
* testsuite/binutils-all/m68k/objdump.exp: Likewise.
|
||||
* testsuite/binutils-all/vax/objdump.exp: Likewise.
|
||||
* testsuite/binutils-all/size.exp: Likewise.
|
||||
* testsuite/binutils-all/nm.exp: Likewise. Move PR12753 test.
|
||||
* testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail.
|
||||
* testsuite/binutils-all/objdump.exp: Report assembly fails.
|
||||
|
||||
2017-12-18 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 22532
|
||||
|
@ -449,6 +449,7 @@ proc unique_symbol { } {
|
||||
|
||||
if ![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o] {
|
||||
unresolved $testname
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
|
@ -52,6 +52,10 @@ proc check_assembly { testname objfile expected { disas_flags "" } } {
|
||||
global OBJDUMP
|
||||
global OBJDUMPFLAGS
|
||||
|
||||
if [string equal "" $objfile] then {
|
||||
fail $testname
|
||||
return
|
||||
}
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \
|
||||
$objfile"]
|
||||
|
||||
|
@ -34,35 +34,36 @@ send_user "Version [binutil_version $OBJDUMP]"
|
||||
###########################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/thumb2-cond.s tmpdir/thumb2-cond.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/thumb2-cond.o]
|
||||
fail "thumb2-cond (assembling)"
|
||||
} else {
|
||||
set objfile tmpdir/thumb2-cond.o
|
||||
}
|
||||
|
||||
# Make sure that conditional instructions are correctly decoded.
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/thumb2-cond.o]
|
||||
} else {
|
||||
set objfile tmpdir/thumb2-cond.o
|
||||
}
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"]
|
||||
# Make sure that conditional instructions are correctly decoded.
|
||||
|
||||
set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr"
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"]
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "thumb2-cond test1"
|
||||
} else {
|
||||
fail "thumb2-cond test1"
|
||||
}
|
||||
set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr"
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=10 $objfile"]
|
||||
if [regexp $want $got] then {
|
||||
pass "thumb2-cond test1"
|
||||
} else {
|
||||
fail "thumb2-cond test1"
|
||||
}
|
||||
|
||||
set want "bx\[ \t\]*lr"
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=10 $objfile"]
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "thumb2-cond test2"
|
||||
} else {
|
||||
fail "thumb2-cond test2"
|
||||
set want "bx\[ \t\]*lr"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "thumb2-cond test2"
|
||||
} else {
|
||||
fail "thumb2-cond test2"
|
||||
}
|
||||
}
|
||||
|
||||
###########################
|
||||
@ -70,45 +71,47 @@ if [regexp $want $got] then {
|
||||
###########################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/simple.s tmpdir/simple.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/simple.o]
|
||||
} else {
|
||||
set objfile tmpdir/simple.o
|
||||
}
|
||||
|
||||
# Make sure multiple disassemblies come out the same
|
||||
|
||||
set got [binutils_run $OBJDUMP "-dr $objfile $objfile"]
|
||||
|
||||
set want "$objfile:\[ \]*file format.*$objfile:\[ \]*file format.*push.*add.*sub.*str.*add.*ldmfd"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "multiple input files"
|
||||
} else {
|
||||
fail "multiple input files"
|
||||
} else {
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/simple.o]
|
||||
} else {
|
||||
set objfile tmpdir/simple.o
|
||||
}
|
||||
|
||||
# Make sure multiple disassemblies come out the same
|
||||
|
||||
set got [binutils_run $OBJDUMP "-dr $objfile $objfile"]
|
||||
|
||||
set want "$objfile:\[ \]*file format.*$objfile:\[ \]*file format.*push.*add.*sub.*str.*add.*ldmfd"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "multiple input files"
|
||||
} else {
|
||||
fail "multiple input files"
|
||||
}
|
||||
}
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/rvct_symbol.s tmpdir/rvct_symbol.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/rvct_symbol.o]
|
||||
} else {
|
||||
set objfile tmpdir/rvct_symbol.o
|
||||
}
|
||||
|
||||
# Make sure multiple disassemblies come out the same
|
||||
|
||||
set got [binutils_run $OBJDUMP "-D $objfile $objfile"]
|
||||
|
||||
set want "foo.*global_a.*global_b"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "skip rvct symbol"
|
||||
} else {
|
||||
fail "skip rvct symbol"
|
||||
} else {
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/rvct_symbol.o]
|
||||
} else {
|
||||
set objfile tmpdir/rvct_symbol.o
|
||||
}
|
||||
|
||||
# Make sure multiple disassemblies come out the same
|
||||
|
||||
set got [binutils_run $OBJDUMP "-D $objfile $objfile"]
|
||||
|
||||
set want "foo.*global_a.*global_b"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "skip rvct symbol"
|
||||
} else {
|
||||
fail "skip rvct symbol"
|
||||
}
|
||||
}
|
||||
|
@ -30,23 +30,24 @@ send_user "Version [binutil_version $OBJDUMP]"
|
||||
###################################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/unknown-mode.s tmpdir/unknown-mode.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/unknown-mode.o]
|
||||
fail "unknown mode test (assembling)"
|
||||
} else {
|
||||
set objfile tmpdir/unknown-mode.o
|
||||
}
|
||||
|
||||
# Make sure that the unknown mode does not cause abort.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D $objfile"]
|
||||
|
||||
set want "e1 c1\[ \t\]*ILLEGAL.*34 98 .*\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "unknown mode test"
|
||||
} else {
|
||||
fail "unknown mode test"
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/unknown-mode.o]
|
||||
} else {
|
||||
set objfile tmpdir/unknown-mode.o
|
||||
}
|
||||
|
||||
# Make sure that the unknown mode does not cause abort.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D $objfile"]
|
||||
|
||||
set want "e1 c1\[ \t\]*ILLEGAL.*34 98 .*\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "unknown mode test"
|
||||
} else {
|
||||
fail "unknown mode test"
|
||||
}
|
||||
}
|
||||
|
@ -42,30 +42,31 @@ if {[which $OBJDUMP] == 0} then {
|
||||
send_user "Version [binutil_version $OBJDUMP]"
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/addendbug.s tmpdir/addendbug.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/addendbug.o]
|
||||
fail "addendbug test (assembling)"
|
||||
} else {
|
||||
set objfile tmpdir/addendbug.o
|
||||
}
|
||||
|
||||
# Make sure the SOM BFD code sign extends constants in R_DATA_OVERRIDE fixups.
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/addendbug.o]
|
||||
} else {
|
||||
set objfile tmpdir/addendbug.o
|
||||
}
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"]
|
||||
# Make sure the SOM BFD code sign extends constants in
|
||||
# R_DATA_OVERRIDE fixups.
|
||||
|
||||
if [istarget hppa*-*-*elf*] then {
|
||||
set want "00000000 R_PARISC_DPREL21L\[ \]+is_idchar-0x00000020.*"
|
||||
} else {
|
||||
set want "00000000 R_DP_RELATIVE\[ \]+is_idchar-0x00000020.*"
|
||||
}
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"]
|
||||
|
||||
if [istarget hppa*-*-*elf*] then {
|
||||
set want "00000000 R_PARISC_DPREL21L\[ \]+is_idchar-0x00000020.*"
|
||||
} else {
|
||||
set want "00000000 R_DP_RELATIVE\[ \]+is_idchar-0x00000020.*"
|
||||
}
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "addendbug test"
|
||||
} else {
|
||||
fail "addendbug test"
|
||||
if [regexp $want $got] then {
|
||||
pass "addendbug test"
|
||||
} else {
|
||||
fail "addendbug test"
|
||||
}
|
||||
}
|
||||
|
||||
###########################
|
||||
@ -73,23 +74,24 @@ if [regexp $want $got] then {
|
||||
###########################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/freg.s tmpdir/freg.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/freg.o]
|
||||
fail "freg test (assembling)"
|
||||
} else {
|
||||
set objfile tmpdir/freg.o
|
||||
}
|
||||
|
||||
# Make sure that we get R float regs like we're supposed to
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "fmpyfadd,sgl fr4,fr4R,fr5R,fr5"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "freg test"
|
||||
} else {
|
||||
fail "freg test"
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/freg.o]
|
||||
} else {
|
||||
set objfile tmpdir/freg.o
|
||||
}
|
||||
|
||||
# Make sure that we get R float regs like we're supposed to
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "fmpyfadd,sgl fr4,fr4R,fr5R,fr5"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "freg test"
|
||||
} else {
|
||||
fail "freg test"
|
||||
}
|
||||
}
|
||||
|
@ -30,25 +30,26 @@ send_user "Version [binutil_version $OBJDUMP]"
|
||||
###########################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/movem.s tmpdir/movem.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/movem.o]
|
||||
} else {
|
||||
set objfile tmpdir/movem.o
|
||||
}
|
||||
|
||||
# Make sure that the movem is correctly decoded.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "moveml %d0-%d3,%sp@-.*moveml %d0-%d3,%sp@\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "movem test"
|
||||
} else {
|
||||
fail "movem test"
|
||||
} else {
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/movem.o]
|
||||
} else {
|
||||
set objfile tmpdir/movem.o
|
||||
}
|
||||
|
||||
# Make sure that the movem is correctly decoded.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "moveml %d0-%d3,%sp@-.*moveml %d0-%d3,%sp@\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "movem test"
|
||||
} else {
|
||||
fail "movem test"
|
||||
}
|
||||
}
|
||||
|
||||
###########################
|
||||
@ -56,23 +57,24 @@ if [regexp $want $got] then {
|
||||
###########################
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/fnop.s tmpdir/fnop.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/fnop.o]
|
||||
} else {
|
||||
set objfile tmpdir/fnop.o
|
||||
}
|
||||
|
||||
# Make sure that fnop is decoded as fnop, not fbf.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "fnop *\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "fnop test"
|
||||
} else {
|
||||
fail "fnop test"
|
||||
} else {
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/fnop.o]
|
||||
} else {
|
||||
set objfile tmpdir/fnop.o
|
||||
}
|
||||
|
||||
# Make sure that fnop is decoded as fnop, not fbf.
|
||||
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $objfile"]
|
||||
|
||||
set want "fnop *\[\r\n\]"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "fnop test"
|
||||
} else {
|
||||
fail "fnop test"
|
||||
}
|
||||
}
|
||||
|
@ -31,119 +31,94 @@ send_user "Version [binutil_version $NM]"
|
||||
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set tempfile [remote_download host tmpdir/bintest.o]
|
||||
fail "nm (assembling)"
|
||||
} else {
|
||||
set tempfile tmpdir/bintest.o
|
||||
}
|
||||
|
||||
# Test nm with no arguments.
|
||||
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
|
||||
# This test does not work correctly on XCOFF targets, because XCOFF
|
||||
# does not enter static symbols in the symbol table.
|
||||
setup_xfail "*-*-aix*"
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS $tempfile"]
|
||||
|
||||
if [info exists vars] then { unset vars }
|
||||
while {[regexp "(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} {
|
||||
set vars($symbol) $type
|
||||
set got $rest
|
||||
}
|
||||
|
||||
if {![info exists vars(text_symbol)] \
|
||||
|| $vars(text_symbol) != "T" \
|
||||
|| ![info exists vars(data_symbol)] \
|
||||
|| $vars(data_symbol) != "D" \
|
||||
|| ![info exists vars(common_symbol)] \
|
||||
|| $vars(common_symbol) != "C" \
|
||||
|| ![info exists vars(external_symbol)] \
|
||||
|| $vars(external_symbol) != "U" \
|
||||
|| ![info exists vars(static_text_symbol)] \
|
||||
|| $vars(static_text_symbol) != "t" \
|
||||
|| ![info exists vars(static_data_symbol)] \
|
||||
|| $vars(static_data_symbol) != "d"} {
|
||||
fail "nm (no arguments)"
|
||||
} else {
|
||||
pass "nm (no arguments)"
|
||||
}
|
||||
|
||||
# Test nm -g
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -g $tempfile"]
|
||||
|
||||
if [info exists vars] then { unset vars }
|
||||
while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} {
|
||||
set vars($symbol) 1
|
||||
set got $rest
|
||||
}
|
||||
|
||||
if {![info exists vars(text_symbol)] \
|
||||
|| ![info exists vars(data_symbol)] \
|
||||
|| ![info exists vars(common_symbol)] \
|
||||
|| ![info exists vars(external_symbol)] \
|
||||
|| [info exists vars(static_text_symbol)] \
|
||||
|| [info exists vars(static_data_symbol)]} {
|
||||
fail "nm -g"
|
||||
} else {
|
||||
pass "nm -g"
|
||||
}
|
||||
|
||||
if [is_elf_format] {
|
||||
# PR binutils/12753
|
||||
# Test nm -g on a unique global symbol.
|
||||
if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then {
|
||||
unsupported "nm -g on unique symbols"
|
||||
if [is_remote host] {
|
||||
set tempfile [remote_download host tmpdir/bintest.o]
|
||||
} else {
|
||||
if [is_remote host] {
|
||||
set tmpfile [remote_download host tmpdir/unique.o]
|
||||
} else {
|
||||
set tmpfile tmpdir/unique.o
|
||||
}
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -g $tmpfile"]
|
||||
|
||||
if [regexp "u foo" $got] then {
|
||||
pass "nm -g on unique symbols"
|
||||
} else {
|
||||
fail "nm -g on unique symbols"
|
||||
}
|
||||
|
||||
if { $verbose < 1 } {
|
||||
remote_file host delete "tmpdir/unique.o"
|
||||
}
|
||||
set tempfile tmpdir/bintest.o
|
||||
}
|
||||
}
|
||||
|
||||
# Test nm -P
|
||||
# Test nm with no arguments.
|
||||
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
|
||||
# This test does not work correctly on XCOFF targets, because XCOFF
|
||||
# does not enter static symbols in the symbol table.
|
||||
setup_xfail "*-*-aix*"
|
||||
# This test does not work correctly on XCOFF targets, because XCOFF
|
||||
# does not enter static symbols in the symbol table.
|
||||
setup_xfail "*-*-aix*"
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -P $tempfile"]
|
||||
set got [binutils_run $NM "$NMFLAGS $tempfile"]
|
||||
|
||||
set want "common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*"
|
||||
if [info exists vars] then { unset vars }
|
||||
while {[regexp "(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} {
|
||||
set vars($symbol) $type
|
||||
set got $rest
|
||||
}
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "nm -P"
|
||||
} else {
|
||||
fail "nm -P"
|
||||
if {![info exists vars(text_symbol)] \
|
||||
|| $vars(text_symbol) != "T" \
|
||||
|| ![info exists vars(data_symbol)] \
|
||||
|| $vars(data_symbol) != "D" \
|
||||
|| ![info exists vars(common_symbol)] \
|
||||
|| $vars(common_symbol) != "C" \
|
||||
|| ![info exists vars(external_symbol)] \
|
||||
|| $vars(external_symbol) != "U" \
|
||||
|| ![info exists vars(static_text_symbol)] \
|
||||
|| $vars(static_text_symbol) != "t" \
|
||||
|| ![info exists vars(static_data_symbol)] \
|
||||
|| $vars(static_data_symbol) != "d"} {
|
||||
fail "nm (no arguments)"
|
||||
} else {
|
||||
pass "nm (no arguments)"
|
||||
}
|
||||
|
||||
# Test nm -g
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -g $tempfile"]
|
||||
|
||||
if [info exists vars] then { unset vars }
|
||||
while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} {
|
||||
set vars($symbol) 1
|
||||
set got $rest
|
||||
}
|
||||
|
||||
if {![info exists vars(text_symbol)] \
|
||||
|| ![info exists vars(data_symbol)] \
|
||||
|| ![info exists vars(common_symbol)] \
|
||||
|| ![info exists vars(external_symbol)] \
|
||||
|| [info exists vars(static_text_symbol)] \
|
||||
|| [info exists vars(static_data_symbol)]} {
|
||||
fail "nm -g"
|
||||
} else {
|
||||
pass "nm -g"
|
||||
}
|
||||
|
||||
# Test nm -P
|
||||
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
|
||||
# This test does not work correctly on XCOFF targets, because XCOFF
|
||||
# does not enter static symbols in the symbol table.
|
||||
setup_xfail "*-*-aix*"
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -P $tempfile"]
|
||||
|
||||
set want "common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "nm -P"
|
||||
} else {
|
||||
fail "nm -P"
|
||||
}
|
||||
}
|
||||
|
||||
# Test nm --size-sort
|
||||
@ -174,32 +149,57 @@ if { [is_elf_format]
|
||||
}
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set tempfile [remote_download host tmpdir/nm-1.o]
|
||||
fail "nm --size-sort (assembling)"
|
||||
} else {
|
||||
set tempfile tmpdir/nm-1.o
|
||||
}
|
||||
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
if [is_remote host] {
|
||||
set tempfile [remote_download host tmpdir/nm-1.o]
|
||||
} else {
|
||||
set tempfile tmpdir/nm-1.o
|
||||
}
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"]
|
||||
# This test does not work correctly on ECOFF targets, because ECOFF
|
||||
# stores most symbols twice, which messes up the nm output.
|
||||
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
|
||||
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
||||
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
||||
|
||||
set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1"
|
||||
set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"]
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "nm --size-sort"
|
||||
} else {
|
||||
fail "nm --size-sort"
|
||||
set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1"
|
||||
|
||||
if [regexp $want $got] then {
|
||||
pass "nm --size-sort"
|
||||
} else {
|
||||
fail "nm --size-sort"
|
||||
}
|
||||
}
|
||||
|
||||
if [is_elf_format] {
|
||||
# PR binutils/12753
|
||||
# Test nm -g on a unique global symbol.
|
||||
if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then {
|
||||
unsupported "nm -g on unique symbols"
|
||||
} else {
|
||||
if [is_remote host] {
|
||||
set tmpfile [remote_download host tmpdir/unique.o]
|
||||
} else {
|
||||
set tmpfile tmpdir/unique.o
|
||||
}
|
||||
|
||||
set got [binutils_run $NM "$NMFLAGS -g $tmpfile"]
|
||||
|
||||
if [regexp "u foo" $got] then {
|
||||
pass "nm -g on unique symbols"
|
||||
} else {
|
||||
fail "nm -g on unique symbols"
|
||||
}
|
||||
|
||||
if { $verbose < 1 } {
|
||||
remote_file host delete "tmpdir/unique.o"
|
||||
}
|
||||
}
|
||||
|
||||
# PR binutils/20751
|
||||
# Test nm --with-symbol-versions
|
||||
|
||||
|
@ -47,7 +47,6 @@ proc objcopy_test {testname srcfile} {
|
||||
global copyfile
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/${srcfile} $tempfile]} then {
|
||||
perror "unresolved $testname"
|
||||
unresolved "objcopy ($testname)"
|
||||
remote_file host delete $tempfile
|
||||
return
|
||||
|
@ -62,9 +62,11 @@ if [regexp $want $got] then {
|
||||
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
||||
fail "objdump (assembling)"
|
||||
return
|
||||
}
|
||||
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest2.o]} then {
|
||||
fail "objdump (assembling)"
|
||||
return
|
||||
}
|
||||
if [is_remote host] {
|
||||
|
@ -31,51 +31,52 @@ send_user "Version [binutil_version $SIZE]"
|
||||
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
||||
return
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set testfile [remote_download host tmpdir/bintest.o]
|
||||
fail "size (assembling)"
|
||||
} else {
|
||||
set testfile tmpdir/bintest.o
|
||||
}
|
||||
|
||||
set dec "\[0-9\]+"
|
||||
set hex "\[0-9a-fA-F\]+"
|
||||
if [is_remote host] {
|
||||
set testfile [remote_download host tmpdir/bintest.o]
|
||||
} else {
|
||||
set testfile tmpdir/bintest.o
|
||||
}
|
||||
|
||||
# Test size with no arguments
|
||||
set dec "\[0-9\]+"
|
||||
set hex "\[0-9a-fA-F\]+"
|
||||
|
||||
set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
|
||||
# Test size with no arguments
|
||||
|
||||
set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}"
|
||||
set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
|
||||
|
||||
if ![regexp $want $got all text data bss dtot hextot] then {
|
||||
fail "size (no arguments)"
|
||||
} else {
|
||||
if {$text < 8 || $data < 4} then {
|
||||
# The z80-coff port defaults to a "binary" like output
|
||||
# file format which does not include a data section.
|
||||
setup_xfail "z80-*-coff"
|
||||
set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}"
|
||||
|
||||
if ![regexp $want $got all text data bss dtot hextot] then {
|
||||
fail "size (no arguments)"
|
||||
} else {
|
||||
pass "size (no arguments)"
|
||||
if {$text < 8 || $data < 4} then {
|
||||
# The z80-coff port defaults to a "binary" like output
|
||||
# file format which does not include a data section.
|
||||
setup_xfail "z80-*-coff"
|
||||
fail "size (no arguments)"
|
||||
} else {
|
||||
pass "size (no arguments)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Test size -A
|
||||
# Test size -A
|
||||
|
||||
set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
|
||||
set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
|
||||
|
||||
set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[ \]($dec)\[ \]+$dec"
|
||||
set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[ \]($dec)\[ \]+$dec"
|
||||
|
||||
if ![regexp $want $got all textname textsize dataname datasize] then {
|
||||
fail "size -A"
|
||||
} else {
|
||||
verbose "text size: $textsize"
|
||||
verbose "data size: $datasize"
|
||||
if {$textsize < 8 || $datasize < 4} then {
|
||||
if ![regexp $want $got all textname textsize dataname datasize] then {
|
||||
fail "size -A"
|
||||
} else {
|
||||
pass "size -A"
|
||||
verbose "text size: $textsize"
|
||||
verbose "data size: $datasize"
|
||||
if {$textsize < 8 || $datasize < 4} then {
|
||||
fail "size -A"
|
||||
} else {
|
||||
pass "size -A"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,30 +34,31 @@ if {[which $OBJDUMP] == 0} then {
|
||||
send_user "Version [binutil_version $OBJDUMP]"
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/entrymask.s tmpdir/entrymask.o]} then {
|
||||
return
|
||||
}
|
||||
fail "entrymask test (assembling)"
|
||||
} else {
|
||||
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/entrymask.o]
|
||||
} else {
|
||||
set objfile tmpdir/entrymask.o
|
||||
}
|
||||
if [is_remote host] {
|
||||
set objfile [remote_download host tmpdir/entrymask.o]
|
||||
} else {
|
||||
set objfile tmpdir/entrymask.o
|
||||
}
|
||||
|
||||
#
|
||||
# We check both function entry points. The second one at offset 2 will
|
||||
# show up automatically on ELF targets, but needs to be set on a.out
|
||||
# targets.
|
||||
#
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d -M entry:0x0 -M entry:2 $objfile"]
|
||||
set want1 "\[ \]+0:\[ \]+10 01\[ \]+\\.word 0x0110.\*r8 r4"
|
||||
set want2 "\[ \]+2:\[ \]+24 02\[ \]+\\.word 0x0224.\*r9 r5 r2"
|
||||
if [regexp $want1 $got] then {
|
||||
pass "entrymask test 1"
|
||||
} else {
|
||||
fail "entrymask test 1"
|
||||
}
|
||||
if [regexp $want2 $got] then {
|
||||
pass "entrymask test 2"
|
||||
} else {
|
||||
fail "entrymask test 2"
|
||||
#
|
||||
# We check both function entry points. The second one at offset 2 will
|
||||
# show up automatically on ELF targets, but needs to be set on a.out
|
||||
# targets.
|
||||
#
|
||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -d -M entry:0x0 -M entry:2 $objfile"]
|
||||
set want1 "\[ \]+0:\[ \]+10 01\[ \]+\\.word 0x0110.\*r8 r4"
|
||||
set want2 "\[ \]+2:\[ \]+24 02\[ \]+\\.word 0x0224.\*r9 r5 r2"
|
||||
if [regexp $want1 $got] then {
|
||||
pass "entrymask test 1"
|
||||
} else {
|
||||
fail "entrymask test 1"
|
||||
}
|
||||
if [regexp $want2 $got] then {
|
||||
pass "entrymask test 2"
|
||||
} else {
|
||||
fail "entrymask test 2"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user