This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cross-host testing patch


This patch improves binutils support for cross-host testing (runtest 
--host_board, testing where the build system on which you run runtest is 
different from the host system on which the tools being tested are run, 
[is_remote host]).

The main principles are:

- "remote_exec host" must be used instead of Tcl's built-in "exec".  
Because the two have different interfaces, this involves further changes.

- Various "which $foo" tests are inapplicable for cross-host testing.

The general case of cross-host testing requires copying all the input and 
output files between the build and host systems.  Most of the development 
and testing of this patch has been done with a shared filesystem between 
the build and host systems; a lot more changes would be needed for the 
general case.  The patch does however have some changes relevant to it; in 
particular, some existing support for cross-host testing causes files to 
be in different locations in the cross-host case, and other changes 
related to that are needed, and even with a shared filesystem doing 
filesystem operations on the right system (with remote_file) helps ensure 
coherency in the presence of filesystem caching.

There are three changes made to binutils C code to ensure consistency 
between hosts in some areas found to differ by the testsuite:

- elf32_arm_compare_mapping was not a valid qsort comparison function, 
returning 0 instead of -1 as the opposite to 1.  It is fixed to be a 
proper comparison function, and to avoid problems with unstable sorts so 
the linker output doesn't depend on the host qsort.

- sort_sections_by_lma would not always distinguish sections, leading to 
diagnostics (at least) depending on what order the host qsort used; a 
secondary comparison based on the internal section id is added to avoid 
this host dependence.

- The assembler is made to flush stderr before printing to stdout to 
ensure that the output ordering does not depend on the host in the 
presence of redirections.

It is likely other such places may be shown up by testing on other hosts 
and targets.

Most of the testsuite changes are reasonably straightforward.  There was 
dependence in some places on details of the exact operation of "exec" and 
'catch "exec ..."', which affected the details of the changes.  For 
example, explicit "subst" calls needed adding for options in .d files such 
as -I$srcdir/$subdir, which previously got implicitly expanded and no 
longer do; there was some dependence on the text "child process exited 
abnormally" added by Tcl exec; changes to the sequence in which text gets 
passed through ptys could cause \r\r\n line endings so requiring the 
change to gas/all/gas.exp:do_comment.

The actual cross-host testing was done with a toolchain targetted to 
arm-none-linux-gnueabi; it's likely further changes may be needed for 
other targets to get cross-host testing fully functional for them.  I also 
tested with normal cross/native toolchains (build = host = 
i686-pc-linux-gnu) for the following 86 targets (based on a list provided 
by Daniel, plus some more targets from config.bfd) to make sure the test 
results were identical before and after the patch.

alpha-linux-gnu
alpha-unknown-freebsd4.7
alpha-unknown-osf4.0
arc-elf
arm-aout
arm-eabi
arm-epoc-pe
arm-netbsdelf
arm-nto
arm-rtems
arm-vxworks
arm-wince-pe
avr-elf
bfin-elf
c4x-coff
cr16c-elf
cris-elf
crx-elf
d10v-elf
d30v-elf
dlx-elf
fr30-elf
frv-elf
frv-linux
h8300-elf
hppa-linux-gnu
hppa64-hp-hpux11.23
i686-pc-cygwin
i686-pc-elf
i686-pc-linux-gnu
ip2k-elf
iq2000-elf
m32c-elf
m32r-elf
m68hc11-elf
m68hc12-elf
m68k-elf
m68k-linux-gnu
m68k-rtems
m68k-uclinux
mcore-elf
mcore-pe
mep-elf
mingw32-pe
mips-elf
mips-sgi-irix5
mips-wrs-vxworks
mipsel-linux-gnu
mips64-linux
mmix-elf
mmix-mmixware
mn10200-elf
mn10300-elf
msp430-elf
mt-elf
ns32k-netbsd
openrisc-elf
or32-elf
pdp11-dec-bsd
pj-elf
powerpc-eabisim
powerpc-linux-gnu
powerpc-nto
powerpc-wrs-vxworks
powerpc64-linux-gnu
rs6000-aix4.3.3
s390-linux
sh-elf
sh-linux
sh-nto
shl-unknown-netbsdelf1.6T 
sh64-superh-linux-gnu
sparc-elf
sparc64-linux-gnu
sparc64-netbsd
sparc-linux-gnu
spu-elf
tic54x-coff
v850-elf
vax-netbsdelf
x86_64-linux
x86_64-mingw32
xscale-elf
xstormy16-elf
xtensa-elf
z8k-coff

