From 7f6a71ffb6ce85438f442a992e2def6eda2e1554 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 28 Aug 2007 13:21:58 +0000 Subject: [PATCH] bfd: 2007-08-28 Mark Shinwell Joseph Myers * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, then on type. binutils/testsuite: 2007-08-28 Mark Shinwell Joseph Myers * binutils-all/ar.exp (long_filenames): Delete temporary files on the host. * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if host is local. * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the srec file to be passed to binutils_run. (objcopy_test_readelf): Use remote_exec. * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. (readelf_test): Likewise. (readelf_wi_test): Likewise. * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if host is local. Use remote_exec. Use $tempfile not tmpdir/bintest.o. gas: 2007-08-28 Mark Shinwell Joseph Myers * as.c (main): Flush stderr before printing listings to ensure consistent output order across platforms. gas/testsuite: 2007-08-28 Mark Shinwell Joseph Myers * lib/gas-defs.exp (gas_version): Use remote_* functions instead of exec. (gas_host_run): New. (gas_run): Use gas_host_run. (gas_start): Likewise. (run_dump_test): Likewise. (objdump): Use gas_host_run. (objdump_start_no_subdir): Likewise. * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". * lib/run: Remove. * gas/macros/macros.exp: Download app4b.s to host. * gas/i386/i386.exp (gas_64_check): Use gas_host_run. (gas_32_check): Likewise. * gas/maxq10/maxq10.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/maxq20/maxq20.exp (gas_64_check): Likewise (gas_32_check): Likewise. * gas/sparc/sparc.exp (gas_64_check): Likewise. * gas/cfi/cfi.exp: Likewise. * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file for readelf output in place of pipe. * gas/all/gas.exp: Download incbin.dat to host. (do_comment): Allow \r\r\n. ld: 2007-08-28 Mark Shinwell Joseph Myers * ldlang.c (sort_sections_by_lma): Sort by internal id after lma for stable sort. ld/testsuite: 2007-08-28 Mark Shinwell Joseph Myers * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which $CC" if host is local. * ld-checks/checks.exp: Use run_host_cmd. * ld-elf/exclude.exp: Likewise. * ld-elf/elf.exp: Download merge.ld if host is remote. * ld-elf/binutils.exp (binutils_test): Use remote_exec. * ld-elf/tls_common.exp: Use run_host_cmd. * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is local. Use remote_exec. (run_host_cmd): New. (run_host_cmd_yesno): New. (default_ld_relocate): Use run_host_cmd_yesno. (default_ld_link): Likewise. (default_ld_simple_link): Use run_host_cmd. (default_ld_compile): Only check "which $ccprog" if host is local. Use remote_file and remote_exec. (default_ld_assemble): Only check "which $as" if host is local. Use run_host_cmd. (default_ld_nm): Use remote_exec, remote_upload and remote_file. (run_dump_test): Use remote_exec, remote_upload and remote_file. Only check "which $binary" if host is local. (run_ld_link_tests): Use remote_exec, remote_upload and remote_file. * ld-selective/selective.exp: Only check "which $CXX" if host is local. Use remote_exec. * ld-scripts/phdrs.exp: Only check "which $objdump" if host is local. Use run_host_cmd. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/weak.exp: Likewise. * ld-undefined/weak-undef.exp: Likewise. * ld-scripts/crossref.exp: Only check "which $CC" if host is local. Use run_host_cmd. * ld-scripts/map-address.exp: Upload map_address.map if host is remote. * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check "which $CC" and "which $CXX" if host is local. * ld-undefined/undefined.exp: Only check "which $CC" if host is local. Use remote_file and run_host_cmd. * config/default.exp: Use remote_exec to create tmpdir. --- bfd/ChangeLog | 6 + bfd/elf32-arm.c | 18 +- binutils/testsuite/ChangeLog | 17 ++ binutils/testsuite/binutils-all/ar.exp | 3 +- .../testsuite/binutils-all/arm/objdump.exp | 2 +- binutils/testsuite/binutils-all/objcopy.exp | 23 +- binutils/testsuite/binutils-all/readelf.exp | 16 +- binutils/testsuite/lib/utils-lib.exp | 15 +- gas/ChangeLog | 6 + gas/as.c | 2 + gas/testsuite/ChangeLog | 27 +++ gas/testsuite/gas/all/gas.exp | 3 +- gas/testsuite/gas/cfi/cfi.exp | 5 +- gas/testsuite/gas/elf/elf.exp | 8 +- gas/testsuite/gas/i386/i386.exp | 10 +- gas/testsuite/gas/macros/macros.exp | 1 + gas/testsuite/gas/maxq10/maxq10.exp | 9 +- gas/testsuite/gas/maxq20/maxq20.exp | 8 +- gas/testsuite/gas/sparc/sparc.exp | 5 +- gas/testsuite/lib/gas-defs.exp | 115 ++++++++-- gas/testsuite/lib/gas-dg.exp | 2 +- gas/testsuite/lib/run | 2 - ld/ChangeLog | 6 + ld/ldlang.c | 4 + ld/testsuite/ChangeLog | 43 ++++ ld/testsuite/config/default.exp | 4 +- ld/testsuite/ld-checks/checks.exp | 3 +- ld/testsuite/ld-elf/binutils.exp | 12 +- ld/testsuite/ld-elf/elf.exp | 4 + ld/testsuite/ld-elf/exclude.exp | 4 +- ld/testsuite/ld-elf/tls_common.exp | 3 +- ld/testsuite/ld-elfcomm/elfcomm.exp | 5 +- ld/testsuite/ld-scripts/crossref.exp | 15 +- ld/testsuite/ld-scripts/map-address.exp | 9 +- ld/testsuite/ld-scripts/phdrs.exp | 6 +- ld/testsuite/ld-scripts/phdrs2.exp | 5 +- ld/testsuite/ld-scripts/weak.exp | 5 +- ld/testsuite/ld-selective/selective.exp | 17 +- ld/testsuite/ld-srec/srec.exp | 9 +- ld/testsuite/ld-undefined/undefined.exp | 7 +- ld/testsuite/ld-undefined/weak-undef.exp | 5 +- ld/testsuite/lib/ld-lib.exp | 217 +++++++++--------- 42 files changed, 447 insertions(+), 239 deletions(-) delete mode 100755 gas/testsuite/lib/run diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 297cec93594..0fb40788f67 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma, + then on type. + 2007-08-28 Robert Sebastian Gerus * config.bfd: Add support for i[3-7]86-*-dragonfly*. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index ef066d3a79e..9c6130f6cc1 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -9774,8 +9774,22 @@ elf32_arm_new_section_hook (bfd *abfd, asection *sec) static int elf32_arm_compare_mapping (const void * a, const void * b) { - return ((const elf32_arm_section_map *) a)->vma - > ((const elf32_arm_section_map *) b)->vma; + const elf32_arm_section_map *amap = (const elf32_arm_section_map *) a; + const elf32_arm_section_map *bmap = (const elf32_arm_section_map *) b; + + if (amap->vma > bmap->vma) + return 1; + else if (amap->vma < bmap->vma) + return -1; + else if (amap->type > bmap->type) + /* Ensure results do not depend on the host qsort for objects with + multiple mapping symbols at the same address by sorting on type + after vma. */ + return 1; + else if (amap->type < bmap->type) + return -1; + else + return 0; } diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 46ba56812ac..c1fcd3ca117 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,20 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * binutils-all/ar.exp (long_filenames): Delete temporary files on + the host. + * binutils-all/arm/objdump.exp: Only check "which $OBJDUMP" if + host is local. + * binutils-all/objcopy.exp: Use ${srecfile} to get the name of the + srec file to be passed to binutils_run. + (objcopy_test_readelf): Use remote_exec. + * binutils-all/readelf.exp (readelf_find_size): Use remote_exec. + (readelf_test): Likewise. + (readelf_wi_test): Likewise. + * lib/utils-lib.exp (run_dump_test): Only check "which $binary" if + host is local. Use remote_exec. Use $tempfile not + tmpdir/bintest.o. + 2007-08-09 Alan Modra * binutils-all/copy-2.d (not-target): Match *-*-*aout. diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp index f90fed8b9b6..67504c3f72a 100644 --- a/binutils/testsuite/binutils-all/ar.exp +++ b/binutils/testsuite/binutils-all/ar.exp @@ -42,6 +42,7 @@ proc long_filenames { } { set file2 tmpdir/$n2 remote_file build delete $file1 + remote_file host delete $n1 # Some file systems truncate file names at 14 characters, which # makes it impossible to run this test. Check for that now. @@ -54,8 +55,8 @@ proc long_filenames { } { puts $f "first" close $f - remote_file build delete $file2 + remote_file host delete $n2 set status [catch "set f [open tmpdir/$n2 w]" errs] if { $status != 0 } { diff --git a/binutils/testsuite/binutils-all/arm/objdump.exp b/binutils/testsuite/binutils-all/arm/objdump.exp index 226363b62ee..8e435eb3f33 100644 --- a/binutils/testsuite/binutils-all/arm/objdump.exp +++ b/binutils/testsuite/binutils-all/arm/objdump.exp @@ -19,7 +19,7 @@ if {![istarget "arm*-*-*"]} then { return } -if {[which $OBJDUMP] == 0} then { +if {![is_remote host] && [which $OBJDUMP] == 0} then { perror "$OBJDUMP does not exist" return } diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index e05e622fb26..8c232d042da 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -194,7 +194,7 @@ if ![string match "" $got] then { 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" @@ -722,23 +722,32 @@ proc objcopy_test_readelf {testname srcfile} { } 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 diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp index 2979cfd3b5d..d8ba1c0d406 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -41,9 +41,12 @@ proc readelf_find_size { binary_file } { set readelf_size "" set testname "finding out ELF size with readelf -h" - catch "exec $READELF $READELFFLAGS -h $binary_file > readelf.out" got + set got [remote_exec host "$READELF $READELFFLAGS -h $binary_file" "" "/dev/null" "readelf.out"] + if [is_remote host] then { + remote_upload host "readelf.out" + } - if ![string match "" $got] then { + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]]} then { send_log $got fail $testname return @@ -76,13 +79,13 @@ proc readelf_test { options binary_file regexp_file xfails } { global subdir send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out\n" - catch "exec $READELF $READELFFLAGS $options $binary_file > readelf.out" got + set got [remote_exec host "$READELF $READELFFLAGS $options $binary_file" "" "/dev/null" "readelf.out"] foreach xfail $xfails { setup_xfail $xfail } - if ![string match "" $got] then { + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { fail "readelf $options (reason: unexpected output)" send_log $got send_log "\n" @@ -146,8 +149,7 @@ proc readelf_wi_test {} { set tempfile [remote_download host tmpdir/testprog.o] # Run "readelf -wi" on it. - send_log "exec $READELF $READELFFLAGS -wi $tempfile > readelf.out\n" - catch "exec $READELF $READELFFLAGS -wi $tempfile > readelf.out" got + set got [remote_exec host "$READELF $READELFFLAGS -wi $tempfile" "" "/dev/null" "readelf.out"] # Upload the results. set output [remote_upload host readelf.out] @@ -155,7 +157,7 @@ proc readelf_wi_test {} { file_on_host delete $tempfile # Strip any superflous warnings. - set got [prune_readelf_wi_warnings $got] + set got [prune_readelf_wi_warnings [lindex $got 1]] if ![string match "" $got] then { fail "readelf $READELFFLAGS -wi (reason: unexpected output)" diff --git a/binutils/testsuite/lib/utils-lib.exp b/binutils/testsuite/lib/utils-lib.exp index 77af1721efd..8ed9330d09d 100644 --- a/binutils/testsuite/lib/utils-lib.exp +++ b/binutils/testsuite/lib/utils-lib.exp @@ -462,7 +462,7 @@ proc run_dump_test { name {extra_options {}} } { set srcfile $srcdir/$subdir/$opts(source) } - set exec_output [binutils_assemble ${srcfile} tmpdir/bintest.o] + set exec_output [binutils_assemble ${srcfile} $tempfile] if [string match "" $exec_output] then { send_log "$exec_output\n" verbose "$exec_output" @@ -486,14 +486,14 @@ proc run_dump_test { name {extra_options {}} } { eval set progopts \$[string toupper $dumpprogram]FLAGS eval set binary \$[string toupper $dumpprogram] - if { [which $binary] == 0 } { + if { ![is_remote host] && [which $binary] == 0 } { untested $testname return } verbose "running $binary $progopts $progopts1" 3 - set cmd "$binary $progopts $progopts1 ${copyfile}.o > tmpdir/dump.out" + set cmd "$binary $progopts $progopts1 ${copyfile}.o" # Ensure consistent sorting of symbols if {[info exists env(LC_ALL)]} { @@ -501,13 +501,18 @@ proc run_dump_test { name {extra_options {}} } { } set env(LC_ALL) "C" send_log "$cmd\n" - catch "exec $cmd" comp_output + set comp_output [remote_exec host $cmd "" "/dev/null" "tmpdir/dump.out"] if {[info exists old_lc_all]} { set env(LC_ALL) $old_lc_all } else { unset env(LC_ALL) } - set comp_output [prune_warnings $comp_output] + if { [lindex $comp_output 0] != 0 } then { + send_log "$comp_output\n" + fail $testname + return + } + set comp_output [prune_warnings [lindex $comp_output 1]] if ![string match "" $comp_output] then { send_log "$comp_output\n" fail $testname diff --git a/gas/ChangeLog b/gas/ChangeLog index f10df64ddc8..e4f44fae8d1 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * as.c (main): Flush stderr before printing listings to ensure + consistent output order across platforms. + 2007-08-28 Robert Sebastian Gerus * configure.tgt: Add support for i[3-7]86-*-dragonfly*. diff --git a/gas/as.c b/gas/as.c index b636396a3e6..5abdbf46cf6 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1223,6 +1223,8 @@ main (int argc, char ** argv) if (keep_it) write_object_file (); + fflush (stderr); + #ifndef NO_LISTING listing_print (listing_filename); #endif diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 1bbbec163a6..1d196d06d4a 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,30 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * lib/gas-defs.exp (gas_version): Use remote_* functions instead + of exec. + (gas_host_run): New. + (gas_run): Use gas_host_run. + (gas_start): Likewise. + (run_dump_test): Likewise. + (objdump): Use gas_host_run. + (objdump_start_no_subdir): Likewise. + * lib/gas-dg.exp (gas-dg-test): Use "remote_file host delete". + * lib/run: Remove. + * gas/macros/macros.exp: Download app4b.s to host. + * gas/i386/i386.exp (gas_64_check): Use gas_host_run. + (gas_32_check): Likewise. + * gas/maxq10/maxq10.exp (gas_64_check): Likewise + (gas_32_check): Likewise. + * gas/maxq20/maxq20.exp (gas_64_check): Likewise + (gas_32_check): Likewise. + * gas/sparc/sparc.exp (gas_64_check): Likewise. + * gas/cfi/cfi.exp: Likewise. + * gas/elf/elf.exp (run_list_test): Likewise. Use temporary file + for readelf output in place of pipe. + * gas/all/gas.exp: Download incbin.dat to host. + (do_comment): Allow \r\r\n. + 2007-08-09 Paul Brook * gas/arm/relax_load_align.d: new test. diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index 6dabbca689b..081c4183bed 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -117,7 +117,7 @@ proc do_comment {} { expect { -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 } -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 } - -re "^ +3\[ \t\]+/. C comments too. ./\r?\n" { set x3 1 } + -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 } -re "\[^\n\]*\n" { } timeout { perror "timeout\n"; break } eof { break } @@ -254,6 +254,7 @@ case $target_triplet in { { *c54x*-*-* } { } default { test_cond + remote_download host "$srcdir/$subdir/incbin.dat" run_dump_test incbin } } diff --git a/gas/testsuite/gas/cfi/cfi.exp b/gas/testsuite/gas/cfi/cfi.exp index b396f9e8523..593c8ff4e6b 100644 --- a/gas/testsuite/gas/cfi/cfi.exp +++ b/gas/testsuite/gas/cfi/cfi.exp @@ -28,11 +28,10 @@ if [istarget "x86_64-*"] then { } elseif { [istarget sparc*-*-*] } then { global NM global NMFLAGS - global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help + set nm_status [gas_host_run "$NM $NMFLAGS --help" ""] run_dump_test "cfi-sparc-1" - if { [regexp "elf64\[_-\]sparc" $nm_help] } then { + if { [regexp "elf64\[_-\]sparc" [lindex $nm_status 1]] } then { run_dump_test "cfi-sparc64-1" } diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 83c80824b39..8b7833f02eb 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -15,7 +15,13 @@ proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } { return } send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n" - catch "exec $READELF $readelf_opts dump.o $readelf_pipe > dump.out\n" comp_output + set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"] + if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then { + send_log "[lindex $status 1]\n" + fail $testname + return + } + catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output if ![string match "" $comp_output] then { send_log "$comp_output\n" fail $testname diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 3a651ac4483..f68ab81b0c5 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -4,19 +4,17 @@ proc gas_64_check { } { global NM global NMFLAGS - global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*x86-64" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*x86-64" [lindex $status 1]]; } proc gas_32_check { } { global NM global NMFLAGS - global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*i386" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*i386" [lindex $status 1]]; } if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]] then { diff --git a/gas/testsuite/gas/macros/macros.exp b/gas/testsuite/gas/macros/macros.exp index 62392ec3b48..436923e53cc 100644 --- a/gas/testsuite/gas/macros/macros.exp +++ b/gas/testsuite/gas/macros/macros.exp @@ -53,6 +53,7 @@ if { ![istarget hppa*-*-*] || [istarget *-*-linux*] } { run_dump_test app1 run_dump_test app2 run_dump_test app3 +remote_download host "$srcdir/$subdir/app4b.s" run_dump_test app4 run_list_test badarg "" diff --git a/gas/testsuite/gas/maxq10/maxq10.exp b/gas/testsuite/gas/maxq10/maxq10.exp index 8887b53494e..a765177c62c 100644 --- a/gas/testsuite/gas/maxq10/maxq10.exp +++ b/gas/testsuite/gas/maxq10/maxq10.exp @@ -4,10 +4,9 @@ proc gas_64_check { } { global NM global NMFLAGS - global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*maxq" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*maxq" [lindex $status 1]] } proc gas_32_check { } { @@ -15,8 +14,8 @@ proc gas_32_check { } { global NMFLAGS global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*maxq" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*maxq" [lindex $status 1]] } if [expr ([istarget "maxq-*-*"] || [istarget "maxq-coff-*"]) && [gas_32_check]] then { diff --git a/gas/testsuite/gas/maxq20/maxq20.exp b/gas/testsuite/gas/maxq20/maxq20.exp index 6d952e9e3ed..cf0c93e43c2 100644 --- a/gas/testsuite/gas/maxq20/maxq20.exp +++ b/gas/testsuite/gas/maxq20/maxq20.exp @@ -6,8 +6,8 @@ proc gas_64_check { } { global NMFLAGS global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*maxq" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*maxq" [lindex $status 1]] } proc gas_32_check { } { @@ -15,8 +15,8 @@ proc gas_32_check { } { global NMFLAGS global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "targets:.*maxq" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "targets:.*maxq" [lindex $status 1]] } diff --git a/gas/testsuite/gas/sparc/sparc.exp b/gas/testsuite/gas/sparc/sparc.exp index 876f9acf801..0111d571b77 100644 --- a/gas/testsuite/gas/sparc/sparc.exp +++ b/gas/testsuite/gas/sparc/sparc.exp @@ -10,10 +10,9 @@ proc gas_64_check { } { global NM global NMFLAGS - global srcdir - catch "exec $srcdir/lib/run $NM $NMFLAGS --help" nm_help - return [regexp "elf64\[_-\]sparc" $nm_help] + set status [gas_host_run "$NM $NMFLAGS --help" ""] + return [regexp "elf64\[_-\]sparc" [lindex $status 1]] } proc sparc_elf_setup { } { diff --git a/gas/testsuite/lib/gas-defs.exp b/gas/testsuite/lib/gas-defs.exp index 8d4902a4d0a..112bb5270a8 100644 --- a/gas/testsuite/lib/gas-defs.exp +++ b/gas/testsuite/lib/gas-defs.exp @@ -23,17 +23,80 @@ proc gas_version {} { global AS - catch "exec $AS -version < /dev/null" tmp + if [is_remote host] then { + remote_exec host "$AS -version < /dev/null" "" "" "gas.version" + remote_exec host "which $AS" "" "" "gas.which" + + remote_upload host "gas.version" + remote_upload host "gas.which" + + set which_as [file_contents "gas.which"] + set tmp [file_contents "gas.version"] + + remote_file build delete "gas.version" + remote_file build delete "gas.which" + remote_file host delete "gas.version" + remote_file host delete "gas.which" + } else { + set which_as [which $AS] + catch "exec $AS -version < /dev/null" tmp + } + # Should find a way to discard constant parts, keep whatever's # left, so the version string could be almost anything at all... regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number if ![info exists number] then { - return "[which $AS] (no version number)\n" + return "$which_as (no version number)\n" } - clone_output "[which $AS] $number\n" + clone_output "$which_as $number\n" unset version } +proc gas_host_run { cmd redir } { + verbose "Executing $cmd $redir" + set return_contents_of "" + if [regexp ">& */dev/null" $redir] then { + set output_file "" + set command "$cmd $redir" + } elseif [regexp "> */dev/null" $redir] then { + set output_file "" + set command "$cmd 2>gas.stderr" + set return_contents_of "gas.stderr" + } elseif [regexp ">&.*" $redir] then { + set output_file [regsub ">&" $redir ""] + set command "$cmd 2>&1" + } elseif [regexp "2>.*" $redir] then { + set output_file "gas.out" + set command "$cmd $redir" + set return_contents_of "gas.out" + } elseif [regexp ">.*" $redir] then { + set output_file "" + set command "$cmd $redir 2>gas.stderr" + set return_contents_of "gas.stderr" + } elseif { "$redir" == "" } then { + set output_file "gas.out" + set command "$cmd 2>&1" + set return_contents_of "gas.out" + } else { + fail "gas_host_run: unknown form of redirection string" + } + + set status [remote_exec host [concat sh -c [list $command]] "" "/dev/null" "$output_file"] + set to_return "" + if { "$return_contents_of" != "" } then { + remote_upload host "$return_contents_of" + set to_return [file_contents "$return_contents_of"] + regsub "\n$" $to_return "" to_return + } + + if { [lindex $status 0] == 0 && "$output_file" != "" + && "$output_file" != "$return_contents_of" } then { + remote_upload host "$output_file" + } + + return [list [lindex $status 0] "$to_return"] +} + proc gas_run { prog as_opts redir } { global AS global ASFLAGS @@ -42,8 +105,11 @@ proc gas_run { prog as_opts redir } { global subdir global host_triplet - verbose -log "Executing $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog $redir" - catch "exec $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog $redir" comp_output + set status [gas_host_run "$AS $ASFLAGS $as_opts $srcdir/$subdir/$prog" "$redir"] + set comp_output [lindex $status 1] + if { [lindex $status 0] != 0 && [regexp "2>.*" $redir] } then { + append comp_output "child process exited abnormally" + } set comp_output [prune_warnings $comp_output] verbose "output was $comp_output" return [list $comp_output ""] @@ -71,12 +137,8 @@ proc gas_start { prog as_opts } { set gas_started 1 verbose -log "Starting $AS $ASFLAGS $as_opts $prog" 2 - catch { - spawn -noecho -nottycopy $srcdir/lib/run $AS $ASFLAGS $as_opts $srcdir/$subdir/$prog - } foo - if ![regexp {^[0-9]+} $foo] then { - perror "Can't run $subdir/$prog: $foo" - } + set status [gas_host_run "$AS $ASFLAGS $as_opts $srcdir/$subdir/$prog" ">&gas.out"] + spawn -noecho -nottycopy cat gas.out } proc gas_finish { } { @@ -422,6 +484,9 @@ proc run_dump_test { name {extra_options {}} } { unresolved $subdir/$name return } + if { $opt_name == "as" } { + set opt_val [subst $opt_val] + } set opts($opt_name) $opt_val } @@ -554,10 +619,11 @@ proc run_dump_test { name {extra_options {}} } { set sourcefile $srcdir/$subdir/$opts(source) } - set cmd "$srcdir/lib/run $AS $ASFLAGS $opts(as) -o dump.o $sourcefile" + set cmd "$AS $ASFLAGS $opts(as) -o dump.o $sourcefile" send_log "$cmd\n" - set cmdret [catch "exec $cmd" comp_output] - set comp_output [prune_warnings $comp_output] + set status [gas_host_run $cmd ""] + set cmdret [lindex $status 0] + set comp_output [prune_warnings [lindex $status 1]] set expmsg $opts(error) if { $opts(warning) != "" } { @@ -632,7 +698,7 @@ proc run_dump_test { name {extra_options {}} } { eval set progopts \$[string toupper $program]FLAGS eval set binary \$[string toupper $program] - if { [which $binary] == 0 } { + if { ![is_remote host] && [which $binary] == 0 } { untested $testname return } @@ -642,9 +708,11 @@ proc run_dump_test { name {extra_options {}} } { # Objcopy, unlike the other two, won't send its output to stdout, # so we have to run it specially. - set cmd "$binary $progopts $progopts1 dump.o > dump.out" + set cmd "$binary $progopts $progopts1 dump.o" + set redir ">dump.out" if { $program == "objcopy" } { set cmd "$binary $progopts $progopts1 dump.o dump.out" + set redir "" } # Ensure consistent sorting of symbols @@ -653,7 +721,8 @@ proc run_dump_test { name {extra_options {}} } { } set env(LC_ALL) "C" send_log "$cmd\n" - catch "exec $cmd" comp_output + set status [gas_host_run "$cmd" "$redir"] + set comp_output [prune_warnings [lindex $status 1]] if {[info exists old_lc_all]} { set env(LC_ALL) $old_lc_all } else { @@ -708,8 +777,8 @@ proc objdump { opts } { global comp_output global host_triplet - catch "exec $OBJDUMP $opts" comp_output - set comp_output [prune_warnings $comp_output] + set status [gas_host_run "$OBJDUMP $opts" ""] + set comp_output [prune_warnings [lindex $status 1]] verbose "objdump output=$comp_output\n" 3 } @@ -719,12 +788,8 @@ proc objdump_start_no_subdir { prog opts } { global spawn_id verbose "Starting $OBJDUMP $opts $prog" 2 - catch { - spawn -noecho -nottyinit $srcdir/lib/run $OBJDUMP $opts $prog - } foo - if ![regexp {^[0-9]+} $foo] then { - perror "Can't run $prog: $foo" - } + set status [gas_host_run "$OBJDUMP $opts $prog" ">&gas.out"] + spawn -noecho -nottycopy cat gas.out } proc objdump_finish { } { diff --git a/gas/testsuite/lib/gas-dg.exp b/gas/testsuite/lib/gas-dg.exp index 801b9b4e93c..3b90548cacd 100644 --- a/gas/testsuite/lib/gas-dg.exp +++ b/gas/testsuite/lib/gas-dg.exp @@ -21,7 +21,7 @@ proc gas-dg-test { prog do_what tool_flags } { "run" { # This is the only place where we care if an executable was # created or not. If it was, dg.exp will try to run it. - catch "exec rm -f $output_file" + remote_file host delete "$output_file" } default { perror "$do_what: not a valid dg-do keyword" diff --git a/gas/testsuite/lib/run b/gas/testsuite/lib/run deleted file mode 100755 index d4150f8d4ce..00000000000 --- a/gas/testsuite/lib/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -eval exec $@ diff --git a/ld/ChangeLog b/ld/ChangeLog index 957593469ac..a2bee5fc4f4 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * ldlang.c (sort_sections_by_lma): Sort by internal id after lma + for stable sort. + 2007-08-28 Robert Sebastian Gerus * configure.host: Add support for i[3-7]86-*-dragonfly*. diff --git a/ld/ldlang.c b/ld/ldlang.c index decfc5f77b3..1fcb991ae32 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4103,6 +4103,10 @@ sort_sections_by_lma (const void *arg1, const void *arg2) else if (bfd_section_lma (sec1->owner, sec1) > bfd_section_lma (sec2->owner, sec2)) return 1; + else if (sec1->id < sec2->id) + return -1; + else if (sec1->id > sec2->id) + return 1; return 0; } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index ecd896ca624..ec3cf044ea9 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,46 @@ +2007-08-28 Mark Shinwell + Joseph Myers + + * ld-elfcomm/elfcomm.exp: Use run_host_cmd. Only check "which + $CC" if host is local. + * ld-checks/checks.exp: Use run_host_cmd. + * ld-elf/exclude.exp: Likewise. + * ld-elf/elf.exp: Download merge.ld if host is remote. + * ld-elf/binutils.exp (binutils_test): Use remote_exec. + * ld-elf/tls_common.exp: Use run_host_cmd. + * lib/ld-lib.exp (ld_version): Only check "which $ld" if host is + local. Use remote_exec. + (run_host_cmd): New. + (run_host_cmd_yesno): New. + (default_ld_relocate): Use run_host_cmd_yesno. + (default_ld_link): Likewise. + (default_ld_simple_link): Use run_host_cmd. + (default_ld_compile): Only check "which $ccprog" if host is local. + Use remote_file and remote_exec. + (default_ld_assemble): Only check "which $as" if host is local. + Use run_host_cmd. + (default_ld_nm): Use remote_exec, remote_upload and remote_file. + (run_dump_test): Use remote_exec, remote_upload and remote_file. + Only check "which $binary" if host is local. + (run_ld_link_tests): Use remote_exec, remote_upload and + remote_file. + * ld-selective/selective.exp: Only check "which $CXX" if host is + local. Use remote_exec. + * ld-scripts/phdrs.exp: Only check "which $objdump" if host is + local. Use run_host_cmd. + * ld-scripts/phdrs2.exp: Likewise. + * ld-scripts/weak.exp: Likewise. + * ld-undefined/weak-undef.exp: Likewise. + * ld-scripts/crossref.exp: Only check "which $CC" if host is local. + Use run_host_cmd. + * ld-scripts/map-address.exp: Upload map_address.map if host is + remote. + * ld-srec/srec.exp (run_srec_tests): Use run_host_cmd. Only check + "which $CC" and "which $CXX" if host is local. + * ld-undefined/undefined.exp: Only check "which $CC" if host is + local. Use remote_file and run_host_cmd. + * config/default.exp: Use remote_exec to create tmpdir. + 2007-08-24 H.J. Lu * ld-i386/i386.exp (i386tests): Add a test for TLS IE->LE diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index dfae71afb68..ab35ecfa53f 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -50,9 +50,7 @@ if ![info exists strip] then { set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]] } -if {![file isdirectory tmpdir]} then { - catch "exec mkdir tmpdir" status -} +remote_exec host "mkdir -p tmpdir" # Make a symlink from tmpdir/as to the assembler in the build tree, so # that we can use a -B option to gcc to force it to use the newly diff --git a/ld/testsuite/ld-checks/checks.exp b/ld/testsuite/ld-checks/checks.exp index d0ace092a34..39e9ac7936f 100644 --- a/ld/testsuite/ld-checks/checks.exp +++ b/ld/testsuite/ld-checks/checks.exp @@ -57,8 +57,7 @@ proc section_check {} { # Perform the equivalent of invoking ld_simple_link # except that we need to massage the output futher. - verbose -log "$ld -o tmpdir/asm.x $ldflags tmpdir/asm.o" - catch "exec $ld -o tmpdir/asm.x $ldflags tmpdir/asm.o" exec_output + set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"] set exec_output [prune_warnings $exec_output] # Make sure that we got some output from the linker diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp index 52ac03b2f4b..ba7ac36862c 100644 --- a/ld/testsuite/ld-elf/binutils.exp +++ b/ld/testsuite/ld-elf/binutils.exp @@ -62,24 +62,24 @@ proc binutils_test { prog_name ld_options test } { } send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n" - catch "exec $READELF -l --wide tmpdir/$test > tmpdir/$test.exp" got - if ![string match "" $got] then { + set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { send_log "$got\n" unresolved "$test_name" return } send_log "$prog tmpdir/$test\n" - catch "exec $prog tmpdir/$test" got - if ![string match "" $got] then { + set got [remote_exec host "$prog tmpdir/$test"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { send_log "$got\n" fail "$test_name" return } send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n" - catch "exec $READELF -l --wide tmpdir/$test > tmpdir/$test.out" got - if ![string match "" $got] then { + set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { send_log "$got\n" unresolved "$test_name" return diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 20e998077d1..dc6a3a6a772 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -29,6 +29,10 @@ if { [istarget spu*-*-*] } { set LDFLAGS "$LDFLAGS --local-store 0:0" } +if { [is_remote host] } then { + remote_download host merge.ld +} + set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] foreach t $test_list { # We need to strip the ".d", but can leave the dirname. diff --git a/ld/testsuite/ld-elf/exclude.exp b/ld/testsuite/ld-elf/exclude.exp index 2bb8cf6aab6..264c1380353 100644 --- a/ld/testsuite/ld-elf/exclude.exp +++ b/ld/testsuite/ld-elf/exclude.exp @@ -53,8 +53,8 @@ if { ![ld_assemble $as $srcdir/$subdir/exclude1.s tmpdir/exclude1.o ] return } -catch "exec rm -f tmpdir/libexclude.a" catch_output -catch "exec $ar cq tmpdir/libexclude.a tmpdir/exclude2.o" catch_output +remote_file host delete "tmpdir/libexclude.a" +set catch_output [run_host_cmd "$ar" "cq tmpdir/libexclude.a tmpdir/exclude2.o"] if {![string match "" $catch_output]} { unresolved $test1 return diff --git a/ld/testsuite/ld-elf/tls_common.exp b/ld/testsuite/ld-elf/tls_common.exp index edeedbe8c77..66a550ccdf7 100644 --- a/ld/testsuite/ld-elf/tls_common.exp +++ b/ld/testsuite/ld-elf/tls_common.exp @@ -62,8 +62,7 @@ if { ![ld_simple_link $ld tmpdir/tls_common "tmpdir/tls_common1.o"] } { return } -send_log "$READELF -l --wide tmpdir/tls_common\n" -catch "exec $READELF -l --wide tmpdir/tls_common" readelf_output +set readelf_output [run_host_cmd "$READELF" "-l --wide tmpdir/tls_common"] if ![regexp ".*TLS.*0x0+ 0x0+4 R .*" $readelf_output] then { send_log "$readelf_output\n" fail "tls_common" diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp index fcfdf927395..bed5258fd7b 100644 --- a/ld/testsuite/ld-elfcomm/elfcomm.exp +++ b/ld/testsuite/ld-elfcomm/elfcomm.exp @@ -34,7 +34,7 @@ set test1w2 "$test1 (warning 2)" set test1c1 "$test1 (change 1)" set test1c2 "$test1 (change 2)" -if { [which $CC] == 0 } { +if { ![is_remote host] && [which $CC] == 0 } { untested $test1w1 untested $test1w2 untested $test1c1 @@ -54,7 +54,8 @@ proc dump_common1 { testname } { global READELF send_log "$READELF -s tmpdir/common1.o | grep foo\n" - catch "exec $READELF -s tmpdir/common1.o | grep foo" exec_output + set exec_output [run_host_cmd "readelf" "-s tmpdir/common1.o | grep foo"] + if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(PRC\\\[0xff03\\\]|COM|SCOM)(\[ \]+)_?foo2" $exec_output] || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } { send_log "$exec_output\n" diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp index 4d43ecf0de5..6d0420b0148 100644 --- a/ld/testsuite/ld-scripts/crossref.exp +++ b/ld/testsuite/ld-scripts/crossref.exp @@ -24,7 +24,7 @@ set test1 "NOCROSSREFS 1" set test2 "NOCROSSREFS 2" set test3 "NOCROSSREFS 3" -if { [which $CC] == 0 } { +if { ![is_remote host] && [which $CC] == 0 } { untested $test1 untested $test2 untested $test3 @@ -62,9 +62,7 @@ if [istarget sh64*-*-elf] { # IA64 has both ordered and unordered sections in an input file. setup_xfail ia64-*-* -verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" - -catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"] set exec_output [prune_warnings $exec_output] @@ -88,10 +86,7 @@ if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } { return } -verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" - -catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output - +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"] set exec_output [prune_warnings $exec_output] regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output @@ -119,9 +114,7 @@ if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] return } -verbose -log "$ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o" - -catch "exec $ld $flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o" exec_output +set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"] set exec_output [prune_warnings $exec_output] diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp index 6ddad412cab..c8fe6535830 100644 --- a/ld/testsuite/ld-scripts/map-address.exp +++ b/ld/testsuite/ld-scripts/map-address.exp @@ -31,7 +31,14 @@ if {![ld_simple_link $ld tmpdir/map-address \ tmpdir/map-address.o \ -Map tmpdir/map-address.map"]} { fail $testname -} elseif {[regexp_diff \ + return +} + +if [is_remote host] then { + remote_upload host "tmpdir/map_address.map" +} + +if {[regexp_diff \ "tmpdir/map-address.map" \ "$srcdir/$subdir/map-address.d"]} { fail $testname diff --git a/ld/testsuite/ld-scripts/phdrs.exp b/ld/testsuite/ld-scripts/phdrs.exp index bde4f10cf03..ad59cd1b560 100644 --- a/ld/testsuite/ld-scripts/phdrs.exp +++ b/ld/testsuite/ld-scripts/phdrs.exp @@ -52,13 +52,11 @@ set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o" if ![ld_simple_link $ld tmpdir/phdrs $ldopt] { fail $testname } else { - if {[which $objdump] == 0} { + if {![is_remote host] && [which $objdump] == 0} { unresolved $testname return } - - verbose -log "$objdump --private tmpdir/phdrs" - catch "exec $objdump --private tmpdir/phdrs" exec_output + set exec_output [run_host_cmd "$objdump" "--private tmpdir/phdrs"] set exec_output [prune_warnings $exec_output] verbose -log $exec_output diff --git a/ld/testsuite/ld-scripts/phdrs2.exp b/ld/testsuite/ld-scripts/phdrs2.exp index 654a8becd9a..5a4a8cccd22 100644 --- a/ld/testsuite/ld-scripts/phdrs2.exp +++ b/ld/testsuite/ld-scripts/phdrs2.exp @@ -57,13 +57,12 @@ set ldopt "$ldopt -T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o" if ![ld_simple_link $ld tmpdir/phdrs2 $ldopt] { fail $testname } else { - if {[which $objdump] == 0} { + if {![is_remote host] && [which $objdump] == 0} { unresolved $testname return } - verbose -log "$objdump --private tmpdir/phdrs2" - catch "exec $objdump --private tmpdir/phdrs2" exec_output + set exec_output [run_host_cmd "$objdump" "--private tmpdir/phdrs2"] set exec_output [prune_warnings $exec_output] verbose -log $exec_output diff --git a/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp index de28755e682..5b5c00c3684 100644 --- a/ld/testsuite/ld-scripts/weak.exp +++ b/ld/testsuite/ld-scripts/weak.exp @@ -60,14 +60,13 @@ set weak_regexp_little \ if {! [ld_simple_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then { fail $testname } else { - if {[which $objdump] == 0} then { + if {![is_remote host] && [which $objdump] == 0} then { unresolved $testname set LDFLAGS "$saved_LDFLAGS" return } - verbose -log "$objdump -s tmpdir/weak" - catch "exec $objdump -s tmpdir/weak" exec_output + set exec_output [run_host_cmd "$objdump" "-s tmpdir/weak"] set exec_output [prune_warnings $exec_output] verbose -log $exec_output diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp index dc7e9b80f98..bae43722e8a 100644 --- a/ld/testsuite/ld-selective/selective.exp +++ b/ld/testsuite/ld-selective/selective.exp @@ -71,7 +71,7 @@ if [istarget sh64*-*-elf] { } # If we don't have g++ for the target, mark all tests as untested. -if { [which $CXX] == 0 } { +if { ![is_remote host] && [which $CXX] == 0 } { foreach testitem $seltests { untested "[lindex $testitem 0]" } @@ -103,7 +103,8 @@ foreach testitem $seltests { if [string match "*gcc*" [lindex $CC 0]] { # Starting with 3.4.0, -fvtable-gc is no longer supported and thus # the functionality we try to test for cannot be expected to work. - catch "exec -- $CC -dumpversion" version + set version [remote_exec host "$CC -dumpversion"] + set version [lindex $version 1] if [regexp "^(\[1-9\]\[0-9\]+|\[4-9\]|3.(\[1-9\]\[0-9\]+|\[4-9\]))\\." $version] { setup_xfail {*-*-*} } @@ -122,19 +123,25 @@ foreach testitem $seltests { # V850 targets need libgcc.a if [istarget v850*-*-elf] { - catch "exec $CC -print-libgcc-file-name" libgcc + set libgcc [remote_exec host "$CC -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc set objfile "$objfile $libgcc" } # ARM targets need libgcc.a in THUMB mode so that __call_via_r3 is provided if {[istarget arm-*-*] || [istarget xscale-*-*]} { - catch "exec $CC -print-libgcc-file-name" libgcc + set libgcc [remote_exec host "$CC -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc set objfile "$objfile $libgcc" } # HPPA linux targets need libgcc.a for millicode routines ($$dyncall). if [istarget hppa*-*-linux*] { - catch "exec $CC -print-libgcc-file-name" libgcc + set libgcc [remote_exec host "$CC -print-libgcc-file-name"] + set libgcc [lindex $libgcc 1] + regsub -all "\[\r\n\]" $libgcc "" libgcc set objfile "$objfile $libgcc" } diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp index c40161a574f..c75b57caa59 100644 --- a/ld/testsuite/ld-srec/srec.exp +++ b/ld/testsuite/ld-srec/srec.exp @@ -305,8 +305,7 @@ proc run_srec_test { test objs } { } send_log "$objcopy -O srec tmpdir/sr1 tmpdir/sr1.sr\n" - verbose "$objcopy -O srec tmpdir/sr1 tmpdir/sr1.sr" - catch "exec $objcopy -O srec tmpdir/sr1 tmpdir/sr1.sr" exec_output + set exec_output [run_host_cmd "$objcopy" "-O srec tmpdir/sr1 tmpdir/sr1.sr"] set exec_output [prune_warnings $exec_output] if ![string match "" $exec_output] { send_log "$exec_output\n" @@ -330,7 +329,7 @@ set test1 "S-records" set test2 "S-records with constructors" # See whether the default linker script uses SIZEOF_HEADERS. -catch "exec $ld --verbose" exec_output +set exec_output [run_host_cmd "$ld" "--verbose"] set sizeof_headers [string match "*SIZEOF_HEADERS*" $exec_output] # First test linking a C program. We don't require any libraries. We @@ -338,7 +337,7 @@ set sizeof_headers [string match "*SIZEOF_HEADERS*" $exec_output] # directly to the S-record format, and require that the two files # contain the same data. -if { [which $CC] == 0 } { +if { ![is_remote host] && [which $CC] == 0 } { untested $test1 untested $test2 return @@ -400,7 +399,7 @@ run_srec_test $test1 "tmpdir/sr1.o tmpdir/sr2.o" # destructors. Note that since we are not linking against any # libraries, this program won't actually work or anything. -if { [which $CXX] == 0 } { +if { ![is_remote host] && [which $CXX] == 0 } { untested $test2 return } diff --git a/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-undefined/undefined.exp index e6bf359b508..d546fd80563 100644 --- a/ld/testsuite/ld-undefined/undefined.exp +++ b/ld/testsuite/ld-undefined/undefined.exp @@ -25,7 +25,7 @@ set testund "undefined" set testfn "undefined function" set testline "undefined line" -if { [which $CC] == 0 } { +if { ![is_remote host] && [which $CC] == 0 } { verbose "Could not find C compiler!" 1 untested $testund untested $testfn @@ -41,16 +41,15 @@ if ![ld_compile "$CC -g" $srcdir/$subdir/undefined.c tmpdir/undefined.o] { return } -catch "exec rm -f tmpdir/undefined" exec_output +remote_file host delete "tmpdir/undefined" set flags [big_or_little_endian] # Using -e start prevents the SunOS linker from trying to build a # shared library. send_log "$ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o\n" -verbose "$ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o" +set exec_output [run_host_cmd "$ld" "-e start $flags -o tmpdir/undefined tmpdir/undefined.o"] -catch "exec $ld -e start $flags -o tmpdir/undefined tmpdir/undefined.o" exec_output send_log "$exec_output\n" verbose "$exec_output" diff --git a/ld/testsuite/ld-undefined/weak-undef.exp b/ld/testsuite/ld-undefined/weak-undef.exp index 00c016a273c..e3f109b3f6f 100644 --- a/ld/testsuite/ld-undefined/weak-undef.exp +++ b/ld/testsuite/ld-undefined/weak-undef.exp @@ -66,13 +66,12 @@ set output_regexp \ if {! [ld_simple_link $ld tmpdir/weak-undef "$flags tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"] } then { fail $testname } else { - if {[which $objdump] == 0} then { + if {![is_remote host] && [which $objdump] == 0} then { unresolved $testname return } - verbose -log "$objdump -s tmpdir/weak-undef" - catch "exec $objdump -s tmpdir/weak-undef" exec_output + set exec_output [run_host_cmd "$objdump" "-s tmpdir/weak-undef"] set exec_output [prune_warnings $exec_output] verbose -log $exec_output diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 878af0c5130..5518a72c974 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -24,43 +24,67 @@ proc default_ld_version { ld } { global host_triplet - if { [which $ld] == 0 } then { + if { ![is_remote host] && [which $ld] == 0 } then { perror "$ld does not exist" exit 1 } - catch "exec $ld --version" tmp - set tmp [prune_warnings $tmp] + remote_exec host "$ld --version" "" "/dev/null" "ld.version" + remote_upload host "ld.version" + set tmp [prune_warnings [file_contents "ld.version"]] + remote_file build delete "ld.version" + remote_file host delete "ld.version" + regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number if [info exists number] then { clone_output "$ld $number\n" } } -# Link an object using relocation. -# -proc default_ld_relocate { ld target objects } { - global HOSTING_EMU - global host_triplet - global exec_output +proc run_host_cmd { prog command } { + global link_output - if { [which $ld] == 0 } then { - perror "$ld does not exist" + if { ![is_remote host] && [which "$prog"] == 0 } then { + perror "$prog does not exist" return 0 } - catch "exec rm -f $target" exec_output + verbose -log "$prog $command" + set status [remote_exec host [concat sh -c [list "$prog $command 2>&1"]] "" "/dev/null" "ld.tmp"] + remote_upload host "ld.tmp" + set link_output [file_contents "ld.tmp"] + regsub "\n$" $link_output "" link_output + if { [lindex $status 0] != 0 && [string match "" $link_output] } then { + append link_output "child process exited abnormally" + } + remote_file build delete ld.tmp + remote_file host delete ld.tmp - verbose -log "$ld $HOSTING_EMU -o $target -r $objects" + if [string match "" $link_output] then { + return "" + } - catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output - set exec_output [prune_warnings $exec_output] + verbose -log "$link_output" + return "$link_output" +} + +proc run_host_cmd_yesno { prog command } { + global exec_output + + set exec_output [prune_warnings [run_host_cmd "$prog" "$command"]] if [string match "" $exec_output] then { - return 1 - } else { - verbose -log "$exec_output" - return 0 + return 1; } + return 0; +} + +# Link an object using relocation. +# +proc default_ld_relocate { ld target objects } { + global HOSTING_EMU + + remote_file host delete $target + return [run_host_cmd_yesno "$ld" "$HOSTING_EMU -o $target -r $objects"] } # Check to see if ld is being invoked with a non-endian output format @@ -126,44 +150,24 @@ proc default_ld_link { ld target objects } { set objs "$HOSTING_CRT0 $objects" set libs "$LIBS $HOSTING_LIBS" - if { [which $ld] == 0 } then { - perror "$ld does not exist" - return 0 - } - if [is_endian_output_format $objects] then { set flags [big_or_little_endian] } else { set flags "" } - catch "exec rm -f $target" exec_output - - verbose -log "$ld $HOSTING_EMU $flags -o $target $objs $libs" + remote_file host delete $target - catch "exec $ld $HOSTING_EMU $flags -o $target $objs $libs" link_output - set exec_output [prune_warnings $link_output] - if [string match "" $exec_output] then { - return 1 - } else { - verbose -log "$exec_output" - return 0 - } + return [run_host_cmd_yesno "$ld" "$HOSTING_EMU $flags -o $target $objs $libs"] } # Link a program using ld, without including any libraries. # proc default_ld_simple_link { ld target objects } { global host_triplet - global link_output global gcc_ld_flag global exec_output - if { [which $ld] == 0 } then { - perror "$ld does not exist" - return 0 - } - if [is_endian_output_format $objects] then { set flags [big_or_little_endian] } else { @@ -183,12 +187,10 @@ proc default_ld_simple_link { ld target objects } { set flags "$gcc_ld_flag $flags" } - catch "exec rm -f $target" exec_output + remote_file host delete $target - verbose -log "$ld $flags -o $target $objects" - - catch "exec $ld $flags -o $target $objects" link_output - set exec_output [prune_warnings $link_output] + set exec_output [run_host_cmd "$ld" "$flags -o $target $objects"] + set exec_output [prune_warnings $exec_output] # We don't care if we get a warning about a non-existent start # symbol, since the default linker script might use ENTRY. @@ -197,7 +199,6 @@ proc default_ld_simple_link { ld target objects } { if [string match "" $exec_output] then { return 1 } else { - verbose -log "$exec_output" return 0 } } @@ -215,12 +216,13 @@ proc default_ld_compile { cc source object } { if {[llength $cc_prog] > 1} then { set cc_prog [lindex $cc_prog 0] } - if {[which $cc_prog] == 0} then { + if {![is_remote host] && [which $cc_prog] == 0} then { perror "$cc_prog does not exist" return 0 } - catch "exec rm -f $object" exec_output + remote_file build delete "$object" + remote_file host delete "$object" set flags "-I$srcdir/$subdir $CFLAGS" @@ -246,22 +248,20 @@ proc default_ld_compile { cc source object } { verbose -log "$cc $flags $ccflags -c $source -o $object" - catch "exec $cc $flags $ccflags -c $source -o $object" exec_output + set status [remote_exec host [concat sh -c [list "$cc $flags $ccflags -c $source -o $object 2>&1"]] "" "/dev/null" "ld.tmp"] + remote_upload host "ld.tmp" + set exec_output [file_contents "ld.tmp"] + remote_file build delete "ld.tmp" + remote_file host delete "ld.tmp" set exec_output [prune_warnings $exec_output] if [string match "" $exec_output] then { if {![file exists $object]} then { regexp ".*/(\[^/\]*)$" $source all dobj regsub "\\.c" $dobj ".o" realobj verbose "looking for $realobj" - if {[file exists $realobj]} then { + if {[remote_file host exists $realobj]} then { verbose -log "mv $realobj $object" - catch "exec mv $realobj $object" exec_output - set exec_output [prune_warnings $exec_output] - if {![string match "" $exec_output]} then { - verbose -log "$exec_output" - perror "could not move $realobj to $object" - return 0 - } + remote_upload "$realobj" "$object" } else { perror "$object not found after compilation" return 0 @@ -281,23 +281,14 @@ proc default_ld_assemble { as source object } { global ASFLAGS global host_triplet - if {[which $as] == 0} then { - perror "$as does not exist" - return 0 - } - if ![info exists ASFLAGS] { set ASFLAGS "" } set flags [big_or_little_endian] - - verbose -log "$as $flags $ASFLAGS -o $object $source" - - catch "exec $as $flags $ASFLAGS -o $object $source" exec_output + set exec_output [run_host_cmd "$as" "$flags $ASFLAGS -o $object $source"] set exec_output [prune_warnings $exec_output] if [string match "" $exec_output] then { return 1 } else { - verbose -log "$exec_output" perror "$source: assembly failed" return 0 } @@ -310,11 +301,6 @@ proc default_ld_nm { nm nmflags object } { global nm_output global host_triplet - if {[which $nm] == 0} then { - perror "$nm does not exist" - return 0 - } - if {[info exists nm_output]} { unset nm_output } @@ -326,15 +312,20 @@ proc default_ld_nm { nm nmflags object } { set old_lc_all $env(LC_ALL) } set env(LC_ALL) "C" + verbose -log "$nm $NMFLAGS $nmflags $object >tmpdir/nm.out" - catch "exec $nm $NMFLAGS $nmflags $object >tmpdir/nm.out" exec_output + set status [remote_exec host [concat sh -c [list "$nm $NMFLAGS $nmflags $object 2>ld.stderr"]] "" "/dev/null" "tmpdir/nm.out"] if {[info exists old_lc_all]} { set env(LC_ALL) $old_lc_all } else { unset env(LC_ALL) } - set exec_output [prune_warnings $exec_output] + remote_upload host "ld.stderr" + remote_upload host "tmpdir/nm.out" "tmpdir/nm.out" + set exec_output [prune_warnings [file_contents "ld.stderr"]] + remote_file host delete "ld.stderr" + remote_file build delete "ld.stderr" if [string match "" $exec_output] then { set file [open tmpdir/nm.out r] while { [gets $file line] != -1 } { @@ -706,6 +697,9 @@ proc run_dump_test { name } { } } } + if { $opt_name == "as" || $opt_name == "ld" } { + set opt_val [subst $opt_val] + } set opts($opt_name) [concat $opts($opt_name) $opt_val] } foreach opt { as ld } { @@ -805,10 +799,13 @@ proc run_dump_test { name } { set cmd "$AS $ASFLAGS $opts(as) $asflags($sourcefile) -o $objfile $sourcefile" send_log "$cmd\n" - set cmdret [catch "exec $cmd" comp_output] - set comp_output [prune_warnings $comp_output] + set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"] + remote_upload host "ld.tmp" + set comp_output [prune_warnings [file_contents "ld.tmp"]] + remote_file host delete "ld.tmp" + remote_file build delete "ld.tmp" - if { $cmdret != 0 || ![string match "" $comp_output] } then { + if { [lindex $cmdret 0] != 0 || ![string match "" $comp_output] } then { send_log "$comp_output\n" verbose "$comp_output" 3 @@ -840,43 +837,32 @@ proc run_dump_test { name } { $opts(ld) -o $objfile $objfiles" send_log "$cmd\n" - set cmdret [catch "exec $cmd" comp_output] - set comp_output [prune_warnings $comp_output] - - if { $cmdret != 0 } then { - # If the executed program writes to stderr and stderr is not - # redirected, exec *always* returns failure, regardless of the - # program exit code. Thankfully, we can retrieve the true - # return status from a special variable. Redirection would - # cause a Tcl-specific message to be appended, and we'd rather - # not deal with that if we can help it. - global errorCode - if { [lindex $errorCode 0] == "NONE" } { - set cmdret 0 - } - } + set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"] + remote_upload host "ld.tmp" + set comp_output [prune_warnings [file_contents "ld.tmp"]] + remote_file host delete "ld.tmp" + remote_file build delete "ld.tmp" + set cmdret [lindex $cmdret 0] if { $cmdret == 0 && $run_objcopy } { set infile $objfile set objfile "tmpdir/dump1" - catch "exec rm -f $objfile" exec_output + remote_file host delete $objfile # Note that we don't use OBJCOPYFLAGS here; any flags must be # explicitly specified. set cmd "$OBJCOPY $opts(objcopy_linked_file) $infile $objfile" send_log "$cmd\n" - set cmdret [catch "exec $cmd" comp_output] - append comp_output [prune_warnings $comp_output] - - if { $cmdret != 0 } then { - global errorCode - if { [lindex $errorCode 0] == "NONE" } { - set cmdret 0 - } - } + set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"] + remote_upload host "ld.tmp" + append comp_output [prune_warnings [file_contents "ld.tmp"]] + remote_file host delete "ld.tmp" + remote_file build delete "ld.tmp" + set cmdret [lindex $cmdret 0] } + regsub "\n$" $comp_output "" comp_output if { $cmdret != 0 || $comp_output != "" || $expmsg != "" } then { set exitstat "succeeded" if { $cmdret != 0 } { set exitstat "failed" } @@ -911,7 +897,7 @@ proc run_dump_test { name } { eval set progopts \$[string toupper $program]FLAGS eval set binary \$[string toupper $program] - if { [which $binary] == 0 } { + if { ![is_remote host] && [which $binary] == 0 } { untested $testname return } @@ -932,13 +918,16 @@ proc run_dump_test { name } { } set env(LC_ALL) "C" send_log "$cmd\n" - catch "exec $cmd" comp_output + set cmdret [remote_exec host [concat sh -c [list "$cmd 2>ld.tmp"]] "" "/dev/null"] + remote_upload host "ld.tmp" + set comp_output [prune_warnings [file_contents "ld.tmp"]] + remote_file host delete "ld.tmp" + remote_file build delete "ld.tmp" if {[info exists old_lc_all]} { set env(LC_ALL) $old_lc_all } else { unset env(LC_ALL) } - set comp_output [prune_warnings $comp_output] if ![string match "" $comp_output] then { send_log "$comp_output\n" fail $testname @@ -1196,15 +1185,19 @@ proc run_ld_link_tests { ldtests } { set old_lc_all $env(LC_ALL) } set env(LC_ALL) "C" - set cmd "$binary $progopts $binfile > dump.out" + set cmd "$binary $progopts $binfile" + set status [remote_exec host [concat sh -c [list "$cmd >dump.out 2>ld.stderr"]] "" "/dev/null"] send_log "$cmd\n" - catch "exec $cmd" comp_output + remote_upload host "ld.stderr" + set comp_output [prune_warnings [file_contents "ld.stderr"]] + remote_file host delete "ld.stderr" + remote_file build delete "ld.stderr" + if {[info exists old_lc_all]} { set env(LC_ALL) $old_lc_all } else { unset env(LC_ALL) } - set comp_output [prune_warnings $comp_output] if ![string match "" $comp_output] then { send_log "$comp_output\n" @@ -1212,11 +1205,17 @@ proc run_ld_link_tests { ldtests } { break } + remote_upload host "dump.out" + if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then { verbose "output is [file_contents "dump.out"]" 2 set failed 1 + remote_file build delete "dump.out" + remote_file host delete "dump.out" break } + remote_file build delete "dump.out" + remote_file host delete "dump.out" } } -- 2.30.2