* lib/ld-lib.exp (default_ld_nm): Run nm with LC_ALL=C to ensure

consistent sorting.
	(run_dump_test): Likewise for objdump/nm/objcopy/readelf.
	* ld-sh/sh64/sh64.exp (run_ld_link_tests): Likewise.
This commit is contained in:
Alan Modra 2002-07-02 23:54:39 +00:00
parent 139e4a7044
commit 3e8cba195d
3 changed files with 112 additions and 78 deletions

View File

@ -1,7 +1,14 @@
2002-07-03 Alan Modra <amodra@bigpond.net.au>
* lib/ld-lib.exp (default_ld_nm): Run nm with LC_ALL=C to ensure
consistent sorting.
(run_dump_test): Likewise for objdump/nm/objcopy/readelf.
* ld-sh/sh64/sh64.exp (run_ld_link_tests): Likewise.
2002-06-29 Hans-Peter Nilsson <hp@bitrange.com> 2002-06-29 Hans-Peter Nilsson <hp@bitrange.com>
* ld-mmix/sec-8m.d, ld-mmix/sec-8m.s, ld-mmix/sec-8a.s, * ld-mmix/sec-8m.d, ld-mmix/sec-8m.s, ld-mmix/sec-8a.s,
ld-mmix/sec-8b.s, ld-mmix/sec-8d.s: New test. ld-mmix/sec-8b.s, ld-mmix/sec-8d.s: New test.
2002-06-18 Chris Demetriou <cgd@broadcom.com> 2002-06-18 Chris Demetriou <cgd@broadcom.com>
@ -14,7 +21,7 @@
* ld-d10v/default_layout.d : New test. * ld-d10v/default_layout.d : New test.
* ld-d10v/regression-001.lt: New test for a linker regression. * ld-d10v/regression-001.lt: New test for a linker regression.
* ld-d10v/linktest-002.lt: New test for run_link_test. * ld-d10v/linktest-002.lt: New test for run_link_test.
* ld-d10v/reloc-001.d - reloc-016.d: New tests. * ld-d10v/reloc-001.d - reloc-016.d: New tests.
2002-06-11 John David Anglin <dave@hiauly1.hia.nrc.ca> 2002-06-11 John David Anglin <dave@hiauly1.hia.nrc.ca>
@ -36,9 +43,9 @@
2002-06-07 Nick Clifton <nickc@cambridge.redhat.com> 2002-06-07 Nick Clifton <nickc@cambridge.redhat.com>
* ld-scripts/phdrs2.s: Use .p2align instead of .align. * ld-scripts/phdrs2.s: Use .p2align instead of .align.
Use section names .foo and .bar instead of .text and .data. Use section names .foo and .bar instead of .text and .data.
* ld-scripts/phdrs2.t: Refer to .foo and .bar instead of .text * ld-scripts/phdrs2.t: Refer to .foo and .bar instead of .text
and .data. and .data.
2002-06-06 David Heine <dlheine@tensilica.com> 2002-06-06 David Heine <dlheine@tensilica.com>
@ -206,11 +213,11 @@
2001-03-14 DJ Delorie <dj@redhat.com> 2001-03-14 DJ Delorie <dj@redhat.com>
* ld-sh/sh64/endian.dbd: New file, endian tests. * ld-sh/sh64/endian.dbd: New file, endian tests.
* ld-sh/sh64/endian.dld: Ditto. * ld-sh/sh64/endian.dld: Ditto.
* ld-sh/sh64/endian.ld: Ditto. * ld-sh/sh64/endian.ld: Ditto.
* ld-sh/sh64/endian.s: Ditto. * ld-sh/sh64/endian.s: Ditto.
* ld-sh/sh64/endian.sbd: Ditto. * ld-sh/sh64/endian.sbd: Ditto.
* ld-sh/sh64/endian.sld: Ditto. * ld-sh/sh64/endian.sld: Ditto.
* ld-sh/sh64/sh64.exp: Add above tests. Add -L option to ld. * ld-sh/sh64/sh64.exp: Add above tests. Add -L option to ld.
2001-03-12 DJ Delorie <dj@redhat.com> 2001-03-12 DJ Delorie <dj@redhat.com>
* ld-sh/sh64/relax.exp: New file, test disabling relaxing. * ld-sh/sh64/relax.exp: New file, test disabling relaxing.
* ld-sh/sh64/relax1.s: Ditto. * ld-sh/sh64/relax1.s: Ditto.
@ -1131,9 +1138,9 @@ Wed Jun 9 12:02:33 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
Tue Feb 2 19:15:02 1999 Catherine Moore <clm@cygnus.com> Tue Feb 2 19:15:02 1999 Catherine Moore <clm@cygnus.com>
* ld-selective/selective.exp: Disable test for unsupported * ld-selective/selective.exp: Disable test for unsupported
targets. Change tests to check for absence of symbols instead targets. Change tests to check for absence of symbols instead
of address zero. of address zero.
Mon Jan 18 03:44:52 1999 Ian Lance Taylor <ian@cygnus.com> Mon Jan 18 03:44:52 1999 Ian Lance Taylor <ian@cygnus.com>
@ -1173,10 +1180,10 @@ Sun Dec 6 12:59:37 1998 H.J. Lu <hjl@gnu.org>
Fri Oct 23 16:28:29 1998 Catherine Moore <clm@cygnus.com> Fri Oct 23 16:28:29 1998 Catherine Moore <clm@cygnus.com>
* ld-selective: New directory with new files to test * ld-selective: New directory with new files to test
selective linking. selective linking.
* lib/ld-lib.exp (ld_nm): Strip leading underscore from $name. * lib/ld-lib.exp (ld_nm): Strip leading underscore from $name.
Sun Oct 4 22:17:05 1998 Ian Lance Taylor <ian@cygnus.com> Sun Oct 4 22:17:05 1998 Ian Lance Taylor <ian@cygnus.com>
@ -1793,7 +1800,7 @@ Fri May 27 09:35:04 1994 Ken Raeburn (raeburn@cygnus.com)
Tue May 17 15:06:49 1994 Bill Cox (bill@rtl.cygnus.com) Tue May 17 15:06:49 1994 Bill Cox (bill@rtl.cygnus.com)
* ld.bootstrap/bootstrap.exp, lib/ld.exp: Replace error proc * ld.bootstrap/bootstrap.exp, lib/ld.exp: Replace error proc
calls with perror calls. calls with perror calls.
Wed May 11 16:47:46 1994 Ken Raeburn (raeburn@rtl.cygnus.com) Wed May 11 16:47:46 1994 Ken Raeburn (raeburn@rtl.cygnus.com)