My list also had the following targets, but the binutils sources I was 
using didn't build for them, whether because of not being supported in 
some or all directories, bitrot or temporary problems for those targets.

alpha-dec-vms
c30-aout
cr16-elf
h8300-coff
i960-coff
ia64-x-freebsd5
ia64-hp-hpux11.23
ia64-linux-gnu
m68k-aout
m68k-coff
m88k-coff
maxq-coff
or32-coff
sh-coff
sh-hms

OK to commit?

bfd:
2007-08-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma,
	then on type.

binutils/testsuite:
2007-08-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* 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-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* as.c (main): Flush stderr before printing listings to ensure
	consistent output order across platforms.

gas/testsuite:
2007-08-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* 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-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* ldlang.c (sort_sections_by_lma): Sort by internal id after lma
	for stable sort.

ld/testsuite:
2007-08-24  Mark Shinwell  <shinwell@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

	* 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.

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.125
diff -u -r1.125 elf32-arm.c
--- bfd/elf32-arm.c	6 Aug 2007 18:47:21 -0000	1.125
+++ bfd/elf32-arm.c	24 Aug 2007 21:32:34 -0000
@@ -9774,8 +9774,22 @@
 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;
 }
 
 
Index: binutils/testsuite/binutils-all/ar.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/ar.exp,v
retrieving revision 1.9
diff -u -r1.9 ar.exp
--- binutils/testsuite/binutils-all/ar.exp	5 Jul 2007 16:54:45 -0000	1.9
+++ binutils/testsuite/binutils-all/ar.exp	24 Aug 2007 21:32:35 -0000
@@ -42,6 +42,7 @@
     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 @@
     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 } {
Index: binutils/testsuite/binutils-all/objcopy.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/objcopy.exp,v
retrieving revision 1.47
diff -u -r1.47 objcopy.exp
--- binutils/testsuite/binutils-all/objcopy.exp	9 Aug 2007 11:25:58 -0000	1.47
+++ binutils/testsuite/binutils-all/objcopy.exp	24 Aug 2007 21:32:35 -0000
@@ -194,7 +194,7 @@
 		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 @@
     }
 
     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
Index: binutils/testsuite/binutils-all/readelf.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/readelf.exp,v
retrieving revision 1.26
diff -u -r1.26 readelf.exp
--- binutils/testsuite/binutils-all/readelf.exp	5 Jul 2007 16:54:45 -0000	1.26
+++ binutils/testsuite/binutils-all/readelf.exp	24 Aug 2007 21:32:35 -0000
@@ -41,9 +41,12 @@
 
     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 @@
     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 @@
     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 @@
     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)"
Index: binutils/testsuite/binutils-all/arm/objdump.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/arm/objdump.exp,v
retrieving revision 1.4
diff -u -r1.4 objdump.exp
--- binutils/testsuite/binutils-all/arm/objdump.exp	5 Jul 2007 16:54:45 -0000	1.4
+++ binutils/testsuite/binutils-all/arm/objdump.exp	24 Aug 2007 21:32:35 -0000
@@ -19,7 +19,7 @@
   return
 }
 
-if {[which $OBJDUMP] == 0} then {
+if {![is_remote host] && [which $OBJDUMP] == 0} then {
     perror "$OBJDUMP does not exist"
     return
 }
Index: binutils/testsuite/lib/utils-lib.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/lib/utils-lib.exp,v
retrieving revision 1.14
diff -u -r1.14 utils-lib.exp
--- binutils/testsuite/lib/utils-lib.exp	5 Jul 2007 16:54:46 -0000	1.14
+++ binutils/testsuite/lib/utils-lib.exp	24 Aug 2007 21:32:35 -0000
@@ -462,7 +462,7 @@
 	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 @@
     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 @@
     }
     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
Index: gas/as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.75
diff -u -r1.75 as.c
--- gas/as.c	3 Jul 2007 11:01:02 -0000	1.75
+++ gas/as.c	24 Aug 2007 21:32:35 -0000
@@ -1215,6 +1215,8 @@
   if (keep_it)
     write_object_file ();
 
+  fflush (stderr);
+
 #ifndef NO_LISTING
   listing_print (listing_filename);
 #endif
