--- binutils-2.18/binutils/testsuite/binutils-all/readelf.s	2003-09-30 00:15:54.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/readelf.s	2008-05-28 15:43:58.000000000 +0000
@@ -21,4 +21,4 @@ Key to Flags:
   W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\)
   I \(info\), L \(link order\), G \(group\), x \(unknown\)
   O \(extra OS processing required\) o \(OS specific\), p \(processor specific\)
-
+XYZ0ZYX
--- binutils-2.18/binutils/testsuite/binutils-all/readelf.r	2002-02-20 10:32:47.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/readelf.r	2008-05-28 15:43:58.000000000 +0000
@@ -2,3 +2,4 @@
 Relocation section '.rel.*text' at offset 0x.* contains 1 entries:
  Offset     Info    Type            Sym.Value  Sym. Name.*
 00000004  [0-9A-Fa-f]+ *R_.*00000000   external_symbol.*
+XYZ0ZYX
--- binutils-2.18/binutils/testsuite/binutils-all/readelf.ss	2005-10-08 17:07:15.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/readelf.ss	2008-05-28 15:43:58.000000000 +0000
@@ -16,3 +16,4 @@ Symbol table '.symtab' contains .* entri
     ..: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND external_symbol
     ..: 00000000     0 NOTYPE  GLOBAL DEFAULT    [34] data_symbol
     ..: 00000004     4 OBJECT  GLOBAL DEFAULT ( COM|ANSI_COM) common_symbol
+XYZ0ZYX
--- binutils-2.18/binutils/testsuite/binutils-all/strip-1.d	2006-09-14 23:37:35.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/strip-1.d	2008-05-28 15:43:58.000000000 +0000
@@ -9,3 +9,4 @@
   \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WA[ \t]+.*
 #...
 There are no section groups in this file.
