2007-08-28  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-28  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-28  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-28  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-28  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-28  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.
This commit is contained in:
Joseph Myers 2007-08-28 13:21:58 +00:00
parent ad71ef64ac
commit 7f6a71ffb6
42 changed files with 450 additions and 242 deletions

View file

@ -1,3 +1,9 @@
2007-08-28 Mark Shinwell <shinwell@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* elf32-arm.c (elf32_arm_compare_mapping): Compare first on vma,
then on type.
2007-08-28 Robert Sebastian Gerus <arachnist@gmail.com>
* config.bfd: Add support for i[3-7]86-*-dragonfly*.

View file

@ -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;
}

View file

@ -1,3 +1,20 @@
2007-08-28 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.
2007-08-09 Alan Modra <amodra@bigpond.net.au>
* binutils-all/copy-2.d (not-target): Match *-*-*aout.

View file

@ -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 } {

View file

@ -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
}

View file

@ -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

View file

@ -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)"

View file

@ -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

View file

@ -1,3 +1,9 @@
2007-08-28 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.
2007-08-28 Robert Sebastian Gerus <arachnist@gmail.com>
* configure.tgt: Add support for i[3-7]86-*-dragonfly*.

View file

@ -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

View file

@ -1,3 +1,30 @@
2007-08-28 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.
2007-08-09 Paul Brook <paul@codesourcery.com>
* gas/arm/relax_load_align.d: new test.

View file

@ -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
}
}

View file

@ -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"
}

View file

@ -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

View file

@ -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 {

View file

@ -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 ""

View file

@ -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 {

View file

@ -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]]
}

View file

@ -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 { } {

View file

@ -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 { } {

View file

@ -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"

View file

@ -1,2 +0,0 @@
#!/bin/sh
eval exec $@

View file

@ -1,3 +1,9 @@
2007-08-28 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.
2007-08-28 Robert Sebastian Gerus <arachnist@gmail.com>
* configure.host: Add support for i[3-7]86-*-dragonfly*.

View file

@ -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;
}

View file

@ -1,3 +1,46 @@
2007-08-28 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.
2007-08-24 H.J. Lu <hongjiu.lu@intel.com>
* ld-i386/i386.exp (i386tests): Add a test for TLS IE->LE

View file

@ -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

View file

@ -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

View file

@ -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

View file

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

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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]

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"
}

View file

@ -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
}

View file

@ -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"

View file

@ -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

View file

@ -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"
}
}
proc run_host_cmd { prog command } {
global link_output
if { ![is_remote host] && [which "$prog"] == 0 } then {
perror "$prog does not exist"
return 0
}
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
if [string match "" $link_output] then {
return ""
}
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;
}
return 0;
}
# Link an object using relocation.
#
proc default_ld_relocate { ld target objects } {
global HOSTING_EMU
global host_triplet
global exec_output
if { [which $ld] == 0 } then {
perror "$ld does not exist"
return 0
}
catch "exec rm -f $target" exec_output
verbose -log "$ld $HOSTING_EMU -o $target -r $objects"
catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then {
return 1
} else {
verbose -log "$exec_output"
return 0
}
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
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 @@ 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"
}
}