Index: gas/testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.47
diff -u -r1.47 gas.exp
--- gas/testsuite/gas/all/gas.exp	3 Jul 2007 11:17:32 -0000	1.47
+++ gas/testsuite/gas/all/gas.exp	24 Aug 2007 21:32:37 -0000
@@ -117,7 +117,7 @@
 	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 @@
     { *c54x*-*-* } { }
     default {
         test_cond
+	remote_download host "$srcdir/$subdir/incbin.dat"
         run_dump_test incbin
     }
 }
Index: gas/testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.19
diff -u -r1.19 cfi.exp
--- gas/testsuite/gas/cfi/cfi.exp	5 Jun 2007 17:00:31 -0000	1.19
+++ gas/testsuite/gas/cfi/cfi.exp	24 Aug 2007 21:32:37 -0000
@@ -28,11 +28,10 @@
 } 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"
     }
 
Index: gas/testsuite/gas/elf/elf.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/elf.exp,v
retrieving revision 1.39
diff -u -r1.39 elf.exp
--- gas/testsuite/gas/elf/elf.exp	19 Jul 2007 16:47:40 -0000	1.39
+++ gas/testsuite/gas/elf/elf.exp	24 Aug 2007 21:32:37 -0000
@@ -15,7 +15,13 @@
 	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
Index: gas/testsuite/gas/i386/i386.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/i386.exp,v
retrieving revision 1.73
diff -u -r1.73 i386.exp
--- gas/testsuite/gas/i386/i386.exp	9 Aug 2007 13:50:51 -0000	1.73
+++ gas/testsuite/gas/i386/i386.exp	24 Aug 2007 21:32:37 -0000
@@ -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 {
Index: gas/testsuite/gas/macros/macros.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/macros/macros.exp,v
retrieving revision 1.27
diff -u -r1.27 macros.exp
--- gas/testsuite/gas/macros/macros.exp	5 Jun 2007 17:00:32 -0000	1.27
+++ gas/testsuite/gas/macros/macros.exp	24 Aug 2007 21:32:38 -0000
@@ -53,6 +53,7 @@
 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 ""
Index: gas/testsuite/gas/maxq10/maxq10.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/maxq10/maxq10.exp,v
retrieving revision 1.3
diff -u -r1.3 maxq10.exp
--- gas/testsuite/gas/maxq10/maxq10.exp	5 Jun 2007 17:00:32 -0000	1.3
+++ gas/testsuite/gas/maxq10/maxq10.exp	24 Aug 2007 21:32:38 -0000
@@ -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 @@
     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 {
Index: gas/testsuite/gas/maxq20/maxq20.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/maxq20/maxq20.exp,v
retrieving revision 1.3
diff -u -r1.3 maxq20.exp
--- gas/testsuite/gas/maxq20/maxq20.exp	5 Jun 2007 17:00:32 -0000	1.3
+++ gas/testsuite/gas/maxq20/maxq20.exp	24 Aug 2007 21:32:38 -0000
@@ -6,8 +6,8 @@
     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 @@
     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]]
 }
 
 
Index: gas/testsuite/gas/sparc/sparc.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/sparc/sparc.exp,v
retrieving revision 1.11
diff -u -r1.11 sparc.exp
--- gas/testsuite/gas/sparc/sparc.exp	5 Jun 2007 17:00:33 -0000	1.11
+++ gas/testsuite/gas/sparc/sparc.exp	24 Aug 2007 21:32:39 -0000
@@ -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 { } {
Index: gas/testsuite/lib/gas-defs.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v
retrieving revision 1.27
diff -u -r1.27 gas-defs.exp
--- gas/testsuite/lib/gas-defs.exp	23 Jul 2007 14:03:33 -0000	1.27
+++ gas/testsuite/lib/gas-defs.exp	24 Aug 2007 21:32:40 -0000
@@ -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 @@
     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 @@
     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 @@
 	    unresolved $subdir/$name
 	    return
 	}
+	if { $opt_name == "as" } {
+	    set opt_val [subst $opt_val]
+	}
 	set opts($opt_name) $opt_val
     }
 