+XYZ0ZYX
--- binutils-2.18/binutils/testsuite/binutils-all/strip-2.d	2006-09-14 23:37:35.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/strip-2.d	2008-05-28 15:43:58.000000000 +0000
@@ -15,4 +15,5 @@ COMDAT group section \[[ 0-9]+\] `foo_gr
    \[Index\]    Name
    \[[ 0-9]+\]   .text.*
    \[[ 0-9]+\]   .data.*
+XYZ0ZYX
 #pass
--- binutils-2.18/binutils/testsuite/binutils-all/readelf.h	2003-09-30 00:15:54.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/readelf.h	2008-05-28 15:43:58.000000000 +0000
@@ -18,3 +18,4 @@ ELF Header:
   Size of section headers:           .* \(bytes\)
   Number of section headers:         .*
   Section header string table index: .*
+XYZ0ZYX
--- binutils-2.18/binutils/testsuite/binutils-all/readelf.exp	2007-08-06 19:56:17.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/readelf.exp	2008-06-03 16:03:06.346200600 +0000
@@ -21,6 +21,12 @@
 # Based on scripts written by Ian Lance Taylor <ian@cygnus.com>
 # and Ken Raeburn <raeburn@cygnus.com>.
 
+# Exclude non-ELF targets.
+if ![is_elf_format] {
+    verbose "$READELF is only intended for ELF targets" 2
+    return
+}
+
 # First some helpful procedures, then the tests themselves
 
 # Return the contents of the filename given
@@ -41,16 +47,19 @@ 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" ""]
+    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
     }
 
     if { ! [regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \
-	    [file_contents readelf.out] nil readelf_size] } {
+	    [lindex $got 1] nil readelf_size] } {
 	verbose -log "EI_CLASS field not found in output"
 	verbose -log "output is \n[file_contents readelf.out]"
 	fail $testname
@@ -76,13 +85,13 @@ proc readelf_test { options binary_file 
     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,16 +155,16 @@ 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 > readelf.out\"" "" "/dev/null" ""]
+
 
     # Upload the results.
-    set output [remote_upload host readelf.out]
+    set output [remote_upload host readelf.out tmpdir/readelf.out]
 
     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)"
@@ -201,10 +210,58 @@ proc readelf_wi_test {} {
 }
 
 
-# Exclude non-ELF targets.
-if ![is_elf_format] {
-    verbose "$READELF is only intended for ELF targets" 2
-    return
+# Test readelf's dumping abilities.
+
+proc readelf_dump_test {} {
+    global READELF
+    global READELFFLAGS
+    global srcdir
+    global subdir
+    
+    # Assemble the dump test file.
+    if {![binutils_assemble $srcdir/$subdir/dumptest.s tmpdir/dumptest.o]} then {
+      unresolved "readelf -p: failed to assemble dump test file"
+      return
+    }
+    # Download it.
+    set tempfile [remote_download host tmpdir/dumptest.o]
+
+    # Run "readelf -p.data" on it.
+    set got [remote_exec host "$READELF $READELFFLAGS -p.data \" $tempfile > readelf.out\" " "" "/dev/null" ""]
+    set got [lindex $got 1]
+
+    # Upload the results.
+    set output [remote_upload host readelf.out tmpdir/readelf.out]
+
+    # Check for something going wrong.
+    if ![string match "" $got] then {
+	fail "readelf -p: unexpected output"
+	send_log $got
+	send_log "\n"
+	return
+    }
+
+    # Search for strings that should be in the output.
+    set sought {
+	".*test_string.*"
+    }
+    
+    foreach looked_for $sought {	
+	set lines [grep $output $looked_for]
+	if ![llength $lines] then {
+	    fail "readelf -p: missing: $looked_for"
+	    send_log readelf.out
+	    return
+	}
+    }
+
+    file_on_host delete $tempfile    
+    file_on_host delete $output
+
+    # All done.
+    pass "readelf -p"
+
+    # XXX FIXME: Add test of readelf -x here
 }
 
 if ![is_remote host] {
@@ -218,7 +275,7 @@ send_user "Version [binutil_version $REA
 
 # Assemble the test file.
 if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
-    perror "unresolved 1"
+    perror "could not assemble test file"
     unresolved "readelf - failed to assemble"
     return
 }
@@ -239,3 +296,5 @@ readelf_test -s $tempfile readelf.ss {}
 readelf_test -r $tempfile readelf.r  {}
 
 readelf_wi_test
+
+readelf_dump_test
--- binutils-2.18/binutils/testsuite/binutils-all/ar.exp	2007-08-06 19:56:17.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/ar.exp	2008-06-03 16:09:13.487386656 +0000
@@ -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.
@@ -56,6 +57,7 @@ proc long_filenames { } {
 
 
     remote_file build delete $file2
+    remote_file host delete $n2
 
     set status [catch "set f [open tmpdir/$n2 w]" errs]
     if { $status != 0 } {
--- binutils-2.18/binutils/testsuite/binutils-all/objcopy.exp	2007-08-12 19:00:06.000000000 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/binutils-all/objcopy.exp	2008-06-03 16:22:44.009168616 +0000
@@ -53,7 +53,7 @@ proc objcopy_test {testname srcfile} {
 	unresolved "objcopy ($testname)"
 	return
     }
-
+    set tempfile a.out 
     set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile ${copyfile}.o"]
 
     if ![string match "" $got] then {
@@ -118,7 +118,7 @@ set got [binutils_run $OBJCOPY "$OBJCOPY
 if ![string match "" $got] then {
     fail "objcopy --reverse-bytes"
 } else {
-    if [is_remote host] {
+    if ![is_remote host] {
         remote_upload host ${reversed} tmpdir/copy-reversed.o
         set reversed tmpdir/copy-reversed.o
     }
@@ -194,7 +194,8 @@ if ![string match "" $got] then {
 		verbose $line
 		fail "objcopy -O srec"
 	    } else {
-		set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+                set srecfile copy.sre
+		set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${srecfile}"]
 		if ![regexp "file format srec" $got] then {
 		    send_log "objdump failed\n"
 		    fail "objcopy -O srec"
@@ -721,24 +722,33 @@ proc objcopy_test_readelf {testname srcf
 	return
     }
 
-    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 {
+    verbose -log "sh4-linux-$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
+    set exec_output [remote_exec build "sh4-linux-$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]
+    verbose -log "sh4-linux-$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out"
+    set exec_output [remote_exec build "sh4-linux-$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 build "sh4-linux-$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
--- binutils-2.18/binutils/testsuite/lib/utils-lib.exp	2008-06-04 09:07:59.070885504 +0000
+++ binutils-2.18.50.0.1/binutils/testsuite/lib/utils-lib.exp	2008-06-04 09:32:59.195831848 +0000
@@ -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