View File

@ -5,12 +5,12 @@
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -119,7 +119,7 @@ set sh64tests {
{"SH64 Little Endianness" "-mshlelf64 -Tendian.ld" {"SH64 Little Endianness" "-mshlelf64 -Tendian.ld"
"--abi=64 --little" {endian.s} "--abi=64 --little" {endian.s}
{{objdump -s endian.sld} {objdump -d endian.dld}}} {{objdump -s endian.sld} {objdump -d endian.dld}}}
} }
# FIXME: Generalize and move this to ld-lib.exp # FIXME: Generalize and move this to ld-lib.exp
@ -132,6 +132,7 @@ proc run_ld_link_tests { ldtests } {
global readelf global readelf
global srcdir global srcdir
global subdir global subdir
global env
set binfile "tmpdir/linked" set binfile "tmpdir/linked"
@ -199,8 +200,19 @@ proc run_ld_link_tests { ldtests } {
set dumpfile [lindex $actionlist 2] set dumpfile [lindex $actionlist 2]
set binary $dump_prog set binary $dump_prog
send_log "$binary $progopts $binfile > dump.out\n" # Ensure consistent sorting of symbols
catch "exec $binary $progopts $binfile > dump.out" comp_output if {[info exists env(LC_ALL)]} {
set old_lc_all $env(LC_ALL)
}
set env(LC_ALL) "C"
set cmd "$binary $progopts $binfile > dump.out"
send_log "$cmd\n"
catch "exec $cmd" comp_output
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] set comp_output [prune_warnings $comp_output]
if ![string match "" $comp_output] then { if ![string match "" $comp_output] then {
@ -300,9 +312,9 @@ proc regexp_diff { file_1 file_2 } {
} }
} }
if { $diff_pass } { if { $diff_pass } {
break break
} elseif { $end_1 && $end_2 } { } elseif { $end_1 && $end_2 } {
break break
} elseif { $end_1 } { } elseif { $end_1 } {
send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n" send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n"

View File

@ -1,23 +1,23 @@
# Support routines for LD testsuite. # Support routines for LD testsuite.
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
# #
# This file is free software; you can redistribute it and/or modify # This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
# #
# default_ld_version # default_ld_version
# extract and print the version number of ld # extract and print the version number of ld
# #
proc default_ld_version { ld } { proc default_ld_version { ld } {
@ -27,7 +27,7 @@ proc default_ld_version { ld } {
perror "$ld does not exist" perror "$ld does not exist"
exit 1 exit 1
} }
catch "exec $ld --version" tmp catch "exec $ld --version" tmp
set tmp [prune_warnings $tmp] set tmp [prune_warnings $tmp]
regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number
@ -37,20 +37,20 @@ proc default_ld_version { ld } {
} }
# #
# default_ld_relocate # default_ld_relocate
# link an object using relocation # link an object using relocation
# #
proc default_ld_relocate { ld target objects } { proc default_ld_relocate { ld target objects } {
global HOSTING_EMU global HOSTING_EMU
global host_triplet global host_triplet
if { [which $ld] == 0 } then { if { [which $ld] == 0 } then {
perror "$ld does not exist" perror "$ld does not exist"
return 0 return 0
} }
verbose -log "$ld $HOSTING_EMU -o $target -r $objects" verbose -log "$ld $HOSTING_EMU -o $target -r $objects"
catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
set exec_output [prune_warnings $exec_output] set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then { if [string match "" $exec_output] then {
@ -88,7 +88,7 @@ proc is_endian_output_format { object_flags } {
# process_multilib_options. # process_multilib_options.
proc big_or_little_endian {} { proc big_or_little_endian {} {
if [board_info [target_info name] exists multilib_flags] { if [board_info [target_info name] exists multilib_flags] {
set tmp_flags " [board_info [target_info name] multilib_flags]"; set tmp_flags " [board_info [target_info name] multilib_flags]";
@ -111,7 +111,7 @@ proc big_or_little_endian {} {
} }
# #
# default_ld_link # default_ld_link
# link a program using ld # link a program using ld
# #
proc default_ld_link { ld target objects } { proc default_ld_link { ld target objects } {
@ -121,10 +121,10 @@ proc default_ld_link { ld target objects } {
global LIBS global LIBS
global host_triplet global host_triplet
global link_output global link_output
set objs "$HOSTING_CRT0 $objects" set objs "$HOSTING_CRT0 $objects"
set libs "$LIBS $HOSTING_LIBS" set libs "$LIBS $HOSTING_LIBS"
if { [which $ld] == 0 } then { if { [which $ld] == 0 } then {
perror "$ld does not exist" perror "$ld does not exist"
return 0 return 0
@ -136,7 +136,7 @@ proc default_ld_link { ld target objects } {
set flags "" set flags ""
} }
verbose -log "$ld $HOSTING_EMU $flags -o $target $objs $libs" verbose -log "$ld $HOSTING_EMU $flags -o $target $objs $libs"
catch "exec $ld $HOSTING_EMU $flags -o $target $objs $libs" link_output catch "exec $ld $HOSTING_EMU $flags -o $target $objs $libs" link_output
set exec_output [prune_warnings $link_output] set exec_output [prune_warnings $link_output]
if [string match "" $link_output] then { if [string match "" $link_output] then {
@ -148,7 +148,7 @@ proc default_ld_link { ld target objects } {
} }
# #
# default_ld_simple_link # default_ld_simple_link
# link a program using ld, without including any libraries # link a program using ld, without including any libraries
# #
proc default_ld_simple_link { ld target objects } { proc default_ld_simple_link { ld target objects } {
@ -159,15 +159,15 @@ proc default_ld_simple_link { ld target objects } {
perror "$ld does not exist" perror "$ld does not exist"
return 0 return 0
} }
if [is_endian_output_format $objects] then { if [is_endian_output_format $objects] then {
set flags [big_or_little_endian] set flags [big_or_little_endian]
} else { } else {
set flags "" set flags ""
} }
verbose -log "$ld $flags -o $target $objects" verbose -log "$ld $flags -o $target $objects"
catch "exec $ld $flags -o $target $objects" link_output catch "exec $ld $flags -o $target $objects" link_output
set exec_output [prune_warnings $link_output] set exec_output [prune_warnings $link_output]
@ -184,7 +184,7 @@ proc default_ld_simple_link { ld target objects } {
} }
# #
# default_ld_compile # default_ld_compile
# compile an object using cc # compile an object using cc
# #
proc default_ld_compile { cc source object } { proc default_ld_compile { cc source object } {
@ -256,7 +256,7 @@ proc default_ld_compile { cc source object } {
proc default_ld_assemble { as source object } { proc default_ld_assemble { as source object } {
global ASFLAGS global ASFLAGS
global host_triplet global host_triplet
if {[which $as] == 0} then { if {[which $as] == 0} then {
perror "$as does not exist" perror "$as does not exist"
return 0 return 0
@ -299,9 +299,19 @@ proc default_ld_nm { nm nmflags object } {
if ![info exists NMFLAGS] { set NMFLAGS "" } if ![info exists NMFLAGS] { set NMFLAGS "" }
# Ensure consistent sorting of symbols
if {[info exists env(LC_ALL)]} {
set old_lc_all $env(LC_ALL)
}
set env(LC_ALL) "C"
verbose -log "$nm $NMFLAGS $nmflags $object >tmpdir/nm.out" verbose -log "$nm $NMFLAGS $nmflags $object >tmpdir/nm.out"
catch "exec $nm $NMFLAGS $nmflags $object >tmpdir/nm.out" exec_output catch "exec $nm $NMFLAGS $nmflags $object >tmpdir/nm.out" exec_output
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] set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then { if [string match "" $exec_output] then {
set file [open tmpdir/nm.out r] set file [open tmpdir/nm.out r]
@ -353,26 +363,26 @@ proc is_elf_format {} {
# #
proc simple_diff { file_1 file_2 } { proc simple_diff { file_1 file_2 } {
global target global target
set eof -1 set eof -1
set differences 0 set differences 0
if [file exists $file_1] then { if [file exists $file_1] then {
set file_a [open $file_1 r] set file_a [open $file_1 r]
} else { } else {
warning "$file_1 doesn't exist" warning "$file_1 doesn't exist"
return return
} }
if [file exists $file_2] then { if [file exists $file_2] then {
set file_b [open $file_2 r] set file_b [open $file_2 r]
} else { } else {
fail "$file_2 doesn't exist" fail "$file_2 doesn't exist"
return return
} }
verbose "# Diff'ing: $file_1 $file_2\n" 2 verbose "# Diff'ing: $file_1 $file_2\n" 2
while { [gets $file_a line] != $eof } { while { [gets $file_a line] != $eof } {
if [regexp "^#.*$" $line] then { if [regexp "^#.*$" $line] then {
continue continue
@ -381,7 +391,7 @@ proc simple_diff { file_1 file_2 } {
} }
} }
close $file_a close $file_a
while { [gets $file_b line] != $eof } { while { [gets $file_b line] != $eof } {
if [regexp "^#.*$" $line] then { if [regexp "^#.*$" $line] then {
continue continue
@ -405,7 +415,7 @@ proc simple_diff { file_1 file_2 } {
return return
} }
} }
if { [llength $list_a] != [llength $list_b] } { if { [llength $list_a] != [llength $list_b] } {
fail "Test: $target" fail "Test: $target"
return return
@ -416,11 +426,11 @@ proc simple_diff { file_1 file_2 } {
} }
} }
# run_dump_test FILE # run_dump_test FILE
# Copied from gas testsuite, tweaked and further extended. # Copied from gas testsuite, tweaked and further extended.
# #
# Assemble a .s file, then run some utility on it and check the output. # Assemble a .s file, then run some utility on it and check the output.
# #
# There should be an assembly language file named FILE.s in the test # There should be an assembly language file named FILE.s in the test
# suite directory, and a pattern file called FILE.d. `run_dump_test' # suite directory, and a pattern file called FILE.d. `run_dump_test'
# will assemble FILE.s, run some tool like `objdump', `objcopy', or # will assemble FILE.s, run some tool like `objdump', `objcopy', or
@ -432,9 +442,9 @@ proc simple_diff { file_1 file_2 } {
# flags to pass to the assembler, the program to run to dump the # flags to pass to the assembler, the program to run to dump the
# assembler's output, and the options it wants. The option lines have # assembler's output, and the options it wants. The option lines have
# the syntax: # the syntax:
# #
# # OPTION: VALUE # # OPTION: VALUE
# #
# OPTION is the name of some option, like "name" or "objdump", and # OPTION is the name of some option, like "name" or "objdump", and
# VALUE is OPTION's value. The valid options are described below. # VALUE is OPTION's value. The valid options are described below.
# Whitespace is ignored everywhere, except within VALUE. The option # Whitespace is ignored everywhere, except within VALUE. The option
@ -442,12 +452,12 @@ proc simple_diff { file_1 file_2 } {
# (hmm, not great for error detection). # (hmm, not great for error detection).
# #
# The interesting options are: # The interesting options are:
# #
# name: TEST-NAME # name: TEST-NAME
# The name of this test, passed to DejaGNU's `pass' and `fail' # The name of this test, passed to DejaGNU's `pass' and `fail'
# commands. If omitted, this defaults to FILE, the root of the # commands. If omitted, this defaults to FILE, the root of the
# .s and .d files' names. # .s and .d files' names.
# #
# as: FLAGS # as: FLAGS
# When assembling, pass FLAGS to the assembler. # When assembling, pass FLAGS to the assembler.
# If assembling several files, you can pass different assembler # If assembling several files, you can pass different assembler
@ -474,6 +484,8 @@ proc simple_diff { file_1 file_2 } {
# objcopy: FLAGS # objcopy: FLAGS
# Use the specified program to analyze the assembler or linker # Use the specified program to analyze the assembler or linker
# output file, and pass it FLAGS, in addition to the output name. # output file, and pass it FLAGS, in addition to the output name.
# Note that they are run with LC_ALL=C in the environment to give
# consistent sorting of symbols.
# #
# source: SOURCE [FLAGS] # source: SOURCE [FLAGS]
# Assemble the file SOURCE.s using the flags in the "as" directive # Assemble the file SOURCE.s using the flags in the "as" directive
@ -512,6 +524,7 @@ proc run_dump_test { name } {
global OBJDUMP NM AS OBJCOPY READELF LD global OBJDUMP NM AS OBJCOPY READELF LD
global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS LDFLAGS global OBJDUMPFLAGS NMFLAGS ASFLAGS OBJCOPYFLAGS READELFFLAGS LDFLAGS
global host_triplet runtests global host_triplet runtests
global env
if [string match "*/*" $name] { if [string match "*/*" $name] {
set file $name set file $name
@ -778,26 +791,28 @@ proc run_dump_test { name } {
# Objcopy, unlike the other two, won't send its output to stdout, # Objcopy, unlike the other two, won't send its output to stdout,
# so we have to run it specially. # so we have to run it specially.
set cmd "$binary $progopts $progopts1 $objfile > $dumpfile"
if { $program == "objcopy" } { if { $program == "objcopy" } {
set cmd "$binary $progopts $progopts1 $objfile $dumpfile" set cmd "$binary $progopts $progopts1 $objfile $dumpfile"
send_log "$cmd\n" }
catch "exec $cmd" comp_output
set comp_output [prune_warnings $comp_output] # Ensure consistent sorting of symbols
if ![string match "" $comp_output] then { if {[info exists env(LC_ALL)]} {
send_log "$comp_output\n" set old_lc_all $env(LC_ALL)
fail $testname }
return set env(LC_ALL) "C"
} send_log "$cmd\n"
catch "exec $cmd" comp_output
if {[info exists old_lc_all]} {
set env(LC_ALL) $old_lc_all
} else { } else {
set cmd "$binary $progopts $progopts1 $objfile > $dumpfile" unset env(LC_ALL)
send_log "$cmd\n" }
catch "exec $cmd" comp_output set comp_output [prune_warnings $comp_output]
set comp_output [prune_warnings $comp_output] if ![string match "" $comp_output] then {
if ![string match "" $comp_output] then { send_log "$comp_output\n"
send_log "$comp_output\n" fail $testname
fail $testname return
return
}
} }
verbose_eval {[file_contents $dumpfile]} 3 verbose_eval {[file_contents $dumpfile]} 3
@ -903,9 +918,9 @@ proc regexp_diff { file_1 file_2 } {
} }
} }
if { $diff_pass } { if { $diff_pass } {
break break
} elseif { $end_1 && $end_2 } { } elseif { $end_1 && $end_2 } {
break break
} elseif { $end_1 } { } elseif { $end_1 } {
send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n" send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n"