@@ -554,10 +619,11 @@
 	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 @@
     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 @@
 
     # 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 @@
     }
     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 @@
     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 @@
     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 { } {
Index: gas/testsuite/lib/gas-dg.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/lib/gas-dg.exp,v
retrieving revision 1.2
diff -u -r1.2 gas-dg.exp
--- gas/testsuite/lib/gas-dg.exp	8 Sep 2006 17:08:05 -0000	1.2
+++ gas/testsuite/lib/gas-dg.exp	24 Aug 2007 21:32:40 -0000
@@ -21,7 +21,7 @@
 	"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"
Index: gas/testsuite/lib/run
===================================================================
RCS file: gas/testsuite/lib/run
diff -N gas/testsuite/lib/run
--- gas/testsuite/lib/run	3 May 1999 07:28:53 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-#!/bin/sh
-eval exec $@
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.268
diff -u -r1.268 ldlang.c
--- ld/ldlang.c	29 Jul 2007 12:33:37 -0000	1.268
+++ ld/ldlang.c	24 Aug 2007 21:32:42 -0000
@@ -4103,6 +4103,10 @@
   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;
 }
Index: ld/testsuite/config/default.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/config/default.exp,v
retrieving revision 1.12
diff -u -r1.12 default.exp
--- ld/testsuite/config/default.exp	6 Jul 2007 14:09:42 -0000	1.12
+++ ld/testsuite/config/default.exp	24 Aug 2007 21:32:42 -0000
@@ -50,9 +50,7 @@
     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
Index: ld/testsuite/ld-checks/checks.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-checks/checks.exp,v
retrieving revision 1.11
diff -u -r1.11 checks.exp
--- ld/testsuite/ld-checks/checks.exp	6 Jul 2007 14:09:42 -0000	1.11
+++ ld/testsuite/ld-checks/checks.exp	24 Aug 2007 21:32:43 -0000
@@ -57,8 +57,7 @@
     # 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
Index: ld/testsuite/ld-elf/binutils.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/binutils.exp,v
retrieving revision 1.6
diff -u -r1.6 binutils.exp
--- ld/testsuite/ld-elf/binutils.exp	6 Jul 2007 14:09:43 -0000	1.6
+++ ld/testsuite/ld-elf/binutils.exp	24 Aug 2007 21:32:43 -0000
@@ -62,24 +62,24 @@
     }
 
     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
Index: ld/testsuite/ld-elf/elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/elf.exp,v
retrieving revision 1.11
diff -u -r1.11 elf.exp
--- ld/testsuite/ld-elf/elf.exp	23 Jul 2007 09:56:19 -0000	1.11
+++ ld/testsuite/ld-elf/elf.exp	24 Aug 2007 21:32:43 -0000
@@ -29,6 +29,10 @@
     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.
Index: ld/testsuite/ld-elf/exclude.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/exclude.exp,v
retrieving revision 1.5
diff -u -r1.5 exclude.exp
--- ld/testsuite/ld-elf/exclude.exp	6 Jul 2007 14:09:43 -0000	1.5
+++ ld/testsuite/ld-elf/exclude.exp	24 Aug 2007 21:32:43 -0000
@@ -53,8 +53,8 @@
     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
Index: ld/testsuite/ld-elf/tls_common.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/tls_common.exp,v
retrieving revision 1.3
diff -u -r1.3 tls_common.exp
--- ld/testsuite/ld-elf/tls_common.exp	6 Jul 2007 14:09:43 -0000	1.3
+++ ld/testsuite/ld-elf/tls_common.exp	24 Aug 2007 21:32:43 -0000
@@ -62,8 +62,7 @@
     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"
Index: ld/testsuite/ld-elfcomm/elfcomm.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elfcomm/elfcomm.exp,v
retrieving revision 1.14
diff -u -r1.14 elfcomm.exp
--- ld/testsuite/ld-elfcomm/elfcomm.exp	6 Jul 2007 14:09:43 -0000	1.14
+++ ld/testsuite/ld-elfcomm/elfcomm.exp	24 Aug 2007 21:32:43 -0000
@@ -34,7 +34,7 @@
 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 @@
     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"
Index: ld/testsuite/ld-scripts/crossref.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/crossref.exp,v
retrieving revision 1.15
diff -u -r1.15 crossref.exp
--- ld/testsuite/ld-scripts/crossref.exp	6 Jul 2007 14:09:45 -0000	1.15
+++ ld/testsuite/ld-scripts/crossref.exp	24 Aug 2007 21:32:43 -0000
@@ -24,7 +24,7 @@
 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 @@
 # 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 @@
     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 @@
     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]
 
Index: ld/testsuite/ld-scripts/map-address.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/map-address.exp,v
retrieving revision 1.4
diff -u -r1.4 map-address.exp
--- ld/testsuite/ld-scripts/map-address.exp	6 Jul 2007 14:09:45 -0000	1.4
+++ ld/testsuite/ld-scripts/map-address.exp	24 Aug 2007 21:32:43 -0000
@@ -31,7 +31,14 @@
 	  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
