summaryrefslogtreecommitdiff
path: root/binutils/testsuite/binutils-all
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>1999-05-03 07:29:11 +0000
committerRichard Henderson <rth@redhat.com>1999-05-03 07:29:11 +0000
commit252b5132c753830d5fd56823373aed85f2a0db63 (patch)
tree1af963bfd8d3e55167b81def4207f175eaff3a56 /binutils/testsuite/binutils-all
downloadbinutils-gdb-252b5132c753830d5fd56823373aed85f2a0db63.tar.gz
19990502 sourceware importbinu_ss_19990502
Diffstat (limited to 'binutils/testsuite/binutils-all')
-rw-r--r--binutils/testsuite/binutils-all/ar.exp219
-rw-r--r--binutils/testsuite/binutils-all/bintest.s12
-rw-r--r--binutils/testsuite/binutils-all/hppa/addendbug.s23
-rw-r--r--binutils/testsuite/binutils-all/hppa/objdump.exp59
-rw-r--r--binutils/testsuite/binutils-all/nm.exp123
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp591
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp140
-rw-r--r--binutils/testsuite/binutils-all/readelf.exp217
-rw-r--r--binutils/testsuite/binutils-all/readelf.h16
-rw-r--r--binutils/testsuite/binutils-all/readelf.r4
-rw-r--r--binutils/testsuite/binutils-all/readelf.s13
-rw-r--r--binutils/testsuite/binutils-all/readelf.ss13
-rw-r--r--binutils/testsuite/binutils-all/readelf.wi78
-rw-r--r--binutils/testsuite/binutils-all/size.exp78
-rw-r--r--binutils/testsuite/binutils-all/testprog.c28
15 files changed, 1614 insertions, 0 deletions
diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp
new file mode 100644
index 00000000000..4b38c6b066e
--- /dev/null
+++ b/binutils/testsuite/binutils-all/ar.exp
@@ -0,0 +1,219 @@
+# Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# Written by Ian Lance Taylor <ian@cygnus.com>
+
+if ![is_remote host] {
+ if {[which $AR] == 0} then {
+ perror "$AR does not exist"
+ return
+ }
+}
+
+# send_user "Version [binutil_version $AR]"
+
+# Test long file name support
+
+proc long_filenames { } {
+ global AR
+ global host_triplet
+
+ set testname "ar long file names"
+
+ set n1 "abcdefghijklmnopqrstuvwxyz1"
+ set n2 "abcdefghijklmnopqrstuvwxyz2"
+ set file1 tmpdir/$n1
+ set file2 tmpdir/$n2
+
+ remote_file build delete $file1
+
+ # Some file systems truncate file names at 14 characters, which
+ # makes it impossible to run this test. Check for that now.
+ set status [catch "set f [open tmpdir/$n1 w]" errs]
+ if { $status != 0 } {
+ verbose -log "open tmpdir/$n1 returned $errs"
+ unsupported $testname
+ return
+ }
+ puts $f "first"
+ close $f
+
+
+ remote_file build delete $file2
+
+ set status [catch "set f [open tmpdir/$n2 w]" errs]
+ if { $status != 0 } {
+ verbose -log "open tmpdir/$n2 returned $errs"
+ unsupported $testname
+ return
+ }
+ puts $f "second"
+ close $f
+
+ if [is_remote host] {
+ set file1 [remote_download host $file1];
+ set file2 [remote_download host $file2];
+ set dest artest.a
+ } else {
+ set dest tmpdir/artest.a
+ }
+
+ remote_file host delete $dest;
+
+ set got [binutils_run $AR "rc $dest $file1 $file2"]
+ if [is_remote host] {
+ remote_upload host $file1 tmpdir/$n1
+ }
+
+ set f [open tmpdir/$n1 r]
+ gets $f string
+ close $f
+ if ![string match "first" $string] {
+ verbose -log "reading tmpdir/$n1 returned $string"
+ unsupported $testname
+ return
+ }
+
+ remote_file host delete $dest;
+ set got [binutils_run $AR "rc $dest $file1 $file2"]
+
+ if ![string match "" $got] {
+ fail $testname
+ return
+ }
+
+ remote_file build delete tmpdir/$n1
+ remote_file build delete tmpdir/$n2
+
+ set got [binutils_run $AR "t $dest"]
+ regsub "\[\r\n \t\]*$" "$got" "" got;
+ if ![string match "$n1*$n2" $got] {
+ fail $testname
+ return
+ }
+
+ if [is_remote host] {
+ remote_file host delete $file1;
+ remote_file host delete $file2;
+ }
+
+ verbose -log "$AR x $dest"
+ set exec_output [binutils_run $AR "x $dest"]
+ set exec_output [prune_warnings $exec_output]
+ if ![string match "" $exec_output] {
+ verbose -log $exec_output
+ fail $testname
+ return
+ }
+
+ if [is_remote host] {
+ remote_upload host $n1 tmpdir/$n1;
+ remote_upload host $n2 tmpdir/$n2;
+ set file1 tmpdir/$n1
+ set file2 tmpdir/$n2
+ } else {
+ set file1 $n1
+ set file2 $n2
+ }
+
+ if ![file exists $file1] {
+ verbose -log "$file1 does not exist"
+ fail $testname
+ return
+ }
+ if ![file exists $file2] {
+ verbose -log "$file2 does not exist"
+ fail $testname
+ return
+ }
+
+ set f [open $file1 r]
+ if { [gets $f line] == -1 || $line != "first" } {
+ verbose -log "$file1 contents:"
+ verbose -log "$line"
+ close $f
+ fail $testname
+ return
+ }
+ close $f
+
+ set f [open $file2 r]
+ if { [gets $f line] == -1 || $line != "second" } {
+ verbose -log "$file2 contents:"
+ verbose -log "$line"
+ close $f
+ fail $testname
+ return
+ }
+ close $f
+
+ pass $testname
+}
+
+# Test building the symbol table.
+
+proc symbol_table { } {
+ global AR
+ global AS
+ global NM
+ global srcdir
+ global subdir
+
+ set testname "ar symbol table"
+
+ if ![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o] {
+ unresolved $testname
+ return
+ }
+
+ if [is_remote host] {
+ set archive artest.a
+ set objfile [remote_download host tmpdir/bintest.o]
+ remote_file host delete $archive
+ } else {
+ set archive tmpdir/artest.a
+ set objfile tmpdir/bintest.o
+ }
+
+ remote_file build delete tmpdir/artest.a
+
+ set got [binutils_run $AR "rc $archive ${objfile}"]
+ if ![string match "" $got] {
+ fail $testname
+ return
+ }
+
+ set got [binutils_run $NM "--print-armap $archive"]
+ if { ![string match "*text_symbol in bintest.o*" $got] \
+ || ![string match "*data_symbol in bintest.o*" $got] \
+ || ![string match "*common_symbol in bintest.o*" $got] \
+ || [string match "*static_text_symbol in bintest.o*" $got] \
+ || [string match "*static_data_symbol in bintest.o*" $got] \
+ || [string match "*external_symbol in bintest.o*" $got] } {
+ fail $testname
+ return
+ }
+
+ pass $testname
+}
+
+# Run the tests.
+
+long_filenames
+symbol_table
diff --git a/binutils/testsuite/binutils-all/bintest.s b/binutils/testsuite/binutils-all/bintest.s
new file mode 100644
index 00000000000..9e006502219
--- /dev/null
+++ b/binutils/testsuite/binutils-all/bintest.s
@@ -0,0 +1,12 @@
+ .globl text_symbol
+ .text
+text_symbol:
+static_text_symbol:
+ .long 1
+ .long external_symbol
+ .globl data_symbol
+ .data
+data_symbol:
+static_data_symbol:
+ .long 2
+ .comm common_symbol,4
diff --git a/binutils/testsuite/binutils-all/hppa/addendbug.s b/binutils/testsuite/binutils-all/hppa/addendbug.s
new file mode 100644
index 00000000000..659306f0741
--- /dev/null
+++ b/binutils/testsuite/binutils-all/hppa/addendbug.s
@@ -0,0 +1,23 @@
+ .SPACE $PRIVATE$
+ .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
+ .SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
+ .SPACE $TEXT$
+ .SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
+ .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
+ .IMPORT $global$,DATA
+ .IMPORT $$dyncall,MILLICODE
+; gcc_compiled.:
+ .SPACE $TEXT$
+ .SUBSPA $CODE$
+
+ .align 4
+ .EXPORT initialize_char_syntax,CODE
+ .EXPORT initialize_char_syntax,ENTRY,PRIV_LEV=3,RTNVAL=GR
+initialize_char_syntax
+ .PROC
+ .CALLINFO FRAME=64,NO_CALLS,SAVE_SP,ENTRY_GR=3
+ .ENTRY
+ addil L'is_idchar-$global$-32,%r27
+ .EXIT
+ .PROCEND
+is_idchar .comm 256
diff --git a/binutils/testsuite/binutils-all/hppa/objdump.exp b/binutils/testsuite/binutils-all/hppa/objdump.exp
new file mode 100644
index 00000000000..a46b289769a
--- /dev/null
+++ b/binutils/testsuite/binutils-all/hppa/objdump.exp
@@ -0,0 +1,59 @@
+# Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# This file was written by Rob Savoye <rob@cygnus.com>
+# and rewritten by Ian Lance Taylor <ian@cygnus.com>
+
+if ![istarget hppa*-*-*] then {
+ return
+}
+
+if {[which $OBJDUMP] == 0} then {
+ perror "$OBJDUMP does not exist"
+ return
+}
+
+send_user "Version [binutil_version $OBJDUMP]"
+
+if {![binutils_assemble $srcdir/$subdir/addendbug.s tmpdir/addendbug.o]} then {
+ return
+}
+
+if [is_remote host] {
+ set objfile [remote_download host tmpdir/addendbug.o]
+} else {
+ set objfile tmpdir/addendbug.o
+}
+
+# Make sure the SOM BFD code sign extends constants in R_DATA_OVERRIDE fixups.
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $objfile"]
+
+if [istarget hppa*-*-*elf*] then {
+ set want "00000000 R_PARISC_DPREL21L\[ \]+is_idchar\\+0xffffffe0.*"
+} else {
+ set want "00000000 R_DP_RELATIVE\[ \]+is_idchar\\+0xffffffe0.*"
+}
+
+
+if [regexp $want $got] then {
+ pass "addendbug test"
+} else {
+ fail "addendbug test"
+}
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
new file mode 100644
index 00000000000..76c7c5f38c9
--- /dev/null
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -0,0 +1,123 @@
+# Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# This file was written by Rob Savoye <rob@cygnus.com>
+# and rewritten by Ian Lance Taylor <ian@cygnus.com>
+
+if ![is_remote host] {
+ if {[which $NM] == 0} then {
+ perror "$NM does not exist"
+ return
+ }
+}
+
+send_user "Version [binutil_version $NM]"
+
+
+if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
+ return
+}
+
+if [is_remote host] {
+ set tempfile [remote_download host tmpdir/bintest.o]
+} else {
+ set tempfile tmpdir/bintest.o
+}
+
+# Test nm with no arguments.
+
+# This test does not work correctly on ECOFF targets, because ECOFF
+# stores most symbols twice, which messes up the nm output.
+setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
+setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
+setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
+
+# This test does not work correctly on XCOFF targets, because XCOFF
+# does not enter static symbols in the symbol table.
+setup_xfail "*-*-aix*"
+
+set got [binutils_run $NM "$NMFLAGS $tempfile"]
+
+if [info exists vars] then { unset vars }
+while {[regexp "(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} {
+ set vars($symbol) $type
+ set got $rest
+}
+
+if {![info exists vars(text_symbol)] \
+ || $vars(text_symbol) != "T" \
+ || ![info exists vars(data_symbol)] \
+ || $vars(data_symbol) != "D" \
+ || ![info exists vars(common_symbol)] \
+ || $vars(common_symbol) != "C" \
+ || ![info exists vars(external_symbol)] \
+ || $vars(external_symbol) != "U" \
+ || ![info exists vars(static_text_symbol)] \
+ || $vars(static_text_symbol) != "t" \
+ || ![info exists vars(static_data_symbol)] \
+ || $vars(static_data_symbol) != "d"} {
+ fail "nm (no arguments)"
+} else {
+ pass "nm (no arguments)"
+}
+
+# Test nm -g
+
+set got [binutils_run $NM "$NMFLAGS -g $tempfile"]
+
+if [info exists vars] then { unset vars }
+while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} {
+ set vars($symbol) 1
+ set got $rest
+}
+
+if {![info exists vars(text_symbol)] \
+ || ![info exists vars(data_symbol)] \
+ || ![info exists vars(common_symbol)] \
+ || ![info exists vars(external_symbol)] \
+ || [info exists vars(static_text_symbol)] \
+ || [info exists vars(static_data_symbol)]} {
+ fail "nm -g"
+} else {
+ pass "nm -g"
+}
+
+# Test nm -P
+
+# This test does not work correctly on ECOFF targets, because ECOFF
+# stores most symbols twice, which messes up the nm output.
+setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
+setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
+setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
+
+# This test does not work correctly on XCOFF targets, because XCOFF
+# does not enter static symbols in the symbol table.
+setup_xfail "*-*-aix*"
+
+set got [binutils_run $NM "$NMFLAGS -P $tempfile"]
+
+set want "common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*"
+
+if [regexp $want $got] then {
+ pass "nm -P"
+} else {
+ fail "nm -P"
+}
+
+# There are certainly other tests that could be run.
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
new file mode 100644
index 00000000000..78972f1c0c1
--- /dev/null
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -0,0 +1,591 @@
+# Copyright (C) 1994, 95, 96, 97, 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# Written by Ian Lance Taylor <ian@cygnus.com>
+
+if ![is_remote host] {
+ if {[which $OBJCOPY] == 0} then {
+ perror "$OBJCOPY does not exist"
+ return
+ }
+}
+
+send_user "Version [binutil_version $OBJCOPY]"
+
+if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
+ perror "unresolved 1"
+ unresolved "objcopy (simple copy)"
+ return
+}
+
+if ![is_remote host] {
+ set tempfile tmpdir/bintest.o;
+ set copyfile tmpdir/copy;
+} else {
+ set tempfile [remote_download host tmpdir/bintest.o]
+ set copyfile copy
+}
+
+# Test that objcopy does not modify a file when copying it.
+
+set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile ${copyfile}.o"]
+
+if ![string match "" $got] then {
+ fail "objcopy (simple copy)"
+} else {
+ send_log "cmp $tempfile ${copyfile}.o\n"
+ verbose "cmp $tempfile ${copyfile}.o"
+ if [is_remote host] {
+ set src1 tmpdir/bintest.o
+ set src2 tmpdir/copy.o
+ remote_upload host $tempfile $src1;
+ remote_upload host ${copyfile}.o $src2;
+ } else {
+ set src1 ${tempfile}
+ set src2 ${copyfile}.o
+ }
+ set status [remote_exec build cmp "${src1} ${src2}"];
+ set exec_output [lindex $status 1];
+ set exec_output [prune_warnings $exec_output]
+
+ # On some systems the result of objcopy will not be identical.
+ # Usually this is just because gas isn't using bfd to write the files
+ # in the first place, and may order things a little differently.
+ # Those systems should use setup_xfail here.
+
+ setup_xfail "sh-*-coff" "sh-*-hms"
+ setup_xfail "m68*-*-hpux*" "m68*-*-sunos*" "m68*-*-coff" "m68*-*-vxworks*"
+ setup_xfail "m68*-ericsson-ose" "m68k*-motorola-sysv*"
+ setup_xfail "i*86-*-linuxaout*" "i*86-*-aout*"
+ setup_xfail "i*86-*-sysv3" "i*86-*-isc*" "i*86-*-sco*" "i*86-*-coff"
+ setup_xfail "i*86-*-aix*" "i*86-*-go32*"
+ setup_xfail "a29k-*-udi" "a29k-*-coff" "a29k-*-vxworks*"
+ setup_xfail "i960-*-coff"
+ setup_xfail "h8300-*-hms" "h8300-*-coff"
+ setup_xfail "h8500-*-hms" "h8500-*-coff"
+ setup_xfail "hppa*-*-*"
+ clear_xfail "hppa*-*-*elf*"
+ setup_xfail "m88*-*-coff" "m88*-motorola-sysv*"
+ setup_xfail "z8*-*-coff"
+
+ if [string match "" $exec_output] then {
+ pass "objcopy (simple copy)"
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+
+ # On OSF/1, this succeeds with gas and fails with /bin/as.
+ setup_xfail "alpha*-*-osf*"
+
+ # This fails for COFF i960-vxworks targets.
+ setup_xfail "i960-*-vxworks*"
+
+ fail "objcopy (simple copy)"
+ }
+}
+
+# Test generating S records.
+
+# We make the srec filename 8.3 compatible. Note that the header string
+# matched against depends on the name of the file. Ugh.
+
+if [is_remote host] {
+ set srecfile copy.sre
+ set header_string S00B0000636F70792E737265C1
+} else {
+ set srecfile ${copyfile}.srec
+ set header_string S0130000746D706469722F636F70792E7372656397
+}
+
+set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${srecfile}"]
+
+if ![string match "" $got] then {
+ fail "objcopy -O srec"
+} else {
+ if [is_remote host] {
+ remote_upload host ${srecfile} tmpdir/copy.srec;
+ set srecfile tmpdir/copy.srec;
+ }
+ set file [open ${srecfile} r]
+
+ # The first S record is fixed by the file name we are using.
+ gets $file line
+ send_log "$line\n"
+ verbose $line
+ if ![regexp "$header_string.*" $line] {
+ send_log "bad header\n"
+ fail "objcopy -O srec"
+ } else {
+ while {[gets $file line] != -1 \
+ && [regexp "^S\[123\]\[0-9a-fA-F\]+\[\r\n\]*$" $line]} {
+ send_log "$line\n"
+ verbose $line
+ set line "**EOF**"
+ }
+ send_log "$line\n"
+ verbose $line
+ if ![regexp "^S\[789\]\[0-9a-fA-F\]+\[\r\n\]*$" $line] then {
+ send_log "bad trailer\n"
+ fail "objcopy -O srec"
+ } else {
+ if {[gets $file line] != -1} then {
+ send_log "garbage at end\n"
+ send_log "$line\n"
+ verbose $line
+ fail "objcopy -O srec"
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+ if ![regexp "file format srec" $got] then {
+ send_log "objdump failed\n"
+ fail "objcopy -O srec"
+ } else {
+ pass "objcopy -O srec"
+ }
+ }
+ }
+ }
+
+ close $file
+}
+
+# Test setting and adjusting the start address. We only test this
+# while generating S records, because we may not be able to set the
+# start address for other object file formats, and the S record case
+# is the only useful one anyhow.
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $tempfile"]
+if ![regexp "start address (\[0-9a-fA-FxX\]+)" $got all origstart] then {
+ perror "objdump can not recognize bintest.o"
+ set origstart ""
+} else {
+ set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${copyfile}.srec --set-start 0x7654"]
+ if ![string match "" $got] then {
+ fail "objcopy --set-start"
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+ if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
+ fail "objcopy --set-start"
+ } else {
+ if {$srecstart != 0x7654} then {
+ send_log "$srecstart != 0x7654\n"
+ fail "objcopy --set-start"
+ } else {
+ pass "objcopy --set-start"
+ }
+ }
+ }
+
+ set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${copyfile}.srec --adjust-start 0x123"]
+ if ![string match "" $got] then {
+ fail "objcopy --adjust-start"
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+ if ![regexp "file format srec.*start address (\[0-9a-fA-FxX\]+)" $got all srecstart] then {
+ fail "objcopy --adjust-start"
+ } else {
+ if {$srecstart != $origstart + 0x123} then {
+ send_log "$srecstart != $origstart + 0x123\n"
+ fail "objcopy --adjust-start"
+ } else {
+ pass "objcopy --adjust-start"
+ }
+ }
+ }
+}
+
+# Test adjusting the overall VMA, and adjusting the VMA of a
+# particular section. We again only test this when generating S
+# records.
+
+set low ""
+set lowname ""
+
+set headers [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $tempfile"]
+
+set headers_regexp "\[ 0-9\]+(\[^ \]+)\[ \]*(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)\[ \]+\[0-9a-fA-F\]+\[ \]+2\[*\]\[*\]\[0-9\]+(.*)"
+
+set got $headers
+while {[regexp $headers_regexp $got all name size vma rest]} {
+ set vma 0x$vma
+ set size 0x$size
+ if {$size != 0} {
+ if {$low == "" || $vma < $low} {
+ set low $vma
+ set lowname $name
+ }
+ }
+ set got $rest
+}
+
+if {$low == "" || $origstart == ""} then {
+ perror "objdump can not recognize bintest.o"
+} else {
+ set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${copyfile}.srec --adjust-vma 0x123"]
+ if ![string match "" $got] then {
+ fail "objcopy --adjust-vma"
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -fh ${copyfile}.srec"]
+ set want "file format srec.*start address\[ \]*(\[0-9a-fA-FxX\]+).*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
+ if ![regexp $want $got all start vma] then {
+ fail "objcopy --adjust-vma"
+ } else {
+ set vma 0x$vma
+ if {$vma != $low + 0x123} then {
+ send_log "$vma != $low + 0x123\n"
+ fail "objcopy --adjust-vma"
+ } else {
+ if {$start != $origstart + 0x123} then {
+ send_log "$start != $origstart + 0x123\n"
+ fail "objcopy --adjust-vma"
+ } else {
+ pass "objcopy --adjust-vma"
+ }
+ }
+ }
+ }
+
+ set arg ""
+ set got $headers
+ while {[regexp $headers_regexp $got all name size vma rest]} {
+ set vma 0x$vma
+ if {$vma == $low} then {
+ set arg "$arg --adjust-section-vma $name+4"
+ }
+ set got $rest
+ }
+
+ set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${copyfile}.srec $arg"]
+ if ![string match "" $got] then {
+ fail "objcopy --adjust-section-vma +"
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
+ set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
+ if ![regexp $want $got all vma] then {
+ fail "objcopy --adjust-section-vma +"
+ } else {
+ set vma 0x$vma
+ if {$vma != $low + 4} then {
+ send_log "$vma != $low + 4\n"
+ fail "objcopy --adjust-section-vma +"
+ } else {
+ pass "objcopy --adjust-section-vma +"
+ }
+ }
+ }
+
+ regsub -all "\\+4" $arg "=[expr $low + 4]" argeq
+ set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS -O srec $tempfile ${copyfile}.srec $argeq"]
+ if ![string match "" $got] then {
+ fail "objcopy --adjust-section-vma ="
+ } else {
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h ${copyfile}.srec"]
+ set want "file format srec.*sec1\[ \]+\[0-9a-fA-F\]+\[ \]+(\[0-9a-fA-F\]+)"
+ if ![regexp $want $got all vma] then {
+ fail "objcopy --adjust-section-vma ="
+ } else {
+ set vma 0x$vma
+ if {$vma != $low + 4} then {
+ send_log "$vma != $low + 4\n"
+ fail "objcopy --adjust-section-vma ="
+ } else {
+ pass "objcopy --adjust-section-vma ="
+ }
+ }
+ }
+}
+
+# Test stripping an object.
+
+proc strip_test { } {
+ global CC
+ global STRIP
+ global STRIPFLAGS
+ global NM
+ global NMFLAGS
+ global srcdir
+ global subdir
+
+ set test "strip"
+
+ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
+ untested $test
+ return
+ }
+
+ if [is_remote host] {
+ set objfile [remote_download host tmpdir/testprog.o];
+ } else {
+ set objfile tmpdir/testprog.o
+ }
+
+ set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
+ if ![string match "" $exec_output] {
+ fail $test
+ return
+ }
+
+ set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
+ if ![string match "*: no symbols*" $exec_output] {
+ fail $test
+ return
+ }
+
+ pass $test
+}
+
+strip_test
+
+# Test stripping an object file with saving a symbol
+
+proc strip_test_with_saving_a_symbol { } {
+ global CC
+ global STRIP
+ global STRIPFLAGS
+ global NM
+ global NMFLAGS
+ global srcdir
+ global subdir
+
+ set test "strip with saving a symbol"
+
+ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
+ untested $test
+ return
+ }
+
+ if [is_remote host] {
+ set objfile [remote_download host tmpdir/testprog.o];
+ } else {
+ set objfile tmpdir/testprog.o
+ }
+
+ set exec_output [binutils_run $STRIP "$STRIPFLAGS -K main -K _main $objfile"]
+ if ![string match "" $exec_output] {
+ fail $test
+ return
+ }
+
+ set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
+ if {![regexp {^([0-9a-fA-F]+)?[ ]+T main} $exec_output] \
+ && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
+ fail $test
+ return
+ }
+
+ pass $test
+}
+
+strip_test_with_saving_a_symbol
+
+# Build a final executable.
+
+proc copy_setup { } {
+ global srcdir
+ global subdir
+
+ set res [build_wrapper testglue.o];
+ set flags { debug };
+
+ if { $res != "" } {
+ lappend flags "additional_flags=[lindex $res 1]";
+ set add_libs "testglue.o";
+ } else {
+ set add_libs "";
+ }
+
+ if { [target_compile "$srcdir/$subdir/testprog.c $add_libs" tmpdir/testprog executable $flags] != "" } {
+ return 2
+ }
+
+ set result [remote_load target tmpdir/testprog];
+ set status [lindex $result 0];
+
+ if { $status != "pass" } {
+ perror "unresolved setup, status = $status"
+ return 3
+ }
+
+ return 0
+}
+
+# Test copying an executable.
+
+proc copy_executable { prog flags test1 test2 } {
+
+ if [is_remote host] {
+ set testfile [remote_download host tmpdir/testprog];
+ set testcopy copyprog
+ } else {
+ set testfile tmpdir/testprog
+ set testcopy tmpdir/copyprog
+ }
+ remote_file host delete $testcopy;
+
+ set exec_output [binutils_run $prog "$flags $testfile $testcopy"]
+
+ if ![string match "" $exec_output] {
+ fail $test1
+ fail $test2
+ return
+ }
+
+ if [is_remote host] {
+ remote_upload host $testcopy tmpdir/copyprog
+ }
+
+ set status [remote_exec build "cmp" "tmpdir/testprog tmpdir/copyprog"]
+ set exec_output [lindex $status 1];
+
+ if [string match "" $exec_output] then {
+ pass $test1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+
+ # This will fail for many reasons. For example, it will most
+ # likely fail if a non-GNU linker is used. Therefore, we do
+ # not insist that it pass. If you are using an assembler and
+ # linker based on the same BFD as objcopy, it is worth
+ # investigating to see why this failure occurs. If we are
+ # cross compiling, we assume that a GNU linker is being used,
+ # and expect it to succeed.
+ if {[isnative]} then {
+ setup_xfail "*-*-*"
+ }
+
+ # This also fails for mips*-*-elf targets. See elf32-mips.c
+ # mips_elf_sym_is_global.
+ setup_xfail "mips*-*-elf"
+
+ fail $test1
+ }
+
+ set output [remote_load target tmpdir/copyprog]
+ set status [lindex $output 0];
+ if { $status != "pass" } {
+ fail $test2
+ } else {
+ pass $test2
+ }
+}
+
+# Test stripping an executable
+
+proc strip_executable { prog flags test } {
+ global NM
+ global NMFLAGS
+
+ remote_download build tmpdir/copyprog tmpdir/striprog
+ if [is_remote host] {
+ set copyfile [remote_download host tmpdir/striprog];
+ } else {
+ set copyfile tmpdir/striprog
+ }
+
+ set exec_output [binutils_run $prog "$flags ${copyfile}"]
+ if ![string match "" $exec_output] {
+ fail $test
+ return
+ }
+
+ if [is_remote host] {
+ remote_upload host ${copyfile} tmpdir/striprog;
+ }
+
+ set result [remote_load target tmpdir/striprog]
+ set status [lindex $result 0];
+ if { $status != "pass" } {
+ fail $test
+ return
+ }
+
+ set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
+ if ![string match "*: no symbols*" $exec_output] {
+ fail $test
+ return
+ }
+ pass $test
+}
+
+# Test stripping an executable with saving a symbol
+
+proc strip_executable_with_saving_a_symbol { prog flags test } {
+ global NM
+ global NMFLAGS
+
+ remote_download build tmpdir/copyprog tmpdir/striprog
+ if [is_remote host] {
+ set copyfile [remote_download host tmpdir/striprog];
+ } else {
+ set copyfile tmpdir/striprog
+ }
+
+ set exec_output [binutils_run $prog "$flags ${copyfile}"]
+ if ![string match "" $exec_output] {
+ fail $test
+ return
+ }
+
+ if [is_remote host] {
+ remote_upload host ${copyfile} tmpdir/striprog;
+ }
+
+ set result [remote_load target tmpdir/striprog]
+ set status [lindex $result 0];
+ if { $status != "pass" } {
+ fail $test
+ return
+ }
+
+ set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
+ if {![regexp {^[0-9a-fA-F]+ T main} $exec_output] \
+ && ![regexp {^[0-9a-fA-F]+ T _main} $exec_output]} {
+ fail $test
+ return
+ }
+ pass $test
+}
+
+set test1 "simple objcopy of executable"
+set test2 "run objcopy of executable"
+set test3 "run stripped executable"
+set test4 "run stripped executable with saving a symbol"
+
+switch [copy_setup] {
+ "1" {
+ # do nothing
+ }
+ "2" {
+ untested $test1
+ untested $test2
+ untested $test3
+ untested $test4
+ }
+ "3" {
+ unresolved $test1
+ unresolved $test2
+ unresolved $test3
+ unresolved $test4
+ }
+ "0" {
+ copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2"
+ strip_executable "$STRIP" "$STRIPFLAGS" "$test3"
+ strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test4"
+ }
+}
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
new file mode 100644
index 00000000000..7c50f02fb6d
--- /dev/null
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -0,0 +1,140 @@
+# Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# This file was written by Rob Savoye <rob@cygnus.com>
+# and rewritten by Ian Lance Taylor <ian@cygnus.com>
+
+if ![is_remote host] {
+ if {[which $OBJDUMP] == 0} then {
+ perror "$OBJDUMP does not exist"
+ return
+ }
+}
+
+send_user "Version [binutil_version $OBJDUMP]"
+
+# Simple test of objdump -i
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
+
+set cpus_expected "(a29k|alliant|alpha|arc|arm|convex|d10v|d30v|h8|hppa|i386|i860|i960|m32r|m68k|m88k|mips|mn10200|mn10300|ns32k|powerpc|pyramid|romp|rs6000|sh|sparc|tahoe|v850|vax|we32k|z8k|z8001|z8002)"
+
+# Make sure the target CPU shows up in the list.
+if ![regexp $cpus_expected $target_cpu] {
+ regsub "^\[(\]" "$cpus_expected" "(${target_cpu}|" cpus_expected;
+}
+
+set want "BFD header file version.*srec.*header .* endian.*, data .* endian.*$cpus_expected"
+
+if [regexp $want $got] then {
+ pass "objdump -i"
+} else {
+ fail "objdump -i"
+}
+
+# The remaining tests require a test file.
+
+
+if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
+ return
+}
+if [is_remote host] {
+ set testfile [remote_download host tmpdir/bintest.o]
+} else {
+ set testfile tmpdir/bintest.o
+}
+
+# Test objdump -f
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"]
+
+set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_expected}.*HAS_RELOC.*HAS_SYMS"
+
+if ![regexp $want $got] then {
+ fail "objdump -f"
+} else {
+ pass "objdump -f"
+}
+
+# Test objdump -h
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"]
+
+set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)"
+
+if ![regexp $want $got all text_name text_size data_name data_size] then {
+ fail "objdump -h"
+} else {
+ verbose "text name is $text_name size is $text_size"
+ verbose "data name is $data_name size is $data_size"
+ if {[expr "0x$text_size"] < 8 || [expr "0x$data_size"] < 4} then {
+ send_log "sizes too small\n"
+ fail "objdump -h"
+ } else {
+ pass "objdump -h"
+ }
+}
+
+# Test objdump -t
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"]
+
+if [info exists vars] then { unset vars }
+while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
+ set vars($symbol) 1
+ set got $rest
+}
+
+if {![info exists vars(text_symbol)] \
+ || ![info exists vars(data_symbol)] \
+ || ![info exists vars(common_symbol)] \
+ || ![info exists vars(external_symbol)]} then {
+ fail "objdump -t"
+} else {
+ pass "objdump -t"
+}
+
+# Test objdump -r
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"]
+
+set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol"
+
+if [regexp $want $got] then {
+ pass "objdump -r"
+} else {
+ fail "objdump -r"
+}
+
+# Test objdump -s
+
+set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"]
+
+set want "$testfile:\[ \]*file format.*Contents.*(text|TEXT|\\\$CODE\\\$)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000001|01000000).*Contents.*(data|DATA)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000002|02000000)"
+
+if [regexp $want $got] then {
+ pass "objdump -s"
+} else {
+ fail "objdump -s"
+}
+
+# Options which are not tested: -a -d -D -R -T -x -l --stabs
+# I don't see any generic way to test any of these other than -a.
+# Tests could be written for specific targets, and that should be done
+# if specific problems are found.
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
new file mode 100644
index 00000000000..b2f744c7e15
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -0,0 +1,217 @@
+# Copyright (C) 1999 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# Written by Nick Clifto <nickc@cygnus.com>
+# Based on scripts written by Ian Lance Taylor <ian@cygnus.com>
+# and Ken Raeburn <raeburn@cygnus.com>.
+
+# First some helpful procedures, then the tests themselves
+
+# Return the contents of the filename given
+proc file_contents { filename } {
+ set file [open $filename r]
+ set contents [read $file]
+ close $file
+ return $contents
+}
+
+# regexp_diff, based on simple_diff taken from ld test suite
+# compares two files line-by-line
+# file1 contains strings, file2 contains regexps and #-comments
+# blank lines are ignored in either file
+# returns non-zero if differences exist
+#
+proc regexp_diff { file_1 file_2 } {
+
+ set eof -1
+ set end_1 0
+ set end_2 0
+ set differences 0
+ set diff_pass 0
+
+ if [file exists $file_1] then {
+ set file_a [open $file_1 r]
+ } else {
+ warning "$file_1 doesn't exist"
+ return 1
+ }
+
+ if [file exists $file_2] then {
+ set file_b [open $file_2 r]
+ } else {
+ fail "$file_2 doesn't exist"
+ close $file_a
+ return 1
+ }
+
+ verbose " Regexp-diff'ing: $file_1 $file_2" 2
+
+ while { 1 } {
+ set line_a ""
+ set line_b ""
+ while { [string length $line_a] == 0 } {
+ if { [gets $file_a line_a] == $eof } {
+ set end_1 1
+ break
+ }
+ }
+ while { [string length $line_b] == 0 || [string match "#*" $line_b] } {
+ if [ string match "#pass" $line_b ] {
+ set end_2 1
+ set diff_pass 1
+ break
+ }
+ if { [gets $file_b line_b] == $eof } {
+ set end_2 1
+ break
+ }
+ }
+
+ if { $diff_pass } {
+ break
+ } elseif { $end_1 && $end_2 } {
+ break
+ } elseif { $end_1 } {
+ send_log "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1\n"
+ verbose "extra regexps in $file_2 starting with \"^$line_b$\"\nEOF from $file_1" 3
+ set differences 1
+ break
+ } elseif { $end_2 } {
+ send_log "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n"
+ verbose "extra lines in $file_1 starting with \"^$line_a$\"\nEOF from $file_2\n" 3
+ set differences 1
+ break
+ } else {
+ verbose "regexp \"^$line_b$\"\nline \"$line_a\"" 3
+ if ![regexp "^$line_b$" "$line_a"] {
+ send_log "regexp_diff match failure\n"
+ send_log "regexp \"^$line_b$\"\nline \"$line_a\"\n"
+ set differences 1
+ break
+ }
+ }
+ }
+
+ if { $differences == 0 && !$diff_pass && [eof $file_a] != [eof $file_b] } {
+ send_log "$file_1 and $file_2 are different lengths\n"
+ verbose "$file_1 and $file_2 are different lengths" 3
+ set differences 1
+ }
+
+ close $file_a
+ close $file_b
+
+ return $differences
+}
+
+# Run an individual readelf test.
+# Basically readelf is run on the binary_file with the given options.
+# Readelf's output is captured and then compared against the contents
+# of the regexp_file.
+
+proc readelf_test { options binary_file regexp_file xfails } {
+
+ global READELF
+ global READELFFLAGS
+ global srcdir
+ global subdir
+
+ send_log "exec $READELF $READELFFLAGS $options $binary_file > readelf.out"
+ catch "exec $READELF $READELFFLAGS $options $binary_file > readelf.out" got
+
+ if { [llength $xfails] != 0 } then {
+ setup_xfail $xfails
+ }
+
+ if ![string match "" $got] then {
+ send_log $got
+ fail "readelf $options"
+ return
+ }
+
+ if { [regexp_diff readelf.out $srcdir/$subdir/$regexp_file] } then {
+ fail "readelf $options"
+ verbose "output is \n[file_contents readelf.out]" 2
+ return
+ }
+
+ pass "readelf $options"
+}
+
+
+
+# Only ELF based toolchains need readelf.
+# For now be paranoid and assume that if ELF is not mentioned
+# in the target string, then the target is not an ELF based port.
+
+if ![istarget "*-*elf"] then {
+ verbose "$READELF is only intenteded for ELF targets" 2
+ return
+}
+
+if ![is_remote host] {
+ if {[which $READELF] == 0} then {
+ perror "$READELF does not exist"
+ return
+ }
+}
+
+send_user "Version [binutil_version $READELF]"
+
+# Assemle the test file.
+if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
+ perror "unresolved 1"
+ unresolved "readelf - failed to assemble"
+ return
+}
+
+if ![is_remote host] {
+ set tempfile tmpdir/bintest.o;
+} else {
+ set tempfile [remote_download host tmpdir/bintest.o]
+}
+
+# Run the tests
+readelf_test -h $tempfile readelf.h {}
+
+# The v850 fails the next two tests because it creates two special
+# sections of its own: .call_table_data and .call_table_text
+# The regexp scripts are not expecting these sections...
+
+readelf_test -S $tempfile readelf.s {v850*-*-*}
+readelf_test -s $tempfile readelf.ss {v850*-*-*}
+readelf_test -r $tempfile readelf.r {}
+
+
+# Compile the second test file.
+if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
+ untested "readelf -w"
+ return
+}
+
+if [is_remote host] {
+ set tempfile [remote_download host tmpdir/testprog.o];
+} else {
+ set tempfile tmpdir/testprog.o
+}
+
+# The xfail targets here do not default to DWARF2 format debug information
+# The symptom is that the output of 'readelf -wi' is empty.
+
+readelf_test -wi $tempfile readelf.wi {v850*-*-*}
diff --git a/binutils/testsuite/binutils-all/readelf.h b/binutils/testsuite/binutils-all/readelf.h
new file mode 100644
index 00000000000..555afe9a7a2
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.h
@@ -0,0 +1,16 @@
+ELF Header:
+ Magic: 7f 45 4c 46 0[12] 0[12] 01 00 00 00 00 00 00 00 00 00
+ Type: REL \(Relocatable file\)
+ Machine: .*
+ Version: 0x1
+ Data: ELFDATA.* endian\)
+ Entry point address: 0x0
+ Start of program headers: 0 \(bytes into file\)
+ Start of section headers: .* \(bytes into file\)
+ Flags: .*
+ Size of this header: .* \(bytes\)
+ Size of program headers: 0 \(bytes\)
+ Number of program headers: 0
+ Size of section headers: .* \(bytes\)
+ Number of section headers: .*
+ Section header string table index: .*
diff --git a/binutils/testsuite/binutils-all/readelf.r b/binutils/testsuite/binutils-all/readelf.r
new file mode 100644
index 00000000000..4bea721451a
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.r
@@ -0,0 +1,4 @@
+
+Relocation section '.rel.*text' at offset 0x.* contains 1 entries:
+ Offset Info Type Symbol's Value Symbol's Name.*
+ 00000004 00.* R_.* 00000000 external_symbol.*
diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s
new file mode 100644
index 00000000000..58b1245e9a3
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.s
@@ -0,0 +1,13 @@
+There are .* section headers, starting at offset .*:
+
+Section Headers:
+ \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al
+ \[ 0\] NULL 00000000 000000 000000 00 0 0 0
+ \[ 1\] .text PROGBITS 00000000 000034 000008 00 AX 0 0 .
+ \[ 2\] .rel.+text +REL. +0+ 0+.* 00000. 0. . 1 4
+ \[ 3\] .data PROGBITS 00000000 00003c 000004 00 WA 0 0 .
+ \[ 4\] .bss NOBITS 00000000 000040 000000 00 WA 0 0 .
+ \[ 5\] .shstrtab STRTAB 00000000 000040 0000.* 00 0 0 .
+ \[ 6\] .symtab SYMTAB 00000000 0+.* 0+.* 10 7 6 4
+ \[ 7\] .strtab STRTAB 00000000 0+.* 0+.* 00 0 0 1
+
diff --git a/binutils/testsuite/binutils-all/readelf.ss b/binutils/testsuite/binutils-all/readelf.ss
new file mode 100644
index 00000000000..3760b38427d
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.ss
@@ -0,0 +1,13 @@
+
+Symbol table '.symtab' contains .* entries:
+ Num: Value Size Type Bind Ot Ndx Name
+ 0: 0 0 NOTYPE LOCAL 0 UND
+ 1: 0 0 SECTION LOCAL 0 1
+ 2: 0 0 SECTION LOCAL 0 3
+ 3: 0 0 SECTION LOCAL 0 4
+ 4: 0 0 NOTYPE LOCAL 0 1 static_text_symbol
+ 5: 0 0 NOTYPE LOCAL 0 3 static_data_symbol
+ .: 0 0 NOTYPE GLOBAL 0 1 text_symbol
+ .: 0 0 NOTYPE GLOBAL 0 UND external_symbol
+ .*: 0 0 NOTYPE GLOBAL 0 3 data_symbol
+ .*: 4 4 OBJECT GLOBAL 0 COM common_symbol
diff --git a/binutils/testsuite/binutils-all/readelf.wi b/binutils/testsuite/binutils-all/readelf.wi
new file mode 100644
index 00000000000..3cb2eccf019
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.wi
@@ -0,0 +1,78 @@
+The section .debug_info contains:
+
+ Compilation Unit:
+ Length: .*
+ Version: 2
+ Abbrev Offset: 0
+ Pointer Size: 4
+ Abbrev Number: 1 \(DW_TAG_compile_unit\)
+ DW_AT_name : .*/testprog.c
+ DW_AT_comp_dir : .*/binutils
+ DW_AT_producer : GNU C .*
+ DW_AT_language : 1 \(ANSI C\)
+ DW_AT_low_pc : 0
+ DW_AT_high_pc : .*
+ DW_AT_stmt_list : 0
+ Abbrev Number: 2 \(DW_TAG_subprogram\)
+ DW_AT_external : 1
+ DW_AT_name : fn
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : a
+ DW_AT_type : .*
+ DW_AT_low_pc : 0
+ DW_AT_high_pc : .*
+ DW_AT_frame_base : 1 byte block: .*
+ Abbrev Number: 3 \(DW_TAG_base_type\)
+ DW_AT_name : int
+ DW_AT_byte_size : 4
+ DW_AT_encoding : 5 \(signed\)
+ Abbrev Number: 4 \(DW_TAG_subprogram\)
+ DW_AT_sibling : .*
+ DW_AT_external : 1
+ DW_AT_name : main
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : 10
+ DW_AT_type : .*
+ DW_AT_low_pc : .*
+ DW_AT_high_pc : .*
+ DW_AT_frame_base : 1 byte block: .*
+ Abbrev Number: 5 \(DW_TAG_lexical_block\)
+ DW_AT_low_pc : .*
+ DW_AT_high_pc : .*
+
+ Extra data at end of comp unit:
+ .*: Abbrev Number: 6 \(DW_TAG_variable\)
+ DW_AT_name : common
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : 3
+ DW_AT_type : .*
+ DW_AT_external : 1
+ DW_AT_location : 5 byte block: 3 . 0 0 0 \(DW_OP_addr: 0\)
+ .*: Abbrev Number: 6 \(DW_TAG_variable\)
+ DW_AT_name : global
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : 4
+ DW_AT_type : .*
+ DW_AT_external : 1
+ DW_AT_location : 5 byte block: 3 . 0 0 0 \(DW_OP_addr: 0\)
+ .*: Abbrev Number: 7 \(DW_TAG_variable\)
+ DW_AT_name : local
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : 5
+ DW_AT_type : .*
+ DW_AT_location : 5 byte block: 3 . 0 0 . \(DW_OP_addr: .\)
+ .*: Abbrev Number: 8 \(DW_TAG_array_type\)
+ DW_AT_sibling : .*
+ DW_AT_type : .*
+ .*: Abbrev Number: 9 \(DW_TAG_subrange_type\)
+ DW_AT_upper_bound : 6
+ .*: Abbrev Number: 3 \(DW_TAG_base_type\)
+ DW_AT_name : char
+ DW_AT_byte_size : 1
+ DW_AT_encoding : . \(.* char\)
+ .*: Abbrev Number: 7 \(DW_TAG_variable\)
+ DW_AT_name : string
+ DW_AT_decl_file : 1
+ DW_AT_decl_line : 6
+ DW_AT_type : .*
+ DW_AT_location : 5 byte block: 3 . 0 0 . \(DW_OP_addr: .\)
diff --git a/binutils/testsuite/binutils-all/size.exp b/binutils/testsuite/binutils-all/size.exp
new file mode 100644
index 00000000000..b908c9198bf
--- /dev/null
+++ b/binutils/testsuite/binutils-all/size.exp
@@ -0,0 +1,78 @@
+# Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu@prep.ai.mit.edu
+
+# This file was written by Rob Savoye <rob@cygnus.com>
+# and rewritten by Ian Lance Taylor <ian@cygnus.com>
+
+if ![is_remote host] {
+ if {[which $SIZE] == 0} then {
+ perror "$SIZE does not exist"
+ return
+ }
+}
+
+send_user "Version [binutil_version $SIZE]"
+
+
+if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
+ return
+}
+
+if [is_remote host] {
+ set testfile [remote_download host tmpdir/bintest.o]
+} else {
+ set testfile tmpdir/bintest.o
+}
+
+set dec "\[0-9\]+"
+set hex "\[0-9a-fA-F\]+"
+
+# Test size with no arguments
+
+set got [binutils_run $SIZE "$SIZEFLAGS $testfile"]
+
+set want "($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($dec)\[ \]+($hex)\[ \]+${testfile}"
+
+if ![regexp $want $got all text data bss dtot hextot] then {
+ fail "size (no arguments)"
+} else {
+ if {$text < 8 || $data < 4} then {
+ fail "size (no arguments)"
+ } else {
+ pass "size (no arguments)"
+ }
+}
+
+# Test size -A
+
+set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
+
+set want "${testfile}.*(text|TEXT)\[^\n\r\]*\[ \]($dec)\[ \]+$dec.*(\\.data|DATA)\[^\n\r\]*\[ \]($dec)\[ \]+$dec"
+
+if ![regexp $want $got all textname textsize dataname datasize] then {
+ fail "size -A"
+} else {
+ verbose "text size: $textsize"
+ verbose "data size: $datasize"
+ if {$textsize < 8 || $datasize < 4} then {
+ fail "size -A"
+ } else {
+ pass "size -A"
+ }
+}
diff --git a/binutils/testsuite/binutils-all/testprog.c b/binutils/testsuite/binutils-all/testprog.c
new file mode 100644
index 00000000000..210656b4487
--- /dev/null
+++ b/binutils/testsuite/binutils-all/testprog.c
@@ -0,0 +1,28 @@
+/* This program is used to test objcopy and strip. */
+
+int common;
+int global = 1;
+static int local = 2;
+static char string[] = "string";
+
+int
+fn ()
+{
+ return 3;
+}
+
+int
+main ()
+{
+ if (common != 0
+ || global != 1
+ || local != 2
+ || strcmp (string, "string") != 0)
+ {
+ printf ("failed\n");
+ exit (1);
+ }
+
+ printf ("ok\n");
+ exit (0);
+}