Index: ld/testsuite/ld-scripts/phdrs.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/phdrs.exp,v
retrieving revision 1.15
diff -u -r1.15 phdrs.exp
--- ld/testsuite/ld-scripts/phdrs.exp	6 Jul 2007 14:09:45 -0000	1.15
+++ ld/testsuite/ld-scripts/phdrs.exp	24 Aug 2007 21:32:43 -0000
@@ -52,13 +52,11 @@
 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
 
Index: ld/testsuite/ld-scripts/phdrs2.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/phdrs2.exp,v
retrieving revision 1.5
diff -u -r1.5 phdrs2.exp
--- ld/testsuite/ld-scripts/phdrs2.exp	6 Jul 2007 14:09:45 -0000	1.5
+++ ld/testsuite/ld-scripts/phdrs2.exp	24 Aug 2007 21:32:43 -0000
@@ -57,13 +57,12 @@
 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
 
Index: ld/testsuite/ld-scripts/weak.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/weak.exp,v
retrieving revision 1.13
diff -u -r1.13 weak.exp
--- ld/testsuite/ld-scripts/weak.exp	6 Jul 2007 14:09:45 -0000	1.13
+++ ld/testsuite/ld-scripts/weak.exp	24 Aug 2007 21:32:43 -0000
@@ -60,14 +60,13 @@
 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
 
Index: ld/testsuite/ld-selective/selective.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-selective/selective.exp,v
retrieving revision 1.37
diff -u -r1.37 selective.exp
--- ld/testsuite/ld-selective/selective.exp	6 Jul 2007 14:09:45 -0000	1.37
+++ ld/testsuite/ld-selective/selective.exp	24 Aug 2007 21:32:43 -0000
@@ -71,7 +71,7 @@
 }
 
 # 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 @@
 	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 @@
 
     # 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"
     }
 
Index: ld/testsuite/ld-srec/srec.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-srec/srec.exp,v
retrieving revision 1.27
diff -u -r1.27 srec.exp
--- ld/testsuite/ld-srec/srec.exp	16 Aug 2007 13:51:27 -0000	1.27
+++ ld/testsuite/ld-srec/srec.exp	24 Aug 2007 21:32:43 -0000
@@ -305,8 +305,7 @@
     }
 
     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 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 @@
 # 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 @@
 # 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
 }
Index: ld/testsuite/ld-undefined/undefined.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-undefined/undefined.exp,v
retrieving revision 1.27
diff -u -r1.27 undefined.exp
--- ld/testsuite/ld-undefined/undefined.exp	6 Jul 2007 14:09:45 -0000	1.27
+++ ld/testsuite/ld-undefined/undefined.exp	24 Aug 2007 21:32:43 -0000
@@ -25,7 +25,7 @@
 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 @@
     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"
 
Index: ld/testsuite/ld-undefined/weak-undef.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-undefined/weak-undef.exp,v
retrieving revision 1.8
diff -u -r1.8 weak-undef.exp
--- ld/testsuite/ld-undefined/weak-undef.exp	6 Jul 2007 14:09:45 -0000	1.8
+++ ld/testsuite/ld-undefined/weak-undef.exp	24 Aug 2007 21:32:43 -0000
@@ -66,13 +66,12 @@
 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
 
Index: ld/testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.49
diff -u -r1.49 ld-lib.exp
--- ld/testsuite/lib/ld-lib.exp	17 Aug 2007 13:22:44 -0000	1.49
+++ ld/testsuite/lib/ld-lib.exp	24 Aug 2007 21:32:44 -0000
@@ -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 @@
     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
+    remote_file host delete $target
 
-    verbose -log "$ld $HOSTING_EMU $flags -o $target $objs $libs"
-
-    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 @@
 	set flags "$gcc_ld_flag $flags"
     }
 
-    catch "exec rm -f $target" exec_output
-
-    verbose -log "$ld $flags -o $target $objects"
+    remote_file host delete $target
 
-    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 @@
     if [string match "" $exec_output] then {
 	return 1
     } else {
-	verbose -log "$exec_output"
 	return 0
     }
 }
@@ -215,12 +216,13 @@
     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 @@
 
     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 @@
     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 @@
     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 @@
 	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 @@
 		}
 	    }
 	}
+	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 @@
 	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 @@
 		   $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 @@
     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 @@
     }
     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 @@
 			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 @@
 			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"
 		}
 	    }
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]