summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/ld/testsuite
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-01-08 11:10:27 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-01-08 11:10:27 +0000
commit8b46c09925a80623c289e346c12921bc09fd1678 (patch)
tree01507d0da339cc7e5e6f5d16dfa625f94910b091 /gnu/usr.bin/binutils/ld/testsuite
parent5d56227f9458a53138642c1b4488b4a30f85f334 (diff)
Initial GNU binutils 2.6 import
Diffstat (limited to 'gnu/usr.bin/binutils/ld/testsuite')
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ChangeLog277
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/config/default.exp123
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-bootstrap/bootstrap.exp88
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-bar.cc17
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.cc89
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.h24
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-main.cc40
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.dat15
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.exp100
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/empic.exp247
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax.t49
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax1.c22
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax2.c19
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax3.c3
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax4.c3
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/run.c160
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest1.c117
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest2.c26
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtesti.s94
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.exp39
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.s2
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.t7
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.exp64
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.s8
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.t16
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/scriptm.t10
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.exp55
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.s1
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.t17
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh.exp141
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh1.s13
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh2.c120
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-sh/start.s27
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/main.c72
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh1.c147
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh2.c14
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.dat15
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.exp230
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/sun4.dat15
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-shared/xcoff.dat10
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr1.c25
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr2.c18
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr3.cc80
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-srec/srec.exp293
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.c10
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.exp86
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-1.robin0 -> 3840 bytes
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-2.robin0 -> 256 bytes
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ld281
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ook133
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-1.robin0 -> 256 bytes
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-2.robin0 -> 2304 bytes
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-3.robin0 -> 1024 bytes
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ld281
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ook99
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/ld-versados/versados.exp99
-rw-r--r--gnu/usr.bin/binutils/ld/testsuite/lib/ld.exp337
57 files changed, 4278 insertions, 0 deletions
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ChangeLog b/gnu/usr.bin/binutils/ld/testsuite/ChangeLog
new file mode 100644
index 00000000000..38369ce4ef8
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ChangeLog
@@ -0,0 +1,277 @@
+Wed Nov 15 17:42:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: New tests.
+ * ld-srec/sr1.c, ld-srec/sr2.c, ld-srec/sr3.cc: New files.
+ * lib/ld.exp (ld_simple_link): Discard warnings about not being
+ able to find the entry symbol.
+
+Tue Nov 14 20:03:54 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-sh/sh2.c (__main): Define.
+
+Mon Nov 6 14:39:18 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-empic/empic.exp: Accept a . in the address symbol.
+
+ * ld-shared/shared.exp: Run tests on rs6000*-*-aix* and
+ powerpc*-*-aix*. Add code to create appropriate exports files,
+ and pass appropriate compilation flags, and test against
+ appropriate expected output.
+ * ld-shared/xcoff.dat: New file.
+ * ld-shared/main.c: Put #ifndef XCOFF_TEST around tests that can
+ not be linked using XCOFF. Use shlib_shlibvar1 as a sample
+ function pointer, rather than shlib_mainvar.
+ * ld-shared/sh1.c: Likewise.
+ * ld-shared/shared.dat: Update for change from using shlib_mainvar
+ to using shlib_shlibvar1.
+ * ld-shared/sun4.dat: Likewise.
+
+Sat Oct 28 01:54:25 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/script.t: Put .pr in .text, and .rw in .data, for
+ convenience when testing XCOFF.
+
+Thu Oct 26 22:53:17 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: On AIX, pass -bI/lib/syscalls.exp
+ along with --static.
+
+ * ld-scripts/script.s: Make symbols global.
+
+Fri Oct 20 12:22:16 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: Add setup_xfails for arm*-*-pe*.
+
+Fri Sep 29 11:06:10 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: Use -e when invoking the linker, to
+ prevent the SunOS linker from trying to create a shared library.
+
+Thu Sep 28 12:37:14 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-shared/shared.exp: Run the tests on sparc*-*-sunos4*. Add
+ appropriate modifications and setup_xfails.
+ * ld-shared/sun4.dat: New file.
+
+Mon Sep 18 14:12:56 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * lib/ld.exp (default_ld_version): Call prune_system_crud.
+ (default_ld_relocate, default_ld_link): Likewise.
+ (default_ld_simple_link, default_ld_compile): Likewise.
+ (default_ld_assemble, default_ld_nm): Likewise.
+
+Fri Sep 8 17:15:38 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-cdtest/cdtest.exp: If the compiler does not exist, mark the
+ tests as untested rather than unresolved.
+
+Wed Aug 23 10:46:38 1995 Ian Lance Taylor (ian@cygnus.com)
+
+ * ld-sh/sh.exp: Call prune_system_crud on the output of cmp.
+
+Tue Aug 15 17:35:35 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/script.exp: Split script verification into a proc.
+ Add simple test of MRI script.
+ * ld-scripts/scriptm.t: New file.
+
+Wed Jul 26 11:38:58 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-sh/sh.exp: Mark `SH confirm relaxing' test unresolved when
+ appropriate.
+
+Mon Jul 24 15:34:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/default.exp: Define objcopy if it is not defined.
+ * ld-sh/*: New tests for SH relaxing.
+
+ * ld-empic/empic.exp: If $CC does not exist, call untested rather
+ than unresolved.
+
+Thu Jul 20 15:09:26 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: If $CC does not exist, mark the
+ tests as untested rather than unresolved. Clear ELF xfails for
+ mips*, not just mips.
+
+Tue Jul 18 12:00:41 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: Add setup_xfail for sh-*-* for
+ undefined line test.
+
+Fri Jul 14 13:07:48 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: New test, to check reporting of
+ undefined symbols.
+ * ld-undefined/undefined.c: New file.
+
+Mon Jul 10 11:13:39 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-versados/versados.exp: If a test fails, report it correctly:
+ don't try to run the next test, and don't report a pass as well as
+ a fail.
+
+Mon Jul 3 14:26:37 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * ld/testsuite/versados/(t1,t2).ld: End in newlines.
+
+Mon May 22 20:19:38 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * lib/ld.exp (default_ld_compile): If cc argument is multiple
+ words, use only the first when trying to verify the availability
+ of the compiler.
+
+Mon Feb 6 11:46:49 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/defined.t: Mention .data and .bss explicitly.
+
+Tue Jan 24 14:51:48 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: If not in the ld build directory,
+ call untested for each test, rather than ignoring it. If one test
+ fails, go on to the next one instead of returning.
+ * ld-cdtest/cdtest.exp: If compilations fail, mark tests as
+ unresolved.
+ * ld-empic/empic.exp: Likewise. Also, always pass the same test
+ name to pass or fail.
+ * ld-shared/shared.exp: Likewise. Also, always run all tests.
+ * ld-scripts/defined.exp: If as or nm fail, mark test as
+ unresolved. Always pass the same test name to pass or fail.
+ * ld-scripts/script.exp: Likewise.
+ * ld-scripts/sizeof.exp: Likewise.
+
+Wed Jan 11 11:48:31 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ld-scripts/sizeof.exp: New test, based on bug report from
+ anders.blomdell@control.lth.se.
+ * ld-scripts/sizeof.s: New file.
+ * ld-scripts/sizeof.t: New file.
+
+Wed Jan 4 18:56:27 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * lib/ld.exp: Use [which $ld] rather than [file exists $ld] to see
+ if the linker exists.
+
+Wed Dec 14 16:39:03 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+
+ * lib/ld.exp (prune_system_crud): Define if not already defined,
+ in case the user isn't using the newest DejaGnu version that we
+ haven't released to the net yet.
+
+Fri Dec 2 14:17:02 1994 Ian Lance Taylor <ian@rtl.cygnus.com>
+
+ * config/default.exp: Define objdump if it is not defined.
+ * ld-empic/*: New tests to test -membedded-pic code.
+
+Mon Nov 28 11:24:36 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: Pass cmp output through
+ prune_system_crud.
+ * ld-cdtest/cdtest.exp: Pass diff output through
+ prune_system_crud.
+ * ld-shared/shared.exp: Likewise.
+
+ * config/default.exp: Remove unused and useless proc ld_load.
+
+Sun Oct 30 13:02:34 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * lib/ld.exp (default_ld_compile): Remove the output file before
+ compiling.
+
+ * ld-shared/shared.exp: Move common test code into a procedure.
+ Add tests for compiling the non shared code PIC.
+ * ld-shared/main.c (main): Call main_called, and print the result.
+ * ld-shared/shared.dat: Adjust accordingly.
+
+Thu Oct 27 17:30:12 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * ld-shared: New directory, with new files to test generating ELF
+ shared libraries.
+
+ * lib/ld.exp (default_ld_compile): If the compilation worked, but
+ no object file was created, check to see if the compiler foolishly
+ ignored the -o switch when compiling, and move the resulting
+ object if it did.
+
+Thu Sep 29 12:36:51 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * VMS does not permits `.' in directory names. Renamed
+ ld.bootstrap to ld-bootstrap, ld.cdtest to ld-cdtest, and
+ ld.scripts to ld-scripts.
+
+Wed Sep 28 12:18:54 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * config/default.exp: Set variables as and nm. Create tmpdir if
+ it does not already exist.
+ * ld.bootstrap/bootstrap.exp: Don't create tmpdir here.
+ * ld.cdtest/cdtest.exp: Likewise.
+ * ld.scripts/defined.exp: Likewise. Also, don't set as and nm
+ here. Change perror for no variables found to fail.
+ * ld.scripts/script.exp: New test.
+ * ld.scripts/script.t, ld.scripts/script.s: New files.
+
+Tue Sep 27 14:59:51 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+
+ * ld.scripts: New directory.
+ * ld.scripts/defined.exp, ld.scripts/defined.s: New files.
+ * ld.scripts/defined.t: New file.
+ * lib/ld.exp (default_ld_simple_link): New function.
+ (default_ld_assemble, default_ld_nm): New functions.
+ * config/default.exp: Rename from unix-ld.exp.
+ (ld_simple_link, ld_assemble, ld_nm): New functions.
+
+ * config/unix-ld.exp: Set ld using findfile.
+ * lib/ld.exp (default_ld_relocate): Return a value. Change format
+ of log messages.
+ (default_ld_compile): Likewise.
+ (default_ld_link): Likewise. Also, don't include $BFDLIB and
+ $LIBIBERTY in link.
+ * ld.bootstrap/bootstrap.exp: Rewrite.
+ * ld.cdtest/cdtest.exp: Rewrite.
+ * ld.cdtest/cdtest-foo.cc: Update from top level ld directory.
+ * ld.cdtest/cdtest-foo.h: Likewise.
+ * ld.cdtest/cdtest-main.cc: Likewise.
+
+Fri May 27 09:35:04 1994 Ken Raeburn (raeburn@cygnus.com)
+
+ * ld.cdtest/cdtest.exp: Don't look for $result before it's
+ defined.
+
+Tue May 17 15:06:49 1994 Bill Cox (bill@rtl.cygnus.com)
+
+ * ld.bootstrap/bootstrap.exp, lib/ld.exp: Replace error proc
+ calls with perror calls.
+
+Wed May 11 16:47:46 1994 Ken Raeburn (raeburn@rtl.cygnus.com)
+
+ * ld.cdtest/cdtest-bar.cc: Renamed from cdtest-func.cc.
+ * ld.cdtest/cdtest.exp: Adjusted.
+
+Fri Jan 28 13:25:41 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
+
+ * lib/ld.exp (simple_diff): Indicate failure if files have
+ different numbers of lines. Don't muck with $differences to avoid
+ indicating a pass, just return.
+
+ * testsuite/ld.cdtest/{cdtest-foo.h,cdtest-foo.cc,cdtest-main.cc}:
+ Fix test case to be valid ANSI C++. Don't require use of header
+ files, so "../gcc/xgcc -B../gcc/" can be used for CXX.
+ * testsuite/ld.cdtest/cdtest.exp: Combine "rm" lines. Add some
+ commentary on things that are still broken with this test case.
+
+Fri Sep 10 09:58:23 1993 Jeffrey Wheat (cassidy@cygnus.com)
+
+ * testsuite/ld.cdtest/cdtest.exp: Added CXXFLAGS to compile stage.
+
+Thu Aug 12 16:05:37 1993 Jeffrey Wheat (cassidy@cygnus.com)
+
+ * testsuite/lib/ld.exp: add compiler and linker support
+ * testsuite/config/unix-ld.exp: add compiler and linker support
+ * testsuite/ld.bootstrap/bootstrap.exp: fixed to do partial links
+ * testsuite/ld.cdtest/cdtest.exp: constructor/destructor testscase
+
+Wed Aug 4 21:00:18 1993 Jeffrey Wheat (cassidy@cygnus.com)
+
+ * testsuite/lib/ld.exp: new file
+ * testsuite/config/unix-ld.exp: new file
+ * testsuite/ld.bootstrap/bootstrap.exp: new file
diff --git a/gnu/usr.bin/binutils/ld/testsuite/config/default.exp b/gnu/usr.bin/binutils/ld/testsuite/config/default.exp
new file mode 100644
index 00000000000..c7c6812d4d7
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/config/default.exp
@@ -0,0 +1,123 @@
+# Basic expect script for LD Regression Tests
+# Copyright (C) 1993,1994 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Jeffrey Wheat (cassidy@cygnus.com)
+#
+
+if ![info exists ld] then {
+ set ld [findfile $objdir/ld.new $objdir/ld.new [transform ld]]
+}
+
+if ![info exists as] then {
+ set as [findfile $base_dir/../gas/as.new $base_dir/../gas/as.new [transform as]]
+}
+
+if ![info exists nm] then {
+ set nm [findfile $base_dir/../binutils/nm.new $base_dir/../binutils/nm.new [transform nm]]
+}
+
+if ![info exists objdump] then {
+ set objdump [findfile $base_dir/../binutils/objdump]
+}
+
+if ![info exists objcopy] then {
+ set objcopy [findfile $base_dir/../binutils/objcopy]
+}
+
+if ![file isdirectory tmpdir] {catch "exec mkdir tmpdir" status}
+
+# load the utility procedures
+load_lib ld.exp
+
+#
+# ld_version -- extract and print the version number of ld compiler (GCC)
+#
+proc ld_version {} {
+ global ld
+ default_ld_version $ld
+}
+
+#
+# ld_exit -- just a stub for ld
+#
+proc ld_exit {} {
+}
+
+#
+# ld_start
+# relink the linker
+#
+proc ld_start { ld target } {
+ #
+}
+
+#
+# ld_relocate
+# link an object using relocation
+#
+proc ld_relocate { ld target objects } {
+ default_ld_relocate $ld $target $objects
+}
+
+#
+# ld_link
+# link a program using ld
+#
+proc ld_link { ld target objects } {
+ default_ld_link $ld $target $objects
+}
+
+#
+# ld_simple_link
+# link a program using ld, without including any libraries
+#
+proc ld_simple_link { ld target objects } {
+ default_ld_simple_link $ld $target $objects
+}
+
+#
+# ld_compile
+# compile an object using $cc
+#
+proc ld_compile { cc source object } {
+ default_ld_compile $cc $source $object
+}
+
+#
+# ld_assemble
+# assemble a file
+#
+proc ld_assemble { as source object } {
+ default_ld_assemble $as $source $object
+}
+
+#
+# ld_nm
+# run nm on a file
+#
+proc ld_nm { nm object } {
+ default_ld_nm $nm $object
+}
+
+#
+# ld_exec
+# execute ithe target
+#
+proc ld_exec { target output } {
+ default_ld_exec $target $output
+}
+
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-bootstrap/bootstrap.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-bootstrap/bootstrap.exp
new file mode 100644
index 00000000000..d79891df4cd
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -0,0 +1,88 @@
+# Expect script for LD Bootstrap Tests
+# Copyright (C) 1993,1994,1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Jeffrey Wheat (cassidy@cygnus.com)
+# Rewritten by Ian Lance Taylor (ian@cygnus.com)
+#
+
+# Make sure that ld can bootstrap itself.
+
+# This test can only be run if ld generates native executables.
+if ![isnative] {
+ return
+}
+
+# Bootstrap ld. First link the object files together using -r, in
+# order to test -r. Then link the result into an executable, ld1, to
+# really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a
+# new ld, ld3. ld2 and ld3 should be identical.
+
+foreach flags {"" "--static" "--traditional-format" "--no-keep-memory"} {
+ if {"$flags" != ""} {
+ set testname "bootstrap with $flags"
+ } else {
+ set testname "bootstrap"
+ }
+
+ # On AIX, you need to specify an import list when using --static.
+ if [istarget "*-*-aix*"] {
+ if {"$flags" == "--static"} {
+ set flags "--static -bI:/lib/syscalls.exp"
+ }
+ }
+
+ # This test can only be run if we have the ld build directory,
+ # since we need the object files.
+ if {$ld != "$objdir/ld.new"} {
+ untested $testname
+ continue
+ }
+
+ if ![ld_relocate $ld tmpdir/ld-partial.o "$flags $OFILES"] {
+ fail $testname
+ continue
+ }
+
+ if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY"] {
+ fail $testname
+ continue
+ }
+
+ if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
+ fail $testname
+ continue
+ }
+
+ if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
+ fail $testname
+ continue
+ }
+
+ send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
+ verbose "cmp tmpdir/ld2 tmpdir/ld3"
+ catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+
+ if [string match "" $exec_output] then {
+ pass $testname
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+
+ fail $testname
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-bar.cc b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-bar.cc
new file mode 100644
index 00000000000..79000e33954
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-bar.cc
@@ -0,0 +1,17 @@
+// test program for Class Foo
+
+#include "cdtest-foo.h"
+
+static Foo static_foo( "static_foo");
+
+Foo f()
+{
+ Foo x;
+ return x;
+}
+
+void g()
+{
+ Foo other_foo1 = Foo( "other_foo1"), other_foo2 = Foo( "other_foo2");
+ other_foo2 = other_foo1;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.cc b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.cc
new file mode 100644
index 00000000000..615e33cea78
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.cc
@@ -0,0 +1,89 @@
+// Class Foo
+#pragma implementation
+
+
+// We don't use header files, since we only want to see, whether the
+// compiler is installed properly.
+//
+#if (__GNUG__ == 2)
+typedef __SIZE_TYPE__ size_t;
+#else
+typedef unsigned int size_t;
+#endif
+
+extern "C" {
+ char *strncpy (char* dest, const char* dest, size_t len);
+ int printf (const char*, ...);
+};
+
+#include "cdtest-foo.h"
+
+int Foo::foos = 0;
+
+void Foo::init_foo ()
+{
+ printf ("BROKENLY calling Foo::init_foo from __init_start; size_of(Foo) = %d\n", sizeof(Foo));
+ foos = FOOLISH_NUMBER;
+}
+
+
+Foo::Foo ()
+{
+ i = ++foos;
+ strncpy (message, "default-foo", len);
+#ifdef WITH_ADDR
+ printf ("Constructing Foo(%d) \"default-foo\" at %08x\n", i, this);
+#else
+ printf ("Constructing Foo(%d) \"default-foo\"\n", i);
+#endif
+}
+
+Foo::Foo (char* msg)
+{
+ i = ++foos;
+ strncpy( message, msg, len);
+#ifdef WITH_ADDR
+ printf ( "Constructing Foo(%d) \"%s\" at %08x\n", i, message, this);
+#else
+ printf ( "Constructing Foo(%d) \"%s\"\n", i, message);
+#endif
+}
+
+
+Foo::Foo (const Foo& foo)
+{
+ i = ++foos;
+#ifdef WITH_ADDR
+ printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n",
+ i, foo.message, this, foo.i, &foo);
+#else
+ printf ("Initializing Foo(%d) \"%s\" with Foo(%d)\n",i, foo.message, foo.i);
+#endif
+ for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
+}
+
+
+Foo& Foo::operator= (const Foo& foo)
+{
+#ifdef WITH_ADDR
+ printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n",
+ foo.i, foo.message, &foo, i, this);
+#else
+ printf ("Copying Foo(%d) \"%s\" to Foo(%d)\n", foo.i, foo.message, i);
+#endif
+ for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
+ return *this;
+}
+
+
+Foo::~Foo ()
+{
+ foos--;
+#ifdef WITH_ADDR
+ printf ("Destructing Foo(%d) \"%s\" at %08x (remaining foos: %d)\n",
+ i, message, this, foos);
+#else
+ printf ("Destructing Foo(%d) \"%s\" (remaining foos: %d)\n",
+ i, message, foos);
+#endif
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.h b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.h
new file mode 100644
index 00000000000..0ba2d37b272
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-foo.h
@@ -0,0 +1,24 @@
+// Class Foo
+
+#pragma interface
+
+#define FOOLISH_NUMBER -4711
+
+#ifndef FOO_MSG_LEN
+#define FOO_MSG_LEN 80
+#endif
+
+class Foo {
+ static int foos;
+ int i;
+ const len = FOO_MSG_LEN;
+ char message[len];
+public:
+ static void init_foo ();
+ static int nb_foos() { return foos; }
+ Foo();
+ Foo( char* message);
+ Foo(const Foo&);
+ Foo & operator= (const Foo&);
+ ~Foo ();
+};
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-main.cc b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-main.cc
new file mode 100644
index 00000000000..4b99b5c5f0f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest-main.cc
@@ -0,0 +1,40 @@
+// main program for Class Foo
+
+extern "C" {
+// Some <assert.h> implementations (e.g. SUNOS 4.1) are broken,
+// in that they require <stdio.h>. But, if gcc/g++ is installed
+// correctly, you should get gcc's assert.h.
+// If the compile fails, it means the wrong include files are in use!
+#include <assert.h>
+};
+#include "cdtest-foo.h"
+
+extern "C" void __init_start();
+
+extern Foo f(void);
+extern void g(void);
+
+/* This function should *not* be called by the environment. There is
+ no way in C++ to ``run something after the initializers but before main()''.
+ The library that depends on this (NIHCL) is broken. -- John Gilmore
+ We leave this here to test that future changes to the compiler
+ do not re-introduce this losing ``feature''. */
+void
+__init_start()
+{
+ Foo::init_foo();
+}
+
+static Foo static_foo( "static_foo");
+
+main()
+{
+ assert (Foo::nb_foos() == 2);
+ Foo automatic_foo( "automatic_foo");
+ Foo bla_foo = f();
+ assert (Foo::nb_foos() == 4);
+ g();
+ assert (Foo::nb_foos() == 4);
+ // `automatic_foo' and `bla_foo' are destructed here
+}
+
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.dat b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.dat
new file mode 100644
index 00000000000..39be0dbc2c7
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.dat
@@ -0,0 +1,15 @@
+Constructing Foo(1) "static_foo"
+Constructing Foo(2) "static_foo"
+Constructing Foo(3) "automatic_foo"
+Constructing Foo(4) "default-foo"
+Initializing Foo(5) "default-foo" with Foo(4)
+Destructing Foo(4) "default-foo" (remaining foos: 4)
+Constructing Foo(5) "other_foo1"
+Constructing Foo(6) "other_foo2"
+Copying Foo(5) "other_foo1" to Foo(6)
+Destructing Foo(6) "other_foo1" (remaining foos: 5)
+Destructing Foo(5) "other_foo1" (remaining foos: 4)
+Destructing Foo(5) "default-foo" (remaining foos: 3)
+Destructing Foo(3) "automatic_foo" (remaining foos: 2)
+Destructing Foo(2) "static_foo" (remaining foos: 1)
+Destructing Foo(1) "static_foo" (remaining foos: 0)
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.exp
new file mode 100644
index 00000000000..828975dc6a3
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-cdtest/cdtest.exp
@@ -0,0 +1,100 @@
+# Expect script for LD cdtest Tests
+# Copyright (C) 1993,1994,1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Jeffrey Wheat (cassidy@cygnus.com)
+# Rewritten by Ian Lance Taylor (ian@cygnus.com)
+#
+
+# Make sure that constructors are handled correctly.
+
+set test1 "cdtest"
+set test2 "cdtest with -Ur"
+
+# This test requires running the executable generated by ld.
+if ![isnative] {
+ return
+}
+
+if { [which $CXX] == 0 } {
+ untested $test1
+ untested $test2
+ return
+}
+
+if { ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
+ || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
+ || ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
+ unresolved $test1
+ unresolved $test2
+ return
+}
+
+if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
+ fail $test1
+} else {
+ send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
+ verbose "tmpdir/cdtest >tmpdir/cdtest.out"
+ catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
+ if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail $test1
+ } else {
+ send_log "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat\n"
+ verbose "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat"
+ catch "exec diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+
+ if [string match "" $exec_output] then {
+ pass $test1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail $test1
+ }
+ }
+}
+
+if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
+ fail $test2
+} else {
+ if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] {
+ fail $test2
+ } else {
+ send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
+ verbose "tmpdir/cdtest >tmpdir/cdtest.out"
+ catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output
+ if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail $test2
+ } else {
+ send_log "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat\n"
+ verbose "diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat"
+ catch "exec diff tmpdir/cdtest.out $srcdir$subdir/cdtest.dat" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+
+ if [string match "" $exec_output] then {
+ pass $test2
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output" 1
+ fail $test2
+ }
+ }
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/empic.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/empic.exp
new file mode 100644
index 00000000000..937f01aac8f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/empic.exp
@@ -0,0 +1,247 @@
+# Expect script for ld-empic tests
+# Copyright (C) 1994,1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Ian Lance Taylor (ian@cygnus.com)
+#
+
+# Test the handling of MIPS embedded PIC code. This test essentially
+# tests the compiler and assembler as well as the linker, since MIPS
+# embedded PIC is a GNU enhancement to standard MIPS tools.
+
+# Embedded PIC is only supported for MIPS ECOFF targets.
+if ![istarget mips*-*-ecoff*] {
+ return
+}
+
+set testname relax
+
+if { [which $CC] == 0 } {
+ untested $testname
+ return
+}
+
+# Test that relaxation works correctly. This testsuite was composed
+# (by experimentation) to force the linker to relax twice--that is,
+# the first relaxation pass will force another call to be out of
+# range, requiring a second relaxation pass.
+if { ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/relax1.c tmpdir/relax1.o]
+ || ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/relax2.c tmpdir/relax2.o]
+ || ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/relax3.c tmpdir/relax3.o]
+ || ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/relax4.c tmpdir/relax4.o] } {
+ unresolved $testname
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/relax "--relax -T $srcdir$subdir/relax.t tmpdir/relax1.o tmpdir/relax2.o tmpdir/relax3.o tmpdir/relax4.o"] {
+ fail $testname
+} else {
+ # Check that the relaxation produced the correct result. Check
+ # each bal instruction. Some will go directly to the start of a
+ # function, which is OK. Some will form part of the five
+ # instruction expanded call sequence, in which case we compute the
+ # real destination and make sure it is the start of a function.
+ # Some bal instructions are used to locate the start of the
+ # function in order to do position independent addressing into the
+ # text section, in which case we just check that it correctly
+ # computes the start of the function.
+
+ # Get the symbol table.
+ if ![ld_nm $nm tmpdir/relax] {
+ unresolved $testname
+ return
+ }
+
+ # Get a disassembly.
+ send_log "$objdump -d tmpdir/relax >tmpdir/relax.dis\n"
+ verbose "$objdump -d tmpdir/relax >tmpdir/relax.dis"
+ catch "exec $objdump -d tmpdir/relax >tmpdir/relax.dis" exec_output
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ unresolved $testname
+ return
+ }
+
+ set balcnt 0
+ set file [open tmpdir/relax.dis r]
+ while { [gets $file line] != -1 } {
+ verbose "$line" 2
+
+ if ![string match "*bal*" $line] {
+ continue
+ }
+
+ verbose "$line"
+
+ incr balcnt
+
+ if ![regexp "^(\[0-9a-fA-F\]+) (<\[a-z+0-9A-Z.\]+>)? bal (\[0-9a-fA-F\]+)" $line whole addr label dest] {
+ perror "unrecognized format for $line"
+ unresolved $testname
+ return
+ }
+
+ if "0x$addr + 8 != 0x$dest" {
+ # This is a straight function call. All function calls in
+ # this example are to either foo or bar.
+ if "0x$dest != $nm_output(foo) && 0x$dest != $nm_output(bar)" {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ } else {
+ # Pick up the next line. If it is sll, this is a switch
+ # prologue, and there is not much we can do to test it.
+ # Otherwise, it should be lui, and the next instruction
+ # should be an addiu, followed by an addu to $31.
+ if { [gets $file l] == -1 } {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose $l
+
+ if [string match "*sll*" $l] {
+ continue
+ }
+ if ![regexp "lui (\[\$a-z0-9\]+),(\[0-9\]+)" $l whole reg upper] {
+ send_log "$line\n"
+ send_log "$l\n"
+ fail $testname
+ return
+ }
+
+ if { [gets $file l] == -1 } {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose "$l"
+ if ![regexp "addiu \\$reg,\\$reg,(\[-0-9\]+)" $l whole lower] {
+ send_log "$line\n"
+ send_log "$l\n"
+ send_log "addiu \\$reg,\\$reg,(\[-0-9\]+)\n"
+ fail $testname
+ return
+ }
+
+ if { [gets $file l] == -1 } {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose "$l"
+ if ![regexp "addu \\$reg,\\$reg,\\\$ra" $l] {
+ send_log "$line\n"
+ send_log "$l\n"
+ fail $testname
+ return
+ }
+
+ # The next line will be jalr in the case of an expanded
+ # call. Otherwise, the code is getting the start of the
+ # function, and the next line can be anything.
+
+ if { [gets $file l] == -1 } {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+
+ if [string match "*jalr*" $l] {
+ set dest [expr 0x$addr + 8 + ($upper << 16) + $lower]
+ if { $dest != $nm_output(foo) && $dest != $nm_output(bar) } {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ } else {
+ set dest [expr ($upper << 16) + $lower]
+ if ![regexp "<\[a-z\]+\\+(\[0-9a-fA-F\]+)>" $label whole offset] {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ if "0x$offset + 8 != - $dest" {
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ }
+ }
+ }
+
+ close $file
+
+ if {$balcnt < 10} {
+ fail $testname
+ } else {
+ verbose "$balcnt bal instructions"
+ pass $testname
+ }
+}
+
+# We now test actually running embedded MIPS PIC code. This can only
+# be done on a MIPS host with the same endianness as our target.
+if [istarget mipsel-*-*] {
+ if ![ishost mips*-*-ultrix*] {
+ return
+ }
+} else {
+ if ![ishost mips*-*-irix*] {
+ return
+ }
+}
+
+set testname "run embedded PIC code"
+
+# Compile the program which will run the test. This code must be
+# compiled for the host, not the target.
+send_log "$CC_FOR_HOST $CFLAGS_FOR_HOST -o tmpdir/run $srcdir$subdir/run.c\n"
+verbose "$CC_FOR_HOST $CFLAGS_FOR_HOST -o tmpdir/run $srcdir$subdir/run.c"
+catch "exec $CC_FOR_HOST $CFLAGS_FOR_HOST -o tmpdir/run $srcdir$subdir/run.c" exec_output
+if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ unresolved $testname
+ return
+}
+
+# Compile and link the test.
+if { ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/runtesti.s tmpdir/runtesti.o]
+ || ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/runtest1.c tmpdir/runtest1.o]
+ || ![ld_compile "$CC $CFLAGS -membedded-pic" $srcdir$subdir/runtest2.c tmpdir/runtest2.o] } {
+ unresolved $testname
+ return
+}
+if ![ld_simple_link $ld tmpdir/runtest "--embedded-relocs tmpdir/runtesti.o tmpdir/runtest1.o tmpdir/runtest2.o"] {
+ fail $testname
+} else {
+ # Now run the test.
+ send_log "tmpdir/run tmpdir/runtest\n"
+ verbose "tmpdir/run tmpdir/runtest"
+ catch "exec tmpdir/run tmpdir/runtest" exec_output
+ if [string match "*ran and returned 0*" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ pass $testname
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ fail $testname
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax.t b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax.t
new file mode 100644
index 00000000000..8c18b69a86e
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax.t
@@ -0,0 +1,49 @@
+OUTPUT_FORMAT("ecoff-bigmips")
+SECTIONS
+{
+ .foo 0x30 : {
+ tmpdir/relax3.o(.text)
+ tmpdir/relax1.o(.text)
+ }
+ .text 0x20000 : {
+ _ftext = . ;
+ *(.init)
+ eprol = .;
+ tmpdir/relax4.o(.text)
+ *(.text)
+ *(.fini)
+ etext = .;
+ _etext = .;
+ }
+ .rdata . : {
+ *(.rdata)
+ }
+ _fdata = .;
+ .data . : {
+ *(.data)
+ CONSTRUCTORS
+ }
+ _gp = . + 0x8000;
+ .lit8 . : {
+ *(.lit8)
+ }
+ .lit4 . : {
+ *(.lit4)
+ }
+ .sdata . : {
+ *(.sdata)
+ }
+ edata = .;
+ _edata = .;
+ _fbss = .;
+ .sbss . : {
+ *(.sbss)
+ *(.scommon)
+ }
+ .bss . : {
+ *(.bss)
+ *(COMMON)
+ }
+ end = .;
+ _end = .;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax1.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax1.c
new file mode 100644
index 00000000000..20ec39efc9c
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax1.c
@@ -0,0 +1,22 @@
+/* First source file in relaxation test. */
+
+extern int bar ();
+static int foo2 ();
+
+int foo (int i)
+{
+ switch (i)
+ {
+ case 0: bar (0); break;
+ case 1: bar (1); break;
+ case 2: bar (2); break;
+ case 3: bar (3); break;
+ case 4: bar (foo2); break;
+ case 5: bar (bar); break;
+ }
+ while (1)
+ if (i)
+ return bar ();
+}
+
+static int foo2 () { }
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax2.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax2.c
new file mode 100644
index 00000000000..58854a03aa9
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax2.c
@@ -0,0 +1,19 @@
+/* Second source file in relaxation test. */
+
+int bar2 ()
+{
+ int i;
+
+ for (i = 0; i < 100; i++)
+ foo ();
+ return foo () + foo () + foo () + foo ();
+}
+
+int bar (int i)
+{
+ while (1)
+ if (i)
+ return foo ();
+ else
+ return foo ();
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax3.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax3.c
new file mode 100644
index 00000000000..1aaa532bc2f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax3.c
@@ -0,0 +1,3 @@
+/* Third source file in relaxation test. */
+
+int quux () { return 0; }
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax4.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax4.c
new file mode 100644
index 00000000000..21cfb05b67d
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/relax4.c
@@ -0,0 +1,3 @@
+/* Fourth source file in relaxation test. */
+
+int xyzzy () { return 0; }
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/run.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/run.c
new file mode 100644
index 00000000000..9a0377e02e5
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/run.c
@@ -0,0 +1,160 @@
+/* Load and run a MIPS position independent ECOFF file.
+ Written by Ian Lance Taylor <ian@cygnus.com>
+ Public domain. */
+
+/* This program will load an ECOFF file into memory and execute it.
+ The file must have been compiled using the GNU -membedded-pic
+ switch to produce position independent code. This will only work
+ if this program is run on a MIPS system with the same endianness as
+ the ECOFF file. The ECOFF file must be complete. System calls may
+ not work correctly.
+
+ There are further restrictions on the file (they could be removed
+ by doing some additional programming). The file must be aligned
+ such that it does not require any gaps introduced in the data
+ segment; the GNU linker produces such files by default. However,
+ the file must not assume that the text or data segment is aligned
+ on a page boundary. The start address must be at the start of the
+ text segment.
+
+ The ECOFF file is run by calling it as though it were a function.
+ The address of the data segment is passed as the only argument.
+ The file is expected to return an integer value, which will be
+ printed. */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* Structures used in ECOFF files. We assume that a short is two
+ bytes and an int is four bytes. This is not much of an assumption,
+ since we already assume that we are running on a MIPS host with the
+ same endianness as the file we are examining. */
+
+struct ecoff_filehdr {
+ unsigned short f_magic; /* magic number */
+ unsigned short f_nscns; /* number of sections */
+ unsigned int f_timdat; /* time & date stamp */
+ unsigned int f_symptr; /* file pointer to symtab */
+ unsigned int f_nsyms; /* number of symtab entries */
+ unsigned short f_opthdr; /* sizeof(optional hdr) */
+ unsigned short f_flags; /* flags */
+};
+
+struct ecoff_aouthdr
+{
+ unsigned short magic; /* type of file */
+ unsigned short vstamp; /* version stamp */
+ unsigned int tsize; /* text size in bytes, padded to FW bdry*/
+ unsigned int dsize; /* initialized data " " */
+ unsigned int bsize; /* uninitialized data " " */
+ unsigned int entry; /* entry pt. */
+ unsigned int text_start; /* base of text used for this file */
+ unsigned int data_start; /* base of data used for this file */
+ unsigned int bss_start; /* base of bss used for this file */
+ unsigned int gprmask; /* ?? */
+ unsigned int cprmask[4]; /* ?? */
+ unsigned int gp_value; /* value for gp register */
+};
+
+#define ECOFF_SCNHDR_SIZE (40)
+
+static void
+die (s)
+ char *s;
+{
+ perror (s);
+ exit (1);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ FILE *f;
+ struct stat s;
+ char *z;
+ struct ecoff_filehdr *fh;
+ struct ecoff_aouthdr *ah;
+ unsigned int toff;
+ char *t, *d;
+ int (*pfn) ();
+ int ret;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s file\n", argv[0]);
+ exit (1);
+ }
+
+ f = fopen (argv[1], "r");
+ if (f == NULL)
+ die (argv[1]);
+
+ if (stat (argv[1], &s) < 0)
+ die ("stat");
+
+ z = (char *) malloc (s.st_size);
+ if (z == NULL)
+ die ("malloc");
+
+ if (fread (z, 1, s.st_size, f) != s.st_size)
+ die ("fread");
+
+ /* We need to figure out the start of the text segment, which is the
+ location we are going to call, and the start of the data segment,
+ which we are going to pass as an argument. We also need the size
+ and start address of the bss segment. This information is all in
+ the ECOFF a.out header. */
+
+ fh = (struct ecoff_filehdr *) z;
+ if (fh->f_opthdr != sizeof (struct ecoff_aouthdr))
+ {
+ fprintf (stderr, "%s: unexpected opthdr size: is %u, want %u\n",
+ argv[1], (unsigned int) fh->f_opthdr,
+ (unsigned int) sizeof (struct ecoff_aouthdr));
+ exit (1);
+ }
+
+ ah = (struct ecoff_aouthdr *) (z + sizeof (struct ecoff_filehdr));
+ if (ah->magic != 0413)
+ {
+ fprintf (stderr, "%s: bad aouthdr magic number 0%o (want 0413)\n",
+ argv[1], (unsigned int) ah->magic);
+ exit (1);
+ }
+
+ /* We should clear the bss segment at this point. This is the
+ ah->bsize bytes starting at ah->bss_start, To do this correctly,
+ we would have to make sure our memory block is large enough. It
+ so happens that our test case does not have any additional pages
+ for the bss segment--it is contained within the data segment.
+ So, we don't bother. */
+ if (ah->bsize != 0)
+ {
+ fprintf (stderr,
+ "%s: bss segment is %u bytes; non-zero sizes not supported\n",
+ argv[1], ah->bsize);
+ exit (1);
+ }
+
+ /* The text section starts just after all the headers, rounded to a
+ 16 byte boundary. */
+ toff = (sizeof (struct ecoff_filehdr) + sizeof (struct ecoff_aouthdr)
+ + fh->f_nscns * ECOFF_SCNHDR_SIZE);
+ toff += 15;
+ toff &=~ 15;
+ t = z + toff;
+
+ /* The tsize field gives us the start of the data segment. */
+ d = z + ah->tsize;
+
+ /* Call the code as a function. */
+ pfn = (int (*) ()) t;
+ ret = (*pfn) (d);
+
+ printf ("%s ran and returned %d\n", argv[1], ret);
+
+ exit (0);
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest1.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest1.c
new file mode 100644
index 00000000000..f9ab6eb6681
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest1.c
@@ -0,0 +1,117 @@
+/* First C source file for actual execution test. */
+
+/* The main point of this test is to make sure that the code and data
+ are truly position independent. We statically initialize several
+ global variables, and make sure that they are correctly adjusted at
+ runtime. */
+
+int i = 1;
+int j = 0;
+extern int k;
+int l;
+char small_buf[] = "aaaa";
+char *small_pointer = small_buf;
+char big_buf[] = "aaaaaaaaaaaaaaaa";
+char *big_pointer = big_buf;
+
+extern int bar ();
+int (*pbar) () = bar;
+
+static int
+foo2 (arg)
+ int arg;
+{
+ l = arg;
+ return i + j;
+}
+
+int (*pfoo2) () = foo2;
+
+int
+chkstr (z, c)
+ char *z;
+ int c;
+{
+ /* Switch statements need extra effort to be position independent,
+ so we run one here, even though most of the cases will never be
+ taken. */
+ switch (c)
+ {
+ case 1:
+ case 2:
+ case 3:
+ return i - 1;
+ case 4:
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ return i * j;
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ return j;
+ case 16:
+ break;
+ default:
+ return 0;
+ }
+
+ while (c-- != 0)
+ if (*z++ != 'a')
+ return 0;
+
+ return *z == '\0';
+}
+
+/* This function is called by the assembler startup routine. It tries
+ to test that everything was correctly initialized. It returns 0 on
+ success, something else on failure. */
+
+int
+foo ()
+{
+ if (i != 1)
+ return 1;
+ if (j != 0)
+ return 2;
+ if (! chkstr (small_buf, 4))
+ return 3;
+ if (! chkstr (small_pointer, 4))
+ return 4;
+ if (! chkstr (big_buf, 16))
+ return 5;
+ if (! chkstr (big_pointer, 16))
+ return 6;
+
+ if (l != 0)
+ return 7;
+ if (foo2 (1) != 1)
+ return 8;
+ if (l != 1)
+ return 9;
+ if ((*pfoo2) (2) != 1)
+ return 10;
+ if (l != 2)
+ return 11;
+
+ if (bar (1) != 0)
+ return 12;
+ if (bar (-1) != 1)
+ return 13;
+ if ((*pbar) (0xa5a5a5a5) != -1)
+ return 14;
+ if (k != 0xa5a5a5a5)
+ return 15;
+ if ((*pbar) (0) != 0xa5a5a5a5)
+ return 16;
+ if (k != 0)
+ return 17;
+
+ return 0;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest2.c b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest2.c
new file mode 100644
index 00000000000..000525f11ea
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtest2.c
@@ -0,0 +1,26 @@
+/* Second C source file for actual execution test. */
+
+int k;
+extern int i;
+extern int j;
+extern char small_buf[];
+extern char *small_pointer;
+
+extern int chkstr ();
+
+int
+bar (n)
+ int n;
+{
+ int r;
+
+ if (i != 1
+ || j != 0
+ || ! chkstr (small_buf, 4)
+ || ! chkstr (small_pointer, 4))
+ return k + 1;
+
+ r = k;
+ k = n;
+ return r;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtesti.s b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtesti.s
new file mode 100644
index 00000000000..efa195301fb
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-empic/runtesti.s
@@ -0,0 +1,94 @@
+# Assembler initialization code for actual execution test.
+
+# This code becomes the start of the execution test program. It is
+# responsible for initializing the static data, invoking the C code,
+# and returning the result. It is called as though it were a C
+# function with an argument of the address of the data segment.
+
+# We need to know the value of _ftext and _fdata at link time, but we
+# have no way to actually get that at runtime. This is because when
+# this code is compiled with -membedded-pic, the la instruction will
+# be turned into an addiu $gp instruction. We work around this by
+# storing the information in words in the .data section. We then load
+# the values of these words *before* doing the runtime relocation.
+ .sdata
+text_start:
+ .word _ftext
+data_start:
+ .word _fdata
+
+ .globl start
+ .text
+start:
+ # Grab some space on the stack, just as though we were a real
+ # function.
+ addiu $sp,$sp,-8
+ sw $31,0($sp)
+
+ # Save the $gp register, and set it up for our data section.
+ sw $gp,4($sp)
+
+ addu $gp,$4,0x8000 # macro
+
+ # The start of the data segment is in $4.
+
+ # Get the address of start into $5 in a position independent
+ # fashion.
+ .set noreorder
+ $LF1 = . + 8
+ bal $LF1
+ la $5,start-$LF1 # macro
+ .set reorder
+ addu $5,$5,$31
+
+ # Now get the address of _ftext into $6.
+ la $6,_ftext-start # macro
+ addu $6,$6,$5
+
+ # Get the value of _ftext used to link into $7.
+ lw $7,text_start # macro
+
+ # Get the value of _fdata used to link into $8.
+ lw $8,data_start # macro
+
+ # Get the address of __runtime_reloc_start into $9.
+ la $9,__runtime_reloc_start-start # macro
+ addu $9,$9,$5
+
+ # Get the address of __runtime_reloc_stop into $10.
+ la $10,__runtime_reloc_stop-start # macro
+ addu $10,$10,$5
+
+ # The words between $9 and $10 are the runtime initialization
+ # instructions. Step through and relocate them. First set
+ # $11 and $12 to the values to add to text and data sections,
+ # respectively.
+ subu $11,$6,$7
+ subu $12,$4,$8
+
+1:
+ bge $9,$10,3f # macro
+ lw $13,0($9)
+ and $14,$13,0xfffffffe # macro
+ move $15,$11
+ beq $13,$14,2f
+ move $15,$12
+2:
+ addu $14,$14,$4
+ lw $24,0($14)
+ addu $24,$24,$15
+ sw $24,0($14)
+ addiu $9,$9,4
+ b 1b
+3:
+
+ # Now the statically initialized data has been relocated
+ # correctly, and we can call the C code which does the actual
+ # testing.
+ bal foo
+
+ # We return the value returned by the C code.
+ lw $31,0($sp)
+ lw $gp,4($sp)
+ addu $sp,$sp,8
+ j $31
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.exp
new file mode 100644
index 00000000000..5e98f39a39f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.exp
@@ -0,0 +1,39 @@
+# Test DEFINED in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+
+set testname "DEFINED"
+set prms_id 5699
+
+if ![ld_assemble $as $srcdir$subdir/defined.s tmpdir/def.o] {
+ unresolved $testname
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/def "-T $srcdir$subdir/defined.t tmpdir/def.o"] {
+ fail $testname
+} else {
+ if ![ld_nm $nm tmpdir/def] {
+ unresolved $testname
+ } else {
+ if {![info exists nm_output(value1)] \
+ || ![info exists nm_output(value2)]} {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $testname
+ } else {
+ if {$nm_output(value1) != 1} {
+ send_log "value1 == $nm_output(value1)\n"
+ verbose "value1 == $nm_output(value1)"
+ fail $testname
+ } else {
+ if {$nm_output(value2) != 2} {
+ send_log "value2 == $nm_output(value2)\n"
+ verbose "value2 == $nm_output(value2)"
+ fail $testname
+ } else {
+ pass $testname
+ }
+ }
+ }
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.s b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.s
new file mode 100644
index 00000000000..a364bbbbe6c
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.s
@@ -0,0 +1,2 @@
+ .globl defined
+ defined = 1
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.t b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.t
new file mode 100644
index 00000000000..c1ef1b6a798
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/defined.t
@@ -0,0 +1,7 @@
+SECTIONS {
+ .text : { *(.text) }
+ .data : { *(.data) }
+ .bss : { *(.bss) *(COMMON) }
+}
+value1 = DEFINED (defined) ? 1 : 2;
+value2 = DEFINED (undefined) ? 1 : 2;
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.exp
new file mode 100644
index 00000000000..46a25f109d7
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.exp
@@ -0,0 +1,64 @@
+# Test basic linker script functionality
+# By Ian Lance Taylor, Cygnus Support
+
+set testname "script"
+
+if ![ld_assemble $as $srcdir$subdir/script.s tmpdir/script.o] {
+ unresolved $testname
+ return
+}
+
+proc check_script { } {
+ global nm
+ global testname
+ global nm_output
+
+ if ![ld_nm $nm tmpdir/script] {
+ unresolved $testname
+ } else {
+ if {![info exists nm_output(text_start)] \
+ || ![info exists nm_output(text_end)] \
+ || ![info exists nm_output(data_start)] \
+ || ![info exists nm_output(data_end)]} {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $testname
+ } else {
+ if {$nm_output(text_start) != 0x100} {
+ send_log "text_start == $nm_output(text_start)\n"
+ verbose "text_start == $nm_output(text_start)"
+ fail $testname
+ } else { if {$nm_output(text_end) < 0x104 \
+ || $nm_output(text_end) > 0x110} {
+ send_log "text_end == $nm_output(text_end)\n"
+ verbose "text_end == $nm_output(text_end)"
+ fail $testname
+ } else { if {$nm_output(data_start) != 0x1000} {
+ send_log "data_start == $nm_output(data_start)\n"
+ verbose "data_start == $nm_output(data_start)"
+ fail $testname
+ } else { if {$nm_output(data_end) < 0x1004 \
+ || $nm_output(data_end) > 0x1010} {
+ send_log "data_end == $nm_output(data_end)\n"
+ verbose "data_end == $nm_output(data_end)"
+ fail $testname
+ } else {
+ pass $testname
+ } } } }
+ }
+ }
+}
+
+if ![ld_simple_link $ld tmpdir/script "-T $srcdir$subdir/script.t tmpdir/script.o"] {
+ fail $testname
+} else {
+ check_script
+}
+
+set testname "MRI script"
+
+if ![ld_simple_link $ld tmpdir/script "-c $srcdir$subdir/scriptm.t"] {
+ fail $testname
+} else {
+ check_script
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.s b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.s
new file mode 100644
index 00000000000..d7b65b0df55
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.s
@@ -0,0 +1,8 @@
+ .text
+ .globl text_symbol
+text_symbol:
+ .long 1
+ .data
+ .globl data_symbol
+data_symbol:
+ .long 2
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.t b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.t
new file mode 100644
index 00000000000..ee7a48a9f60
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/script.t
@@ -0,0 +1,16 @@
+SECTIONS
+{
+ .text 0x100 : {
+ text_start = .;
+ *(.text)
+ *(.pr)
+ text_end = .;
+ }
+ . = 0x1000;
+ .data : {
+ data_start = .;
+ *(.data)
+ *(.rw)
+ data_end = .;
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/scriptm.t b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/scriptm.t
new file mode 100644
index 00000000000..57ccae13662
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/scriptm.t
@@ -0,0 +1,10 @@
+* MRI script
+sect .text = $100 ; .text start address
+sect .data = 1000h ; .data start address
+public text_start = $100
+public text_end = # continuation line
+ text_start + 4
+public data_start = 1000h
+public data_end = data_start + 4
+
+load tmpdir/script.o
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.exp
new file mode 100644
index 00000000000..dc5a4ed35a6
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.exp
@@ -0,0 +1,55 @@
+# Test SIZEOF in a linker script.
+# By Ian Lance Taylor, Cygnus Support
+# Based on a bug report from anders.blomdell@control.lth.se.
+
+set testname "SIZEOF"
+
+if ![ld_assemble $as $srcdir$subdir/sizeof.s tmpdir/sizeof.o] {
+ unresolved $testname
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/sizeof "-T $srcdir$subdir/sizeof.t tmpdir/sizeof.o"] {
+ fail $testname
+ return
+}
+
+if ![ld_nm $nm tmpdir/sizeof] {
+ unresolved $testname
+ return
+}
+
+if {![info exists nm_output(text_start)] \
+ || ![info exists nm_output(text_end)] \
+ || ![info exists nm_output(data_start)] \
+ || ![info exists nm_output(data_end)] \
+ || ![info exists nm_output(sizeof_text)] \
+ || ![info exists nm_output(sizeof_data)]} {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $testname
+ return
+}
+
+if {$nm_output(text_end) - $nm_output(text_start) != $nm_output(sizeof_text)} {
+ send_log "text_end - text_start != sizeof_text\n"
+ verbose "text_end - text_start != sizeof_text"
+ fail $testname
+ return
+}
+
+if {$nm_output(data_end) - $nm_output(data_start) != $nm_output(sizeof_data)} {
+ send_log "data_end - data_start != sizeof_data\n"
+ verbose "data_end - data_start != sizeof_data"
+ fail $testname
+ return
+}
+
+if {$nm_output(sizeof_text) != $nm_output(sizeof_data)} {
+ send_log "sizeof_text != sizeof_data\n"
+ verbose "sizeof_text != sizeof_data"
+ fail $testname
+ return
+}
+
+pass $testname
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.s b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.s
new file mode 100644
index 00000000000..e221ca3c0b3
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.s
@@ -0,0 +1 @@
+ .space 16
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.t b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.t
new file mode 100644
index 00000000000..6244a37b7ac
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-scripts/sizeof.t
@@ -0,0 +1,17 @@
+SECTIONS {
+ .text :
+ {
+ text_start = .;
+ tmpdir/sizeof.o
+ text_end = .;
+ }
+ .data :
+ {
+ data_start = .;
+ . = . + SIZEOF(.text);
+ data_end = .;
+ }
+}
+
+sizeof_text = SIZEOF(.text);
+sizeof_data = SIZEOF(.data);
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh.exp
new file mode 100644
index 00000000000..3bd2a654e7a
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh.exp
@@ -0,0 +1,141 @@
+# Expect script for ld-sh tests
+# Copyright (C) 1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Ian Lance Taylor (ian@cygnus.com)
+#
+
+# Test SH relaxing. This tests the compiler and assembler as well as
+# the linker.
+
+if ![istarget sh*-*-*] {
+ return
+}
+
+set testsimple "SH simple relaxing"
+
+if ![ld_assemble $as "-relax $srcdir$subdir/sh1.s" tmpdir/sh1.o] {
+ unresolved $testsimple
+} else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
+ fail $testsimple
+} else {
+ if ![ld_nm $nm tmpdir/sh1] {
+ unresolved $testsimple
+ } else {
+ if {![info exists nm_output(bar)] \
+ || ![info exists nm_output(foo)]} {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $testsimple
+ } else {
+ if {$nm_output(bar) != $nm_output(foo) + 4} {
+ send_log "foo == $nm_output(foo)\n"
+ verbose "foo == $nm_output(foo)"
+ send_log "bar == $nm_output(bar)\n"
+ verbose "bar == $nm_output(bar)"
+ fail $testsimple
+ } else {
+ pass $testsimple
+ }
+ }
+ }
+} }
+
+set testsrec "SH relaxing to S-records"
+
+if ![ld_simple_link $ld tmpdir/sh1.s1 "-relax -oformat srec tmpdir/sh1.o"] {
+ fail $testsrec
+} else {
+ # The file name is embedded in the S-records, so create both
+ # files with the same name.
+ catch "exec rm -f tmpdir/sh1.s2" exec_output
+ send_log "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
+ verbose "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2"
+ catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ unresolved $testsrec
+ } else {
+ catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ unresolved $testsrec
+ } else {
+ send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
+ verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
+ catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ fail $testsrec
+ } else {
+ pass $testsrec
+ }
+ }
+ }
+}
+
+set testlink "SH relaxing"
+set testjsr "SH confirm relaxing"
+set testrun "SH relaxing execution"
+
+if { [which $CC] == 0 } {
+ untested $testlink
+ untested $testjsr
+ untested $testrun
+ return
+}
+
+if {![ld_assemble $as "-relax $srcdir$subdir/start.s" tmpdir/start.o] \
+ || ![ld_compile $CC "-mrelax $srcdir$subdir/sh2.c" tmpdir/sh2.o]} {
+ unresolved $testlink
+ unresolved $testjsr
+ unresolved $testrun
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
+ fail $testlink
+ unresolved $testjsr
+ unresolved $testrun
+ return
+}
+
+pass $testlink
+
+send_log "$objdump -d tmpdir/sh2\n"
+verbose "$objdump -d tmpdir/sh2"
+catch "exec $objdump -d tmpdir/sh2" exec_output
+if [string match "*jsr*" $exec_output] {
+ fail $testjsr
+} else {
+ pass $testjsr
+}
+
+if { ![info exists SIM] || [which $SIM] == 0 } {
+ untested $testrun
+ return
+}
+
+set status [catch "exec $SIM tmpdir/sh2" exec_output]
+if { $status == 0 } {
+ pass $testrun
+} else {
+ fail $testrun
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh1.s b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh1.s
new file mode 100644
index 00000000000..13c2858f4aa
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh1.s
@@ -0,0 +1,13 @@
+ .text
+foo:
+L1:
+ mov.l L2,r0
+ .uses L1
+ jsr @r0
+ rts
+ .align 2
+L2:
+ .long bar
+bar:
+ rts
+ .align 2
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh2.c b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh2.c
new file mode 100644
index 00000000000..527fe88ce5d
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/sh2.c
@@ -0,0 +1,120 @@
+int global;
+
+extern void trap (int, int);
+static void quit (int);
+static int foo (int);
+
+int
+main ()
+{
+ if (foo (0) != 0 || global != 0)
+ quit (1);
+ if (foo (1) != 1 || global != 1)
+ quit (1);
+ if (foo (2) != 2 || global != 2)
+ quit (1);
+ if (foo (3) != 3 || global != 3)
+ quit (1);
+ if (foo (4) != 4 || global != 4)
+ quit (1);
+ if (foo (5) != 5 || global != 5)
+ quit (1);
+ if (foo (6) != 6 || global != 6)
+ quit (1);
+ if (foo (7) != 7 || global != 7)
+ quit (1);
+ if (foo (8) != 8 || global != 8)
+ quit (1);
+ quit (0);
+}
+
+void
+__main ()
+{
+}
+
+static void
+quit (int status)
+{
+ trap (1, status);
+}
+
+int
+bar (int i)
+{
+ global = i;
+ return i;
+}
+
+int
+bar0 (int i)
+{
+ global = 0;
+ return i;
+}
+
+int
+bar1 (int i)
+{
+ global = 1;
+ return i;
+}
+
+int
+bar2 (int i)
+{
+ global = 2;
+ return i;
+}
+
+int
+bar3 (int i)
+{
+ global = 3;
+ return i;
+}
+
+int
+bar4 (int i)
+{
+ global = 4;
+ return i;
+}
+
+int
+bar5 (int i)
+{
+ global = 5;
+ return i;
+}
+
+int
+bar6 (int i)
+{
+ global = 6;
+ return i;
+}
+
+int
+bar7 (int i)
+{
+ global = 7;
+ return i;
+}
+
+int
+foo (int i)
+{
+ switch (i)
+ {
+ case 0: bar0 (0); return 0;
+ case 1: bar1 (1); return 1;
+ case 2: bar2 (2); return 2;
+ case 3: bar3 (3); return 3;
+ case 4: bar4 (4); return 4;
+ case 5: bar5 (5); return 5;
+ case 6: bar6 (6); return 6;
+ case 7: bar7 (7); return 7;
+ default: return bar (i);
+ }
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-sh/start.s b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/start.s
new file mode 100644
index 00000000000..2af4c799f33
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-sh/start.s
@@ -0,0 +1,27 @@
+ .section .text
+ .global start
+start:
+
+ mov.l stack_k,r15
+
+ ! call the mainline
+L1:
+ mov.l main_k,r0
+ .uses L1
+ jsr @r0
+ nop
+
+ .align 2
+stack_k:
+ .long _stack
+main_k:
+ .long _main
+
+ .global _trap
+_trap:
+ trapa #3
+ rts
+ nop
+
+ .section .stack
+_stack: .long 0xdeaddead
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/main.c b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/main.c
new file mode 100644
index 00000000000..258cb431467
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/main.c
@@ -0,0 +1,72 @@
+/* This is the main program for the shared library test. */
+
+#include <stdio.h>
+
+int mainvar = 1;
+int overriddenvar = 2;
+extern int shlibvar1;
+
+extern int shlib_mainvar ();
+extern int shlib_overriddenvar ();
+extern int shlib_shlibvar1 ();
+extern int shlib_shlibvar2 ();
+extern int shlib_shlibcall ();
+extern int shlib_maincall ();
+extern int shlib_checkfunptr1 ();
+extern int shlib_checkfunptr2 ();
+extern int (*shlib_getfunptr1 ()) ();
+extern int (*shlib_getfunptr2 ()) ();
+extern int shlib_check ();
+
+/* This function is called by the shared library. */
+
+int
+main_called ()
+{
+ return 6;
+}
+
+int
+main ()
+{
+ int (*p) ();
+
+ printf ("mainvar == %d\n", mainvar);
+ printf ("overriddenvar == %d\n", overriddenvar);
+ printf ("shlibvar1 == %d\n", shlibvar1);
+#ifndef XCOFF_TEST
+ printf ("shlib_mainvar () == %d\n", shlib_mainvar ());
+ printf ("shlib_overriddenvar () == %d\n", shlib_overriddenvar ());
+#endif
+ printf ("shlib_shlibvar1 () == %d\n", shlib_shlibvar1 ());
+ printf ("shlib_shlibvar2 () == %d\n", shlib_shlibvar2 ());
+ printf ("shlib_shlibcall () == %d\n", shlib_shlibcall ());
+#ifndef XCOFF_TEST
+ printf ("shlib_maincall () == %d\n", shlib_maincall ());
+#endif
+ printf ("main_called () == %d\n", main_called ());
+ printf ("shlib_checkfunptr1 (shlib_shlibvar1) == %d\n",
+ shlib_checkfunptr1 (shlib_shlibvar1));
+#ifndef XCOFF_TEST
+ printf ("shlib_checkfunptr2 (main_called) == %d\n",
+ shlib_checkfunptr2 (main_called));
+#endif
+ p = shlib_getfunptr1 ();
+ printf ("shlib_getfunptr1 () ");
+ if (p == shlib_shlibvar1)
+ printf ("==");
+ else
+ printf ("!=");
+ printf (" shlib_shlibvar1\n");
+#ifndef XCOFF_TEST
+ p = shlib_getfunptr2 ();
+ printf ("shlib_getfunptr2 () ");
+ if (p == main_called)
+ printf ("==");
+ else
+ printf ("!=");
+ printf (" main_called\n");
+#endif
+ printf ("shlib_check () == %d\n", shlib_check ());
+ return 0;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh1.c b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh1.c
new file mode 100644
index 00000000000..740cfe728f8
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh1.c
@@ -0,0 +1,147 @@
+/* This is part of the shared library ld test. This file becomes part
+ of a shared library. */
+
+/* This variable is supplied by the main program. */
+#ifndef XCOFF_TEST
+extern int mainvar;
+#endif
+
+/* This variable is defined in the shared library, and overridden by
+ the main program. */
+#ifndef XCOFF_TEST
+int overriddenvar = -1;
+#endif
+
+/* This variable is defined in the shared library. */
+int shlibvar1 = 3;
+
+/* This variable is defined by another object in the shared library. */
+extern int shlibvar2;
+
+/* These functions return the values of the above variables as seen in
+ the shared library. */
+
+#ifndef XCOFF_TEST
+int
+shlib_mainvar ()
+{
+ return mainvar;
+}
+#endif
+
+#ifndef XCOFF_TEST
+int
+shlib_overriddenvar ()
+{
+ return overriddenvar;
+}
+#endif
+
+int
+shlib_shlibvar1 ()
+{
+ return shlibvar1;
+}
+
+int
+shlib_shlibvar2 ()
+{
+ return shlibvar2;
+}
+
+/* This function calls a function defined by another object in the
+ shared library. */
+
+extern int shlib_shlibcalled ();
+
+int
+shlib_shlibcall ()
+{
+ return shlib_shlibcalled ();
+}
+
+/* This function calls a function defined by the main program. */
+
+#ifndef XCOFF_TEST
+extern int main_called ();
+
+int
+shlib_maincall ()
+{
+ return main_called ();
+}
+#endif
+
+/* This function is passed a function pointer to shlib_mainvar. It
+ confirms that the pointer compares equally. */
+
+int
+shlib_checkfunptr1 (p)
+ int (*p) ();
+{
+ return p == shlib_shlibvar1;
+}
+
+/* This function is passed a function pointer to main_called. It
+ confirms that the pointer compares equally. */
+
+#ifndef XCOFF_TEST
+int
+shlib_checkfunptr2 (p)
+ int (*p) ();
+{
+ return p == main_called;
+}
+#endif
+
+/* This function returns a pointer to shlib_mainvar. */
+
+int
+(*shlib_getfunptr1 ()) ()
+{
+ return shlib_shlibvar1;
+}
+
+/* This function returns a pointer to main_called. */
+
+#ifndef XCOFF_TEST
+int
+(*shlib_getfunptr2 ()) ()
+{
+ return main_called;
+}
+#endif
+
+/* This function makes sure that constant data and local functions
+ work. */
+
+#ifndef __STDC__
+#define const
+#endif
+
+static int i = 6;
+static const char *str = "Hello, world\n";
+
+int
+shlib_check ()
+{
+ const char *s1, *s2;
+
+ if (i != 6)
+ return 0;
+
+ /* To isolate the test, don't rely on any external functions, such
+ as strcmp. */
+ s1 = "Hello, world\n";
+ s2 = str;
+ while (*s1 != '\0')
+ if (*s1++ != *s2++)
+ return 0;
+ if (*s2 != '\0')
+ return 0;
+
+ if (shlib_shlibvar1 () != 3)
+ return 0;
+
+ return 1;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh2.c b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh2.c
new file mode 100644
index 00000000000..013a4e0994f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sh2.c
@@ -0,0 +1,14 @@
+/* This is part of the shared library ld test. This file becomes part
+ of a shared library. */
+
+/* This variable is defined here, and referenced by another file in
+ the shared library. */
+int shlibvar2 = 4;
+
+/* This function is called by another file in the shared library. */
+
+int
+shlib_shlibcalled ()
+{
+ return 5;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.dat b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.dat
new file mode 100644
index 00000000000..9f12380ffb0
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.dat
@@ -0,0 +1,15 @@
+mainvar == 1
+overriddenvar == 2
+shlibvar1 == 3
+shlib_mainvar () == 1
+shlib_overriddenvar () == 2
+shlib_shlibvar1 () == 3
+shlib_shlibvar2 () == 4
+shlib_shlibcall () == 5
+shlib_maincall () == 6
+main_called () == 6
+shlib_checkfunptr1 (shlib_shlibvar1) == 1
+shlib_checkfunptr2 (main_called) == 1
+shlib_getfunptr1 () == shlib_shlibvar1
+shlib_getfunptr2 () == main_called
+shlib_check () == 1
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.exp
new file mode 100644
index 00000000000..3ad71385919
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/shared.exp
@@ -0,0 +1,230 @@
+# Expect script for ld-shared tests
+# Copyright (C) 1994,1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Ian Lance Taylor (ian@cygnus.com)
+#
+
+# Make sure that ld can generate ELF shared libraries.
+# Note that linking against ELF shared libraries is tested by the
+# bootstrap test.
+
+# This test can only be run if ld generates native executables.
+if ![isnative] then {return}
+
+# This test can only be run on a couple of ELF platforms.
+# Square bracket expressions seem to confuse istarget.
+if { ![istarget i386-*-sysv4*] \
+ && ![istarget i486-*-sysv4*] \
+ && ![istarget i586-*-sysv4*] \
+ && ![istarget i386-*-unixware] \
+ && ![istarget i486-*-unixware] \
+ && ![istarget i586-*-unixware] \
+ && ![istarget i386-*-elf*] \
+ && ![istarget i486-*-elf*] \
+ && ![istarget i586-*-elf*] \
+ && ![istarget sparc*-*-elf] \
+ && ![istarget sparc*-*-solaris2*] \
+ && ![istarget sparc*-*-sunos4*] \
+ && ![istarget rs6000*-*-aix*] \
+ && ![istarget powerpc*-*-aix*] } {
+ return
+}
+
+set tmpdir tmpdir
+set SHCFLAG ""
+
+if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+
+ # AIX shared libraries do not seem to support useful features,
+ # like overriding the shared library function or letting the
+ # shared library refer to objects defined in the main program. We
+ # avoid testing those features.
+ set SHCFLAG "-DXCOFF_TEST"
+
+ # The AIX 3.2.5 loader appears to randomly fail when loading
+ # shared libraries from NSF mounted partitions, so we avoid any
+ # potential problems by using a local directory.
+ catch {exec /bin/sh -c "echo $$"} pid
+ set tmpdir /usr/tmp/ld.$pid
+ catch "exec mkdir $tmpdir" exec_status
+
+ # On AIX, we need to explicitly export the symbols the shared
+ # library is going to provide, and need.
+ set file [open $tmpdir/xcoff.exp w]
+ puts $file shlibvar1
+ puts $file shlibvar2
+ puts $file shlib_shlibvar1
+ puts $file shlib_shlibvar2
+ puts $file shlib_shlibcall
+ puts $file shlib_shlibcalled
+ puts $file shlib_checkfunptr1
+ puts $file shlib_getfunptr1
+ puts $file shlib_check
+ close $file
+}
+
+# The test procedure.
+proc shared_test { progname testname main sh1 sh2 dat } {
+ global ld
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+
+ # Build the shared library.
+ # On AIX, we need to use an export file.
+ set shared -shared
+ if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
+ }
+ if {![ld_simple_link $ld $tmpdir/$progname.so "$shared $tmpdir/$sh1 $tmpdir/$sh2"]} {
+ fail "$testname"
+ return
+ }
+
+ # Link against the shared library. Use -rpath so that the
+ # dynamic linker can locate the shared library at runtime.
+ # On AIX, we must include /lib in -rpath, as otherwise the loader
+ # can not find -lc.
+ set rpath $tmpdir
+ if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ set rpath /lib:$tmpdir
+ }
+ if ![ld_link $ld $tmpdir/$progname "-rpath $rpath $tmpdir/$main $tmpdir/$progname.so"] {
+ fail "$testname"
+ return
+ }
+
+ # Run the resulting program
+ send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
+ verbose "$tmpdir/$progname >$tmpdir/$progname.out"
+ catch "exec $tmpdir/$progname >$tmpdir/$progname.out" exec_output
+ if ![string match "" $exec_output] then {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ fail "$testname"
+ return
+ }
+
+ send_log "diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat\n"
+ verbose "diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat"
+ catch "exec diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+
+ if {![string match "" $exec_output]} then {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ fail "$testname"
+ return
+ }
+
+ pass "$testname"
+}
+
+# Unfortunately, the gcc argument is -fpic and the cc argument is
+# -KPIC. We have to try both.
+
+set picflag "-fpic"
+send_log "$CC $picflag\n"
+verbose "$CC $picflag"
+catch "exec $CC $picflag" exec_output
+send_log "$exec_output\n"
+verbose "--" "$exec_output"
+if { [string match "*illegal option*" $exec_output] \
+ || [string match "*option ignored*" $exec_output] \
+ || [string match "*unrecognized option*" $exec_output] \
+ || [string match "*passed to ld*" $exec_output] } {
+ if [istarget *-*-sunos4*] {
+ set picflag "-pic"
+ } else {
+ set picflag "-KPIC"
+ }
+}
+verbose "Using $picflag to compile PIC code"
+
+# Compile the main program.
+if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+ unresolved "shared (non PIC)"
+ unresolved "shared"
+} else {
+ # The shared library is composed of two files. First compile them
+ # without using -fpic. That should work on an ELF system,
+ # although it will be less efficient because the dynamic linker
+ # will need to do more relocation work. However, note that not
+ # using -fpic will cause some of the tests to return different
+ # results.
+ if { ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
+ || ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
+ unresolved "shared (non PIC)"
+ } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff
+ } else {
+ # SunOS can not handle non PIC code in a shared library
+ setup_xfail "*-*-sunos4*"
+ shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared
+ } }
+
+ # Now compile the code using -fpic.
+
+ if { ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
+ || ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
+ unresolved "shared"
+ } else {
+ # SunOS can not compare function pointers correctly
+ if [istarget "*-*-sunos4*"] {
+ shared_test shp "shared" mainnp.o sh1p.o sh2p.o sun4
+ } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff
+ } else {
+ shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared
+ } }
+ }
+}
+
+# Now do the same tests again, but this time compile main.c PIC.
+if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
+ unresolved "shared (PIC main, non PIC so)"
+ unresolved "shared (PIC main)"
+} else {
+ if { [file exists $tmpdir/sh1np.o ] && [ file exists $tmpdir/sh2np.o ] } {
+ if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff
+ } else {
+ # SunOS can not handle non PIC code in a shared library
+ setup_xfail "*-*-sunos4*"
+ shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared
+ }
+ } else {
+ unresolved "shared (PIC main, non PIC so)"
+ }
+
+ if { [file exists $tmpdir/sh1p.o ] && [ file exists $tmpdir/sh2p.o ] } {
+ if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o xcoff
+ } else {
+ shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o shared
+ }
+ } else {
+ unresolved "shared (PIC main)"
+ }
+}
+
+if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ # Remove the temporary directory.
+ catch "exec rm -rf $tmpdir" exec_status
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sun4.dat b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sun4.dat
new file mode 100644
index 00000000000..28e6b72781a
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/sun4.dat
@@ -0,0 +1,15 @@
+mainvar == 1
+overriddenvar == 2
+shlibvar1 == 3
+shlib_mainvar () == 1
+shlib_overriddenvar () == 2
+shlib_shlibvar1 () == 3
+shlib_shlibvar2 () == 4
+shlib_shlibcall () == 5
+shlib_maincall () == 6
+main_called () == 6
+shlib_checkfunptr1 (shlib_shlibvar1) == 0
+shlib_checkfunptr2 (main_called) == 1
+shlib_getfunptr1 () != shlib_shlibvar1
+shlib_getfunptr2 () == main_called
+shlib_check () == 1
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-shared/xcoff.dat b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/xcoff.dat
new file mode 100644
index 00000000000..a409d96a1ec
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-shared/xcoff.dat
@@ -0,0 +1,10 @@
+mainvar == 1
+overriddenvar == 2
+shlibvar1 == 3
+shlib_shlibvar1 () == 3
+shlib_shlibvar2 () == 4
+shlib_shlibcall () == 5
+main_called () == 6
+shlib_checkfunptr1 (shlib_shlibvar1) == 1
+shlib_getfunptr1 () == shlib_shlibvar1
+shlib_check () == 1
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr1.c b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr1.c
new file mode 100644
index 00000000000..e4fcee1a3aa
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr1.c
@@ -0,0 +1,25 @@
+/* This file is compiled and linked into the S-record format. */
+
+extern int e1;
+extern int e2;
+int i;
+int j = 1;
+static int k;
+static int l = 1;
+static char ab[] = "This is a string constant";
+
+extern int fn1 ();
+extern int fn2 ();
+
+int
+main ()
+{
+ fn1 (ab);
+ fn2 ("static string constant");
+ return e1 + e2 + i + j + k + l;
+}
+
+int
+__main ()
+{
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr2.c b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr2.c
new file mode 100644
index 00000000000..5736cfa468d
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr2.c
@@ -0,0 +1,18 @@
+/* This file is compiled and linked into the S-record format. */
+
+int e1;
+int e2 = 1;
+
+int
+fn1 (s)
+ char *s;
+{
+ return s[e1];
+}
+
+int
+fn2 (s)
+ char *s;
+{
+ return s[e2];
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr3.cc b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr3.cc
new file mode 100644
index 00000000000..96bff164de4
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/sr3.cc
@@ -0,0 +1,80 @@
+// This file is compiled and linked into the S-record format.
+
+#define FOO_MSG_LEN 80
+
+class Foo {
+ static int foos;
+ int i;
+ const len = FOO_MSG_LEN;
+ char message[len];
+public:
+ static void init_foo ();
+ static int nb_foos() { return foos; }
+ Foo();
+ Foo( char* message);
+ Foo(const Foo&);
+ Foo & operator= (const Foo&);
+ ~Foo ();
+};
+
+static Foo static_foo( "static_foo");
+
+int
+main ()
+{
+ Foo automatic_foo( "automatic_foo");
+ return 0;
+}
+
+extern "C" {
+int
+__main ()
+{
+}
+
+int
+__builtin_delete ()
+{
+}
+
+int
+__builtin_new ()
+{
+}
+}
+
+int Foo::foos = 0;
+
+void Foo::init_foo ()
+{
+ foos = 80;
+}
+
+Foo::Foo ()
+{
+ i = ++foos;
+}
+
+Foo::Foo (char* msg)
+{
+ i = ++foos;
+}
+
+Foo::Foo (const Foo& foo)
+{
+ i = ++foos;
+ for (int k = 0; k < FOO_MSG_LEN; k++)
+ message[k] = foo.message[k];
+}
+
+Foo& Foo::operator= (const Foo& foo)
+{
+ for (int k = 0; k < FOO_MSG_LEN; k++)
+ message[k] = foo.message[k];
+ return *this;
+}
+
+Foo::~Foo ()
+{
+ foos--;
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-srec/srec.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/srec.exp
new file mode 100644
index 00000000000..5dfbc0c29ad
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-srec/srec.exp
@@ -0,0 +1,293 @@
+# Test linking directly to S-records.
+# By Ian Lance Taylor, Cygnus Support.
+# Public domain.
+
+# Get the offset from an S-record line to the start of the data.
+
+proc srec_off { l } {
+ if [string match "S1*" $l] {
+ return 8
+ } else { if [string match "S2*" $l] {
+ return 10
+ } else { if [string match "S3*" $l] {
+ return 12
+ } else {
+ return -1
+ } } }
+}
+
+# See if an S-record line contains only zero data.
+
+proc srec_zero { l } {
+ if [string match "S\[0789\]*" $l] {
+ return 1
+ }
+
+ # Strip the address and checksum.
+ if [string match "S\[123\]*" $l] {
+ set l [string range $l [srec_off $l] [expr [string length $l] - 3]]
+ } else {
+ return 0
+ }
+
+ # The rest must be zero.
+ return [string match "" [string trim $l "0"]]
+}
+
+# Get the address of an S-record line.
+
+proc srec_addr { l } {
+ if [string match "S\[123\]*" $l] {
+ set addr [string range $l 4 [expr [srec_off $l] - 1]]
+ } else {
+ return -1
+ }
+
+ return "0x$addr"
+}
+
+# Get the number of data bytes in an S-record line.
+
+proc srec_len { l } {
+ if ![string match "S\[123\]*" $l] {
+ return 0
+ }
+
+ return [expr "0x[string range $l 2 3]" - ([srec_off $l] - 4) / 2 - 1]
+}
+
+# Extract bytes from an S-record line.
+
+proc srec_extract { l start len } {
+ set off [srec_off $l]
+ set rlen [srec_len $l]
+ set stop [expr $start + $len]
+ if { $stop > $rlen } {
+ set stop [expr $rlen]
+ }
+ set start [expr $start * 2 + $off]
+ set stop [expr $stop * 2 + $off - 1]
+ return [string range $l $start $stop]
+}
+
+# See if a range of bytes in an S-record line is all zeroes.
+
+proc srec_zero_range { l start len } {
+ return [string match "" [string trim [srec_extract $l $start $len] "0"]]
+}
+
+# Trim an S-record line such that the specified number of bytes remain
+# at the end.
+
+proc srec_trim { l leave } {
+ set off [srec_off $l]
+ set addr [srec_addr $l]
+ set len [srec_len $l]
+
+ if { $leave >= $len } {
+ return $l
+ }
+
+ set s1 [string range $l 0 1]
+ set s2 [format "%02x" [expr ($off - 4) / 2 + $leave + 1]]
+ set s3 [format "%0[expr $off - 4]x" [expr $addr + $len - $leave]]
+ set s4 [string range $l [expr [string length $l] - ($leave * 2) - 2] end]
+ set s "${s1}${s2}${s3}${s4}"
+
+ verbose "srec_trim { '$l' $leave } returning '$s'" 2
+
+ return $s
+}
+
+# Report failure when comparing S-record lines
+
+proc srec_compare_fail { which l1 l2 } {
+ send_log "comparison failure $which:\n$l1\n$l2\n"
+ verbose "comparison failure $which:\n$l1\n$l2"
+}
+
+# Compare S-record files. We don't want to fuss about things like
+# extra zeroes. Note that BFD always sorts S-records by address.
+
+proc srec_compare { f1 f2 } {
+ set e1 [gets $f1 l1]
+ set e2 [gets $f2 l2]
+
+ while { $e1 != -1 } {
+ set l1 [string trimright $l1 "\r\n"]
+ set l2 [string trimright $l2 "\r\n"]
+ if { $e2 == -1 } {
+ # If l1 contains data, it must be zero.
+ if ![srec_zero $l1] {
+ send_log "data after EOF: $l1\n"
+ verbose "data after EOF: $l1"
+ return 0
+ }
+ } else { if { [string compare $l1 $l2] == 0 } {
+ set e1 [gets $f1 l1]
+ set e2 [gets $f2 l2]
+ } else { if { [srec_zero $l1] } {
+ set e1 [gets $f1 l1]
+ } else { if { [srec_zero $l2] } {
+ set e2 [gets $f2 l2]
+ } else {
+ # The strings are not the same, and neither is all zeroes.
+ set a1 [srec_addr $l1]
+ set n1 [srec_len $l1]
+ set a2 [srec_addr $l2]
+ set n2 [srec_len $l2]
+
+ if { $a1 < $a2 && ![srec_zero_range $l1 0 [expr $a2 - $a1]] } {
+ verbose "$a1 $a2 [srec_extract $l1 0 [expr $a2 - $a1]]" 2
+ srec_compare_fail 1 $l1 $l2
+ return 0
+ }
+ if { $a2 < $a1 && ![srec_zero_range $l2 0 [expr $a1 - $a2]] } {
+ srec_compare_fail 2 $l1 $l2
+ return 0
+ }
+
+ # Here we know that any initial data in both lines is
+ # zero. Now make sure that any overlapping data matches.
+ if { $a1 < $a2 } {
+ set os1 [expr $a2 - $a1]
+ set os2 0
+ } else {
+ set os1 0
+ set os2 [expr $a1 - $a2]
+ }
+ if { $a1 + $n1 < $a2 + $n2 } {
+ set ol [expr $n1 - $os1]
+ } else {
+ set ol [expr $n2 - $os2]
+ }
+
+ set x1 [srec_extract $l1 $os1 $ol]
+ set x2 [srec_extract $l2 $os2 $ol]
+ if { [string compare $x1 $x2] != 0 } {
+ verbose "$os1 $ol $x1" 2
+ verbose "$os2 $ol $x2" 2
+ srec_compare_fail 3 $l1 $l2
+ return 0
+ }
+
+ # These strings match. Trim the data from the larger
+ # string, read a new copy of the smaller string, and
+ # continue.
+ if { $a1 + $n1 < $a2 + $n2 } {
+ set l2 [srec_trim $l2 [expr ($a2 + $n2) - ($a1 + $n1)]]
+ set e1 [gets $f1 l1]
+ } else { if { $a1 + $n1 > $a2 + $n2 } {
+ set l1 [srec_trim $l1 [expr ($a1 + $n1) - ($a2 + $n2)]]
+ set e2 [gets $f2 l2]
+ } else {
+ set e1 [gets $f1 l1]
+ set e2 [gets $f2 l2]
+ } }
+ } } } }
+ }
+
+ # We've reached the end of the first file. The remainder of the
+ # second file must contain only zeroes.
+ while { $e2 != -1 } {
+ set l2 [string trimright $l2 "\r\n"]
+ if ![srec_zero $l2] {
+ send_log "data after EOF: $l2\n"
+ verbose "data after EOF: $l2"
+ return 0
+ }
+ set e2 [gets $f2 l2]
+ }
+
+ return 1
+}
+
+# Link twice, objcopy, and compare
+
+proc run_srec_test { test objs } {
+ global ld
+ global objcopy
+ global sizeof_headers
+ global host_triplet
+
+ # If the linker script uses SIZEOF_HEADERS, use a -Ttext argument
+ # to force both the normal link and the S-record link to be put in
+ # the same place. We don't always use -Ttext because it interacts
+ # poorly with a.out.
+
+ if { $sizeof_headers } {
+ set targ "-Ttext 0x1000"
+ } else {
+ set targ ""
+ }
+
+ if { ![ld_simple_link $ld tmpdir/sr1 "$targ $objs"] \
+ || ![ld_simple_link $ld tmpdir/sr2.sr "$targ -oformat srec $objs"] } {
+ fail $test
+ return
+ }
+
+ 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 [prune_system_crud $host_triplet $exec_output]
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ unresolved $test
+ return
+ }
+
+ set f1 [open tmpdir/sr1.sr r]
+ set f2 [open tmpdir/sr2.sr r]
+ if [srec_compare $f1 $f2] {
+ pass $test
+ } else {
+ fail $test
+ }
+ close $f1
+ close $f2
+}
+
+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 sizeof_headers [string match "*SIZEOF_HEADERS*" $exec_output]
+
+# First test linking a C program. We don't require any libraries. We
+# link it normally, and objcopy to the S-record format, and then link
+# directly to the S-record format, and require that the two files
+# contain the same data.
+
+if { [which $CC] == 0 } {
+ untested $test1
+ untested $test2
+ return
+}
+
+if { ![ld_compile $CC $srcdir/$subdir/sr1.c tmpdir/sr1.o] \
+ || ![ld_compile $CC $srcdir/$subdir/sr2.c tmpdir/sr2.o] } {
+ unresolved $test1
+ unresolved $test2
+ return
+}
+
+run_srec_test $test1 "tmpdir/sr1.o tmpdir/sr2.o"
+
+# Now try linking a C++ program with global constructors and
+# destructors. Note that since we are not linking against any
+# libraries, this program won't actually work or anything.
+
+if { [which $CXX] == 0 } {
+ untested $test2
+ return
+}
+
+if ![ld_compile "$CXX $CXXFLAGS -fgnu-linker" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] {
+ unresolved $test2
+ return
+}
+
+run_srec_test $test2 "tmpdir/sr3.o"
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.c b/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.c
new file mode 100644
index 00000000000..ef2aec6d6e5
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.c
@@ -0,0 +1,10 @@
+/* This file is used to test the linker's reporting of undefined
+ symbols. */
+
+extern int this_function_is_not_defined ();
+
+int
+function ()
+{
+ return this_function_is_not_defined ();
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.exp
new file mode 100644
index 00000000000..2e426dd2ed1
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-undefined/undefined.exp
@@ -0,0 +1,86 @@
+# Test that the linker reports undefined symbol errors correctly.
+# By Ian Lance Taylor, Cygnus Support
+#
+# Copyright (C) 1995 Free Software Foundation
+#
+# 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
+# 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.
+
+set testund "undefined"
+set testfn "undefined function"
+set testline "undefined line"
+
+if { [which $CC] == 0 } {
+ untested $testund
+ untested $testfn
+ untested $testline
+ return
+}
+
+if ![ld_compile "$CC -g" $srcdir$subdir/undefined.c tmpdir/undefined.o] {
+ unresolved $testund
+ unresolved $testfn
+ unresolved $testline
+ return
+}
+
+catch "exec rm -f tmpdir/undefined" exec_output
+
+# Using -e start prevents the SunOS linker from trying to build a
+# shared library.
+send_log "$ld -e start -o tmpdir/undefined tmpdir/undefined.o\n"
+verbose "$ld -e start -o tmpdir/undefined tmpdir/undefined.o"
+
+catch "exec $ld -e start -o tmpdir/undefined tmpdir/undefined.o" exec_output
+send_log "$exec_output\n"
+verbose "$exec_output"
+
+proc checkund { string testname } {
+ global exec_output
+
+ if [string match "*$string*" $exec_output] {
+ pass $testname
+ } else {
+ fail $testname
+ }
+}
+
+set mu "undefined reference to `this_function_is_not_defined'"
+checkund $mu $testund
+
+# ARM PE defaults to using stabs debugging, which we can't handle for
+# a COFF file.
+setup_xfail "arm*-*-pe*"
+
+set mf "tmpdir/undefined.o: In function `function':"
+checkund $mf $testfn
+
+# ELF targets currently can not get line number information (except
+# for MIPS ELF).
+setup_xfail "*-*-elf*" "*-*-sysv4*" "*-*-unixware*" "*-*-solaris*" "*-*-gnu*"
+setup_xfail "hppa*-*-lites*" "m88*-harris-cxux*" "m88*-*-dgux*"
+setup_xfail "powerpc*-*-eabi*" "*-stratus-*" "*-cbm-*" "*-ncr-*"
+clear_xfail "mips*-*-elf*" "mips*-*-sysv4*" "mips*-*-gnu*"
+
+# COFF SH gets this test wrong--it reports line 10, because although
+# the jump is at line 9, the function address, and the reloc, is
+# stored at the end of the function.
+setup_xfail "sh-*-*"
+
+# ARM PE defaults to using stabs debugging, which we can't handle for
+# a COFF file.
+setup_xfail "arm*-*-pe*"
+
+set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
+checkund $ml $testline
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-1.ro b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-1.ro
new file mode 100644
index 00000000000..1d70d8091de
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-1.ro
Binary files differ
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-2.ro b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-2.ro
new file mode 100644
index 00000000000..8d4dc591084
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1-2.ro
Binary files differ
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ld b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ld
new file mode 100644
index 00000000000..1a5c4e3aac0
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ld
@@ -0,0 +1,281 @@
+OUTPUT_FORMAT("srec")
+SECTIONS
+{
+
+
+.text 0 : { *("9") *("10") *("11") *("12") *("13") *("14") *("15")
+ *("7") *("8") *("0") *("1") *("2") *("3") *("4") }
+.bss (NOLOAD) : { *("5") *("6") }
+
+.PAFI =0x00000050 ;
+.PCHIO =0x000000D0 ;
+.PCLO =0x00000054 ;
+.PCVBSV =0x0000000E ;
+.PCVTSU =0x00000012 ;
+.PCVTSV =0x00000016 ;
+.PCVTSVL =0x0000001A ;
+.PCVTUS =0x0000001E ;
+.PDIS =0x00000022 ;
+.PDISL =0x00000026 ;
+.PDVJ =0x0000002A ;
+.PEIO =0x000000CC ;
+.PEOF =0x00000058 ;
+.PEOL =0x0000005C ;
+.PEQUS =0x0000002E ;
+.PEQUV =0x00000032 ;
+.PEQUVL =0x00000036 ;
+.PEQUW =0x000000DE ;
+.PGCM =0x00000064 ;
+.PGEQS =0x0000003A ;
+.PGEQV =0x0000003E ;
+.PGEQVL =0x00000042 ;
+.PGET =0x00000060 ;
+.PGRTS =0x00000046 ;
+.PGRTV =0x0000004A ;
+.PGRTVL =0x0000004E ;
+.PIACT =0x0000006C ;
+.PIFD =0x00000068 ;
+.PINDS =0x00000052 ;
+.PINDV =0x00000056 ;
+.PINDVL =0x0000005A ;
+.PINDW =0x000000D6 ;
+.PLDCS =0x0000005E ;
+.PLDCV =0x00000062 ;
+.PLEQS =0x00000066 ;
+.PLEQV =0x0000006A ;
+.PLEQVL =0x0000006E ;
+.PLESS =0x00000072 ;
+.PLESV =0x00000076 ;
+.PLESVL =0x0000007A ;
+.PLODS =0x0000007E ;
+.PLODV =0x00000082 ;
+.PLODVL =0x00000086 ;
+.PMODJ =0x0000008A ;
+.PMOV =0x000000E2 ;
+.PMPJ =0x0000008E ;
+.PNEQS =0x00000092 ;
+.PNEQV =0x00000096 ;
+.PNEQVL =0x0000009A ;
+.PNEQW =0x000000DA ;
+.PPAGE =0x000000D4 ;
+.PPEE =0x00000070 ;
+.PPUT =0x00000074 ;
+.PRDB =0x00000078 ;
+.PRDC =0x0000007C ;
+.PRDH =0x00000080 ;
+.PRDI =0x00000084 ;
+.PRDJ =0x00000088 ;
+.PRDRS =0x000000C8 ;
+.PRDS =0x0000008C ;
+.PRDV =0x00000090 ;
+.PRLN =0x00000094 ;
+.PRRAN =0x00000098 ;
+.PRST =0x0000009C ;
+.PRWT =0x000000A0 ;
+.PSCON =0x0000009E ;
+.PSCOP =0x000000A2 ;
+.PSDEL =0x000000A6 ;
+.PSINS =0x000000AA ;
+.PSLEN =0x000000AE ;
+.PSPOS =0x000000B2 ;
+.PSTCV =0x000000B6 ;
+.PSTCVL =0x000000BA ;
+.PSTOS =0x000000BE ;
+.PSTOV =0x000000C2 ;
+.PSTOVL =0x000000C6 ;
+.PSTRS =0x000000CA ;
+.PSTRV =0x000000CE ;
+.PSTRVL =0x000000D2 ;
+.PWLN =0x000000A4 ;
+.PWRAN =0x000000A8 ;
+.PWRB =0x000000AC ;
+.PWRC =0x000000B0 ;
+.PWRH =0x000000B4 ;
+.PWRI =0x000000B8 ;
+.PWRJ =0x000000BC ;
+.PWRS =0x000000C0 ;
+.PWRV =0x000000C4 ;
+
+/*
+.PAFI=0x = 0x00;
+.PCHIO =0x 0x000000;
+.PCLO =0x 64 ;
+.PC;
+.PCVTSU =0x 0x000000;
+.PCVTSV =0x 0x000000;
+.PCVTSVL =0x 0x000000;
+.PCVTUS =0x 158 ;
+.P;
+.PDISL =0x 0x000000;
+.PDVJ =0x 0x000000;
+.PEIO =0x 0x000000;
+.PEOF =0x 0x000000;
+.PEOL =0x 0x000000;
+.PEQUS =0x 0x000000;
+.PEQUV =0x 0x000000;
+.PEQUVL =0x 0x000000;
+.PEQUW =0x 0x000000;
+.PGCM =0x 0x000000;
+.PGEQS =0x 0x000000;
+.PGEQV =0x 0x000000;
+.PGEQVL =0x 0x000000;
+.PGET =0x 0x000000;
+.PGRTS =0x 0x000000;
+.PGRTV =0x 0x000000;
+.PGRTVL =0x 0x000000;
+.PIACT =0x 0x000000;
+.PIFD =0x 126 ;
+.P;
+.PINDV =0x 0x000000;
+.PINDVL =0x 0x000000;
+.PINDW =0x 0x000000;
+.PLDCS =0x 0x000000;
+.PLDCV =0x 0x000000;
+.PLEQS =0x 0x000000;
+.PLEQV =0x 0x000000;
+.PLEQVL =0x 0x000000;
+.PLESS =0x 0x000000;
+.PLESV =0x 0x000000;
+.PLESVL =0x 0x000000;
+.PLODS =0x 0x000000;
+.PLODV =0x 0x000000;
+.PLODVL =0x 0x000000;
+.PMODJ =0x 0x000000;
+.PMOV =0x 0x000000;
+.PMPJ =0x 0x000000;
+.PNEQS =0x 0x000000;
+.PNEQV =0x 0x000000;
+.PNEQVL =0x 0x000000;
+.PNEQW =0x 0x000000;
+.PPAGE =0x 0x000000;
+.PPEE =0x 0x000000;
+.PPUT =0x 0x000000;
+.PRDB =0x 0x000000;
+.PRDC =0x 0x000000;
+.PRDH =0x 0x000000;
+.PRDI =0x 0x000000;
+.PRDJ =0x 0x000000;
+.PRDRS =0x 0x000000;
+.PRDS =0x 0x000000;
+.PRDV =0x 0x000000;
+.PRLN =0x 0x000000;
+.PRRAN =0x 0x000000;
+.PRST =0x 0x000000;
+.PRWT =0x 0x000000;
+.PSCON =0x 0x000000;
+.PSCOP =0x 0x000000;
+.PSDEL =0x 0x000000;
+.PSINS =0x 0x000000;
+.PSLEN =0x 0x000000;
+.PSPOS =0x 0x000000;
+.PSTCV =0x 0x000000;
+.PSTCVL =0x 0x000000;
+.PSTOS =0x 0x000000;
+.PSTOV =0x 0x000000;
+.PSTOVL =0x 0x000000;
+.PSTRS =0x 0x000000;
+.PSTRV =0x 0x000000;
+.PSTRVL =0x 0x000000;
+.PWLN =0x 0x000000;
+.PWRAN =0x 0x000000;
+.PWRB =0x 0x000000;
+.PWRC =0x 0x000000;
+.PWRH =0x 0x000000;
+.PWRI =0x 0x000000;
+.PWRJ =0x 0x000000;
+.PWRS =0x 0x000000;
+.PWRV =0x 0x000000;
+
+*/
+/*
+.P=0x = 0;
+.PCHIO =0x 0xfeedfa;
+.PCLO =0x 0xfeedfa;
+.PCVBSV =0x 0xfeedfa;
+.PCVTSU =0x 0xfeedfa;
+.PCVTSV =0x 0xfeedfa;
+.PCVTSVL =0x 0xfeedfa;
+.PCVTUS =0x 0xfeedfa;
+.PDIS =0x 0xfeedfa;
+.PDISL =0x 0xfeedfa;
+.PDVJ =0x 0xfeedfa;
+.PEIO =0x 0xfeedfa;
+.PEOF =0x 0xfeedfa;
+.PEOL =0x 0xfeedfa;
+.PEQUS =0x 0xfeedfa;
+.PEQUV =0x 0xfeedfa;
+.PEQUVL =0x 0xfeedfa;
+.PEQUW =0x 0xfeedfa;
+.PGCM =0x 0xfeedfa;
+.PGEQS =0x 0xfeedfa;
+.PGEQV =0x 0xfeedfa;
+.PGEQVL =0x 0xfeedfa;
+.PGET =0x 0xfeedfa;
+.PGRTS =0x 0xfeedfa;
+.PGRTV =0x 0xfeedfa;
+.PGRTVL =0x 0xfeedfa;
+.PIACT =0x 0xfeedfa;
+.PIFD =0x 0xfeedfa;
+.PINDS =0x 0xfeedfa;
+.PINDV =0x 0xfeedfa;
+.PINDVL =0x 0xfeedfa;
+.PINDW =0x 0xfeedfa;
+.PLDCS =0x 0xfeedfa;
+.PLDCV =0x 0xfeedfa;
+.PLEQS =0x 0xfeedfa;
+.PLEQV =0x 0xfeedfa;
+.PLEQVL =0x 0xfeedfa;
+.PLESS =0x 0xfeedfa;
+.PLESV =0x 0xfeedfa;
+.PLESVL =0x 0xfeedfa;
+.PLODS =0x 0xfeedfa;
+.PLODV =0x 0xfeedfa;
+.PLODVL =0x 0xfeedfa;
+.PMODJ =0x 0xfeedfa;
+.PMOV =0x 0xfeedfa;
+.PMPJ =0x 0xfeedfa;
+.PNEQS =0x 0xfeedfa;
+.PNEQV =0x 0xfeedfa;
+.PNEQVL = 0xfeedface;
+.PNEQW = 0xfeedface;
+.PPAGE = 0xfeedface;
+.PPEE = 0xfeedface;
+.PPUT = 0xfeedface;
+.PRDB = 0xfeedface;
+.PRDC = 0xfeedface;
+.PRDH = 0xfeedface;
+.PRDI = 0xfeedface;
+.PRDJ = 0xfeedface;
+.PRDRS = 0xfeedface;
+.PRDS = 0xfeedface;
+.PRDV = 0xfeedface;
+.PRLN = 0xfeedface;
+.PRRAN = 0xfeedface;
+.PRST = 0xfeedface;
+.PRWT = 0xfeedface;
+.PSCON = 0xfeedface;
+.PSCOP = 0xfeedface;
+.PSDEL = 0xfeedface;
+.PSINS = 0xfeedface;
+.PSLEN = 0xfeedface;
+.PSPOS = 0xfeedface;
+.PSTCV = 0xfeedface;
+.PSTCVL = 0xfeedface;
+.PSTOS = 0xfeedface;
+.PSTOV = 0xfeedface;
+.PSTOVL = 0xfeedface;
+.PSTRS = 0xfeedface;
+.PSTRV = 0xfeedface;
+.PSTRVL = 0xfeedface;
+.PWLN = 0xfeedface;
+.PWRAN = 0xfeedface;
+.PWRB = 0xfeedface;
+.PWRC = 0xfeedface;
+.PWRH = 0xfeedface;
+.PWRI = 0xfeedface;
+.PWRJ = 0xfeedface;
+.PWRS = 0xfeedface;
+.PWRV = 0xfeedface;
+*/
+
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ook b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ook
new file mode 100644
index 00000000000..3984b94ee5e
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t1.ook
@@ -0,0 +1,133 @@
+S00C000074312E6F75742E6F6BC0
+S118000000000A205341464553544F52452041202020202052BE
+S118001531332E33202020202020205231332E32202020202077
+S118002A202000B5E86600B5E9B11DA15B9900001F0000000A50
+S118003F640000003E0000005C00A800BA00F000040001000251
+S1180054000000000000000000000006004031CF52544C4942D0
+S1180069434F4E0004E5EC52544C4942434F4E0004E5ED5254F0
+S118007E4C4942434F4E004031D252544C4942434F4E00000A08
+S11800937D52544C49425354520010A4A852544C494246494CAD
+S11800A8000200B5E86D0000016000B5E873000002540002006A
+S11800BDB5E937534146455052494E5420000006000200080079
+S11800D20000034200B5E86E494E4954534146455354000002C9
+S11800E71800000E00000009020030000000004E56FFD8BA8FDB
+S11800FC63062E4E6100001641FA003243EEFFD8702612D85149
+S1180111C8FFFC4E5E4E752B57FFF22F3C0000000A6000000259
+S11801263B6F0002FFF62F2D00382F2D00344E4C4E4A434F50E7
+S118013B5952494748542054656C65666F6E204142204C204D6B
+S1180150204572696373736F6E2C2031393933004E56FFFCBAB5
+S11801658F63042E4E61AC202E000C06800000000C4E7656807C
+S118017A4E760280FFFFFFFC4AD56604610000B02D40FFFC200B
+S118018F6C003A2208242C003694814E7604820000000C4E76D2
+S11801A44AD566046100008EB0826E0C0CAE00000001000C6CEB
+S11801B900000C207C0000000061000060206C003A200866046C
+S11801CE610000762208D2AEFFFC68046100005C2081216E0043
+S11801E3100004216E000C0008220806810000000C68046100C2
+S11801F800402D4100142950003A206C003A24086604610000BC
+S118020D3A429042A8000442A800084E5E225F285F508F4EE922
+S118022200022B5FFFF24E5ED1DF285F2F082B48FFF2D0D04EDA
+S1180237D02B57FFF22F3C0000000E6000FEE22B57FFF22F3CD4
+S118024C000000106000FED44E56FFFCBA8F63062E4E6100FE2B
+S1180261B82D6C0032FFFC600000122B5FFFF24FEEFFFC42AEF1
+S1180276FFFC600000824AAEFFFC6700007A206EFFFC200866A7
+S118028B00000461B622280004B2AE001067000062220802810B
+S11802A0000000034A8166402208226C003A2409B2826E3426B6
+S11802B510280806840000000C68046100FF76B6846D2026101B
+S11802CA280896844E7604830000000C4E764AD566046100FFCD
+S11802DF5AB6A800086C0000046182206EFFFC20086604610077
+S11802F4FF522D50FFFC60804AAEFFFC6700002C206EFFFC2019
+S11803090866046100FF38226E000C22A80008220806810000B2
+S118031E000C68046100FF142D4100146000000C206E000C4210
+S11803339042AE00144E5E205F285F508F4ED04FEDFF00707F44
+S1180348204F425851C8FFFC486DFF081F3C00043F3C00019F49
+S118035DFC0000000C224F45FA04FE22DA22DA22DA266C00281F
+S11803722F0C286C002C4EAB0068486DFFB8486DFFB42F0C20E7
+S11803876C0000286C00044E909FFC000000522F2DFFC62F0C32
+S118039C206C0008286C000C4E907052266C00204EAB001E416A
+S11803B1FA04BE266C00204EAB007E266C00204EAB009E41EDD7
+S11803C6FFBA266C00204EAB007E266C00204EAB009E1F3C0098
+S11803DB283F3C0001266C00204EAB009E9FFC00000052302DD2
+S11803F0FFCA48C02F002F0C206C0008286C000C4E90705226BF
+S11804056C00204EAB001E266C00204EAB009E41FA045E266CC3
+S118041A00204EAB007E266C00204EAB009E41EDFF9E70162672
+S118042F6C00204EAB00CA600000162B5FFFF24FEDFF002B7C92
+S118044400000001FFB4600003E4486DFF089FFC0000005220DB
+S11804594F43EDFF9E3019725092406F024241D04130C06F0A23
+S118046E5340E24030D951C8FFFC9FFC00000052224F45FA0303
+S1180483F632DA266C00282F0C286C002C4EAB0050FFAA486D02
+S1180498FF08266C00282F0C286C002C4EAB00A0FF9642ADFF73
+S11804AD002B6C0032FF04487A03C43F3CFFFF486DFF08266C1A
+S11804C200282F0C286C002C4EAB00C0FF70486DFF08266C0088
+S11804D7282F0C286C002C4EAB00A4FF5C600000782B5FFFF29E
+S11804EC4FEDFF00487A03BA3F3CFFFF486DFF08266C00282F1F
+S11805010C286C002C4EAB00C0FF349FFC00000052206DFF04AC
+S118051620082F002F0C206C0010286C00144E902F0F3F3CFF60
+S118052BFF486DFF08266C00282F0C286C002C4EAB00C0FF008F
+S1180540DFFC00000052486DFF08266C00282F0C286C002C4EB6
+S1180555AB00A4FEE6600001F0206DFF042008660261804A902E
+S118056A6700016A22100281000000034A81664A2210242C00F1
+S118057F3604820000000C68046100FCAEB2826E3422102408F0
+S118059406820000000C68046100FC9AB2826D202210240892A6
+S11805A9824E7604810000000C4E764AD566046100FC7EB2A8E0
+S11805BE00086C0000066100FF22206DFF04200866046100FFA6
+S11805D31622280008D2ADFF0068046100FC582B41FF009FFC02
+S11805E80000005224082F022F0C206C0010286C00144E902FBF
+S11805FD0F3F3C000C486DFF08266C00282F0C286C002C4EABE5
+S118061200C0FE2ADFFC00000052206DFF04200866046100FE39
+S1180627C22F2800043F3C000C486DFF08266C00282F0C286CD1
+S118063C002C4EAB00BCFDFC206DFF04200866046100FE9A2F81
+S11806512800083F3C000C486DFF08266C00282F0C286C002C68
+S11806664EAB00BCFDD49FFC00000052206DFF04200866046185
+S118067B00FE6C22102F012F0C206C0010286C00144E902F0FFF
+S11806903F3C000C486DFF08266C00282F0C286C002C4EAB0060
+S11806A5C0FD98DFFC00000052486DFF08266C00282F0C286C75
+S11806BA002C4EAB00A4FD7E206DFF04200866046100FE1C2B1B
+S11806CF50FF046000FE8A206C003AB1EDFF046700006C487ADB
+S11806E401E83F3CFFFF486DFF08266C00282F0C286C002C4EDC
+S11806F9AB00C0FD429FFC00000052206DFF0420082F002F0C2F
+S118070E206C0010286C00144E902F0F3F3CFFFF486DFF082617
+S11807236C00282F0C286C002C4EAB00C0FD0EDFFC000000523D
+S1180738486DFF08266C00282F0C286C002C4EAB00A4FCF44862
+S118074D7A01983F3CFFFF486DFF08266C00282F0C286C002C96
+S11807624EAB00C0FCD8486DFF08266C00282F0C286C002C4E32
+S1180777AB00A4FCC4487A016A3F3CFFFF486DFF08266C00283E
+S118078C2F0C286C002C4EAB00C0FCA8486DFF08266C00282F57
+S11807A10C286C002C4EAB00A4FC94206DFF0420080680000008
+S11807B600184E76222C003692804E760281FFFFFFFC4AD566F3
+S11807CB046100FA6A2F013F3C000C486DFF08266C00282F0CE4
+S11807E0286C002C4EAB00BCFC562F2DFF003F3C000C486DFFA3
+S11807F508266C00282F0C286C002C4EAB00BCFC3A486DFF0887
+S118080A266C00282F0C286C002C4EAB00A4FC26486DFF081F86
+S118081F3C0001266C00282F0C286C002C4EAB0054486DFFB815
+S1180834486DFFB42F0C206C0018286C001C4E90486DFF0842D8
+S118084927266C00282F0C286C002C4EAB005442A72F2D0038F0
+S118085E2F2D00344E4A000A4631202020202020202000023A9C
+S11808733A0002293A0000003020202020204164647265737337
+S1180888202020204964656E746974792020202020202020533A
+S118089D697A6520202020202020204E657874001D496E7661B0
+S11808B26C6964207365676D656E74207374617274696E672035
+S11808C761743A202000185365676D656E74206C69737420637F
+S11808DC6F727275707465643A2000000018202020417661693B
+S11808F16C61626C652020202020202020557365644FEDFFF230
+S11809069FFC0000000A6100015641EC003020DF20DF30DF20F1
+S118091B2C003256804E760280FFFFFFFC4AD566046100F90A63
+S1180930294000322940003A6000003E2B5FFFF24FEDFFF2200A
+S11809452C003256804E760280FFFFFFFC4AD566046100F8E064
+S118095A2940003A206C003A220866046100F8DE429042A80094
+S118096F0442A800086000009E4A2C00306700001A206C003A8E
+S11809842008660261B2429042A8000442A800086000007E2007
+S11809996C003A20086602619A4A906700006E221002810000B0
+S11809AE00034A81664A2210242C003604820000000C6804619B
+S11809C300F874B2826E342210240806820000000C680461001A
+S11809D8F860B2826D202210240892824E7604810000000C4ED8
+S11809ED764AD566046100F844B2A800086C0000066100FF3CE5
+S1180A02206C003A200866046100FF302950003A608442A72F44
+S1180A172D00382F2D00344E4A4E560000518F42A71F3C000E63
+S1180A2C4267487A0012426742272F3C00B5E86E4E49000E50B7
+S1180A418F4E5E205F285F4EE80002207C0000000060042B5F99
+S1180A56FFF24E5ED1DF285F2F08D0D04ED043FA0004D3FC00AE
+S1180A6B02704E2F49000A43FA0004D3FC000000402F49000662
+S1180A8041FA0004D1FCFFFFF57A202800566600002222099201
+S1180A95882141005642812448D25AB5C96DFA4441D368005AAE
+S1110AAA1F7C000100044E75422F00044E759F
+S9030000FC
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-1.ro b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-1.ro
new file mode 100644
index 00000000000..633a7cc8856
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-1.ro
Binary files differ
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-2.ro b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-2.ro
new file mode 100644
index 00000000000..704a79d947f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-2.ro
Binary files differ
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-3.ro b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-3.ro
new file mode 100644
index 00000000000..d95934218d2
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2-3.ro
Binary files differ
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ld b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ld
new file mode 100644
index 00000000000..5e1e413d160
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ld
@@ -0,0 +1,281 @@
+OUTPUT_FORMAT("srec")
+SECTIONS
+{
+
+
+.text 0 : { *("9") *("10") *("11") *("12") *("13") *("14") *("15")
+ *("7") *("8") *("0") *("1") *("2") *("3") *("4") }
+.bss : { *("5") *("6") }
+
+.PAFI =0x00000050 ;
+.PCHIO =0x000000D0 ;
+.PCLO =0x00000054 ;
+.PCVBSV =0x0000000E ;
+.PCVTSU =0x00000012 ;
+.PCVTSV =0x00000016 ;
+.PCVTSVL =0x0000001A ;
+.PCVTUS =0x0000001E ;
+.PDIS =0x00000022 ;
+.PDISL =0x00000026 ;
+.PDVJ =0x0000002A ;
+.PEIO =0x000000CC ;
+.PEOF =0x00000058 ;
+.PEOL =0x0000005C ;
+.PEQUS =0x0000002E ;
+.PEQUV =0x00000032 ;
+.PEQUVL =0x00000036 ;
+.PEQUW =0x000000DE ;
+.PGCM =0x00000064 ;
+.PGEQS =0x0000003A ;
+.PGEQV =0x0000003E ;
+.PGEQVL =0x00000042 ;
+.PGET =0x00000060 ;
+.PGRTS =0x00000046 ;
+.PGRTV =0x0000004A ;
+.PGRTVL =0x0000004E ;
+.PIACT =0x0000006C ;
+.PIFD =0x00000068 ;
+.PINDS =0x00000052 ;
+.PINDV =0x00000056 ;
+.PINDVL =0x0000005A ;
+.PINDW =0x000000D6 ;
+.PLDCS =0x0000005E ;
+.PLDCV =0x00000062 ;
+.PLEQS =0x00000066 ;
+.PLEQV =0x0000006A ;
+.PLEQVL =0x0000006E ;
+.PLESS =0x00000072 ;
+.PLESV =0x00000076 ;
+.PLESVL =0x0000007A ;
+.PLODS =0x0000007E ;
+.PLODV =0x00000082 ;
+.PLODVL =0x00000086 ;
+.PMODJ =0x0000008A ;
+.PMOV =0x000000E2 ;
+.PMPJ =0x0000008E ;
+.PNEQS =0x00000092 ;
+.PNEQV =0x00000096 ;
+.PNEQVL =0x0000009A ;
+.PNEQW =0x000000DA ;
+.PPAGE =0x000000D4 ;
+.PPEE =0x00000070 ;
+.PPUT =0x00000074 ;
+.PRDB =0x00000078 ;
+.PRDC =0x0000007C ;
+.PRDH =0x00000080 ;
+.PRDI =0x00000084 ;
+.PRDJ =0x00000088 ;
+.PRDRS =0x000000C8 ;
+.PRDS =0x0000008C ;
+.PRDV =0x00000090 ;
+.PRLN =0x00000094 ;
+.PRRAN =0x00000098 ;
+.PRST =0x0000009C ;
+.PRWT =0x000000A0 ;
+.PSCON =0x0000009E ;
+.PSCOP =0x000000A2 ;
+.PSDEL =0x000000A6 ;
+.PSINS =0x000000AA ;
+.PSLEN =0x000000AE ;
+.PSPOS =0x000000B2 ;
+.PSTCV =0x000000B6 ;
+.PSTCVL =0x000000BA ;
+.PSTOS =0x000000BE ;
+.PSTOV =0x000000C2 ;
+.PSTOVL =0x000000C6 ;
+.PSTRS =0x000000CA ;
+.PSTRV =0x000000CE ;
+.PSTRVL =0x000000D2 ;
+.PWLN =0x000000A4 ;
+.PWRAN =0x000000A8 ;
+.PWRB =0x000000AC ;
+.PWRC =0x000000B0 ;
+.PWRH =0x000000B4 ;
+.PWRI =0x000000B8 ;
+.PWRJ =0x000000BC ;
+.PWRS =0x000000C0 ;
+.PWRV =0x000000C4 ;
+
+/*
+.PAFI=0x = 0x00;
+.PCHIO =0x 0x000000;
+.PCLO =0x 64 ;
+.PC;
+.PCVTSU =0x 0x000000;
+.PCVTSV =0x 0x000000;
+.PCVTSVL =0x 0x000000;
+.PCVTUS =0x 158 ;
+.P;
+.PDISL =0x 0x000000;
+.PDVJ =0x 0x000000;
+.PEIO =0x 0x000000;
+.PEOF =0x 0x000000;
+.PEOL =0x 0x000000;
+.PEQUS =0x 0x000000;
+.PEQUV =0x 0x000000;
+.PEQUVL =0x 0x000000;
+.PEQUW =0x 0x000000;
+.PGCM =0x 0x000000;
+.PGEQS =0x 0x000000;
+.PGEQV =0x 0x000000;
+.PGEQVL =0x 0x000000;
+.PGET =0x 0x000000;
+.PGRTS =0x 0x000000;
+.PGRTV =0x 0x000000;
+.PGRTVL =0x 0x000000;
+.PIACT =0x 0x000000;
+.PIFD =0x 126 ;
+.P;
+.PINDV =0x 0x000000;
+.PINDVL =0x 0x000000;
+.PINDW =0x 0x000000;
+.PLDCS =0x 0x000000;
+.PLDCV =0x 0x000000;
+.PLEQS =0x 0x000000;
+.PLEQV =0x 0x000000;
+.PLEQVL =0x 0x000000;
+.PLESS =0x 0x000000;
+.PLESV =0x 0x000000;
+.PLESVL =0x 0x000000;
+.PLODS =0x 0x000000;
+.PLODV =0x 0x000000;
+.PLODVL =0x 0x000000;
+.PMODJ =0x 0x000000;
+.PMOV =0x 0x000000;
+.PMPJ =0x 0x000000;
+.PNEQS =0x 0x000000;
+.PNEQV =0x 0x000000;
+.PNEQVL =0x 0x000000;
+.PNEQW =0x 0x000000;
+.PPAGE =0x 0x000000;
+.PPEE =0x 0x000000;
+.PPUT =0x 0x000000;
+.PRDB =0x 0x000000;
+.PRDC =0x 0x000000;
+.PRDH =0x 0x000000;
+.PRDI =0x 0x000000;
+.PRDJ =0x 0x000000;
+.PRDRS =0x 0x000000;
+.PRDS =0x 0x000000;
+.PRDV =0x 0x000000;
+.PRLN =0x 0x000000;
+.PRRAN =0x 0x000000;
+.PRST =0x 0x000000;
+.PRWT =0x 0x000000;
+.PSCON =0x 0x000000;
+.PSCOP =0x 0x000000;
+.PSDEL =0x 0x000000;
+.PSINS =0x 0x000000;
+.PSLEN =0x 0x000000;
+.PSPOS =0x 0x000000;
+.PSTCV =0x 0x000000;
+.PSTCVL =0x 0x000000;
+.PSTOS =0x 0x000000;
+.PSTOV =0x 0x000000;
+.PSTOVL =0x 0x000000;
+.PSTRS =0x 0x000000;
+.PSTRV =0x 0x000000;
+.PSTRVL =0x 0x000000;
+.PWLN =0x 0x000000;
+.PWRAN =0x 0x000000;
+.PWRB =0x 0x000000;
+.PWRC =0x 0x000000;
+.PWRH =0x 0x000000;
+.PWRI =0x 0x000000;
+.PWRJ =0x 0x000000;
+.PWRS =0x 0x000000;
+.PWRV =0x 0x000000;
+
+*/
+/*
+.P=0x = 0;
+.PCHIO =0x 0xfeedfa;
+.PCLO =0x 0xfeedfa;
+.PCVBSV =0x 0xfeedfa;
+.PCVTSU =0x 0xfeedfa;
+.PCVTSV =0x 0xfeedfa;
+.PCVTSVL =0x 0xfeedfa;
+.PCVTUS =0x 0xfeedfa;
+.PDIS =0x 0xfeedfa;
+.PDISL =0x 0xfeedfa;
+.PDVJ =0x 0xfeedfa;
+.PEIO =0x 0xfeedfa;
+.PEOF =0x 0xfeedfa;
+.PEOL =0x 0xfeedfa;
+.PEQUS =0x 0xfeedfa;
+.PEQUV =0x 0xfeedfa;
+.PEQUVL =0x 0xfeedfa;
+.PEQUW =0x 0xfeedfa;
+.PGCM =0x 0xfeedfa;
+.PGEQS =0x 0xfeedfa;
+.PGEQV =0x 0xfeedfa;
+.PGEQVL =0x 0xfeedfa;
+.PGET =0x 0xfeedfa;
+.PGRTS =0x 0xfeedfa;
+.PGRTV =0x 0xfeedfa;
+.PGRTVL =0x 0xfeedfa;
+.PIACT =0x 0xfeedfa;
+.PIFD =0x 0xfeedfa;
+.PINDS =0x 0xfeedfa;
+.PINDV =0x 0xfeedfa;
+.PINDVL =0x 0xfeedfa;
+.PINDW =0x 0xfeedfa;
+.PLDCS =0x 0xfeedfa;
+.PLDCV =0x 0xfeedfa;
+.PLEQS =0x 0xfeedfa;
+.PLEQV =0x 0xfeedfa;
+.PLEQVL =0x 0xfeedfa;
+.PLESS =0x 0xfeedfa;
+.PLESV =0x 0xfeedfa;
+.PLESVL =0x 0xfeedfa;
+.PLODS =0x 0xfeedfa;
+.PLODV =0x 0xfeedfa;
+.PLODVL =0x 0xfeedfa;
+.PMODJ =0x 0xfeedfa;
+.PMOV =0x 0xfeedfa;
+.PMPJ =0x 0xfeedfa;
+.PNEQS =0x 0xfeedfa;
+.PNEQV =0x 0xfeedfa;
+.PNEQVL = 0xfeedface;
+.PNEQW = 0xfeedface;
+.PPAGE = 0xfeedface;
+.PPEE = 0xfeedface;
+.PPUT = 0xfeedface;
+.PRDB = 0xfeedface;
+.PRDC = 0xfeedface;
+.PRDH = 0xfeedface;
+.PRDI = 0xfeedface;
+.PRDJ = 0xfeedface;
+.PRDRS = 0xfeedface;
+.PRDS = 0xfeedface;
+.PRDV = 0xfeedface;
+.PRLN = 0xfeedface;
+.PRRAN = 0xfeedface;
+.PRST = 0xfeedface;
+.PRWT = 0xfeedface;
+.PSCON = 0xfeedface;
+.PSCOP = 0xfeedface;
+.PSDEL = 0xfeedface;
+.PSINS = 0xfeedface;
+.PSLEN = 0xfeedface;
+.PSPOS = 0xfeedface;
+.PSTCV = 0xfeedface;
+.PSTCVL = 0xfeedface;
+.PSTOS = 0xfeedface;
+.PSTOV = 0xfeedface;
+.PSTOVL = 0xfeedface;
+.PSTRS = 0xfeedface;
+.PSTRV = 0xfeedface;
+.PSTRVL = 0xfeedface;
+.PWLN = 0xfeedface;
+.PWRAN = 0xfeedface;
+.PWRB = 0xfeedface;
+.PWRC = 0xfeedface;
+.PWRH = 0xfeedface;
+.PWRI = 0xfeedface;
+.PWRJ = 0xfeedface;
+.PWRS = 0xfeedface;
+.PWRV = 0xfeedface;
+*/
+
+}
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ook b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ook
new file mode 100644
index 00000000000..03f24a5f8f8
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/t2.ook
@@ -0,0 +1,99 @@
+S0120000696E6974746573745F6570632E7372CF
+S118000000000000494E495454455354202050413035202052AB
+S118001531332E33202020202020205231332E32202020202077
+S118002A202000934B5B00B5E6C11B089DD600005400000005F9
+S118003F5A00000048005C00A60000010A0126000400010002CB
+S1180054009000000000000000000002004020200000494F5F8A
+S11800695245534552564152544C4942434F4E0040484501003B
+S118007E505F414C4C202020202052544C4942434F4E010000E3
+S118009300009C01000000000000085345504152415445000852
+S11800A80008004031CF52544C4942434F4E0004E5EC52544CD3
+S11800BD4942434F4E00B5E86D5341464553544F5200004F28D7
+S11800D253595354454D494D00B5E8735341464553544F520023
+S11800E74031D252544C4942434F4E00000A7D52544C49425309
+S11800FC54520010A4A852544C494246494C000100B5E6C049EC
+S11801114E495454455354202000000616020008000000023210
+S11801260048000000004E56FFF0BA8F63062E4E610000BC4159
+S118013BFA00F443EEFFF032D82D7C00000001FFFC206E000858
+S118015020086604610000BA222EFFFC53814A816C046100002E
+S11801659E2248D3E9FFFC41F01800B3C863EE4A1066000006E7
+S118017A6000006241EEFFF0266C00384EAB007E206E00082095
+S118018F0866046100007C222EFFFC53814A816C0461000060ED
+S11801A42248D3E9FFFC41F01800B3C863EE1F103F3C0001263B
+S11801B96C00384EAB009E41EEFFF0700C266C00384EAB00CACB
+S11801CE52AEFFFC0CAE0000000AFFFC6F00FF7041EEFFF0431F
+S11801E3EE000C22D822D822D84E5E205F588F4ED02B57FFF278
+S11801F82F3C0000000A6000001E2B57FFF22F3C0000000F60AE
+S118020D0000102B57FFF22F3C00000010600000023B6F0002CC
+S1180222FFF62F2D00382F2D00344E4C4E4A00004FEDFEEA2034
+S11802373C0000008A204F425851C8FFFC486DFEEA1F3C0004CF
+S118024C3F3C00019FFC0000000C224F45FA02D422DA22DA22D6
+S1180261DA266C00402F0C286C00444EAB0068486DFFB8486D43
+S1180276FFB42F0C206C0008286C000C4E909FFC000000522F53
+S118028B2DFFC62F0C206C0010286C00144E907052266C00387F
+S11802A04EAB001E41FA0294266C00384EAB007E266C00384E04
+S11802B5AB009E41EDFFBA266C00384EAB007E266C00384EABFC
+S11802CA009E1F3C00283F3C0001266C00384EAB009E9FFC0082
+S11802DF000052302DFFCA48C02F002F0C206C0010286C0014D8
+S11802F44E907052266C00384EAB001E266C00384EAB009E41CE
+S1180309FA0234266C00384EAB007E266C00384EAB009E41EDDB
+S118031EFF807016266C00384EAB00CA9FFC0000000E61000228
+S11803332841EDFF9E20DF20DF20DF30DF4A2DFF9E6700003AFD
+S1180348598F2F2DFFA02F2DFFA82F0C206C0018286C001C4ED9
+S118035D9001B82B5FFF9A2F2DFF9A2F2DFFA42F2DFFA82F0CE9
+S1180372206C0020286C00244E9060000034598F2F2DFFA04871
+S11803876DFFA82F0C206C0028286C002C4E902B5FFF962F2D41
+S118039CFFA42F2DFF962F2DFFA82F0C206C0020286C00244EC4
+S11803B190486DFEEA9FFC00000052204F43EDFF8030197250F0
+S11803C692406F024241D04130C06F0A5340E24030D951C8FF08
+S11803DBFC9FFC00000052224F45FA015C32DA266C00402F0CFA
+S11803F0286C00444EAB0050012C486DFEEA266C00402F0C28D4
+S11804056C00444EAB00A00118487A01343F3CFFFF486DFEEA6F
+S118041A266C00402F0C286C00444EAB00C000FC486DFEEA266C
+S118042F6C00402F0C286C00444EAB00A400E842ADFFB02B7C2B
+S118044400000001FFAC598F2F2DFFAC6100017E2B5FFFB02BC0
+S118045940FFB02F2DFFAC3F3C000A486DFEEA266C00402F0C65
+S118046E286C00444EAB00BC00AE9FFC0000000C2F2DFFB06127
+S118048300FCA82F0F3F3C000A486DFEEA266C00402F0C286CBB
+S118049800444EAB00C00086DFFC0000000C486DFEEA266C00B2
+S11804AD402F0C286C00444EAB00A4006C52ADFFAC0CAD000077
+S11804C2000AFFAC6F82486DFEEA1F3C0001266C00402F0C284D
+S11804D76C00444EAB0054486DFFB8486DFFB42F0C206C003044
+S11804EC286C00344E90486DFEEA4227266C00402F0C286C00AA
+S1180501444EAB005442A72F2D00382F2D00344E4A2B57FFF238
+S11805162F3C0000000C6000FD002B57FFF22F3C000000646056
+S118052B00FCF2000A4631202020202020202000023A3A0002D0
+S1180540293A000000142020202020204361736520202020521D
+S11805556573756C7441FA0004D1FCFFFFFAA02028003C43FAFB
+S118056A0004D3FC000001D645FA0004D5FC0000025E260A58D2
+S118057F8AD0885580222800566600002E2408265AD5B0B8008F
+S1180594B5C06DF6220992882141005642812648D25BB7C96D2E
+S11805A9FA4441D368005A123C00016000000442411F4100048B
+S11805BE2F68003400062F49000A96892F43000E4E754E56FFCC
+S11805D3F0202E000847FA0004D7FC000001A6220B41FA00049E
+S11805E8D1FC000001B62D58FFF02D58FFF42D58FFF82D50FF92
+S11805FDFC53807408B4806500012C41FA0004D1FC0000000EBA
+S1180612D080303008004EFB00020012002200320042004800DC
+S118062758006C00A000DC41FA0004D1FC0000011820106000C5
+S118063C010247FA0004D7FC0000010C200B600000F241FA00C5
+S118065104D1FC000001102010600000E22001600000DC47FA9E
+S11806660004D7FC00000120200B600000CC43FA0004D3FC001C
+S118067B0000FA41E9000C2010600000B8242EFFF447FA000464
+S1180690D7FC000000FEB48B6600001247FA0004D7FC000001B0
+S11806A514200B6000009447FA0004D7FC0000010A200B60005B
+S11806BA008441FA0004D1FC0000008A205047FA0004D7FC0085
+S11806CF000082B1CB6600001247FA0004D7FC000000E0200B79
+S11806E46000005847FA0004D7FC000000D2200B600000484147
+S11806F9FA0004D1FC0000004E43FA0004D3FC0000003EB3D0FE
+S118070E6600001247FA0004D7FC000000AE200B6000001E47A4
+S1180723FA0004D7FC000000A6200B6000000E47FA0004D7FC95
+S118073800000098200B4E5E4E740004000053756E65000000D8
+S118074D0007464F74746F00000000000A0000000C50656C6CFD
+S118076265000000075E5374696E61004B6172696E00000000C0
+S11807770500000768000000030000076E5075747465004B61BF
+S118078C6C6C65005374696E613100004B6172696E31000000C1
+S11807A1000033000007900000001F0000079878797A7A0000D2
+S11807B64F6C6C650000370038005065746572005376756C6C19
+S11807CB6F00003900536C75740000000000000000074C000072
+S11507E007640000077800000780000007A4000007AC34
+S9030000FC
diff --git a/gnu/usr.bin/binutils/ld/testsuite/ld-versados/versados.exp b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/versados.exp
new file mode 100644
index 00000000000..fde5e183c0f
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/ld-versados/versados.exp
@@ -0,0 +1,99 @@
+# Expect script for ld-versados tests
+# Copyright (C) 1995 Free Software Foundation
+#
+# 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
+# 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.
+#
+# Written by Steve Chamberlain (sac@cygnus.com)
+#
+
+# Make sure that ld can read versados images and
+# generate binaries which are identical to the customer's
+# old method.
+
+# This test can only be run if ld generates native executables.
+
+# This test can only be run on 68k coff targets
+# Square bracket expressions seem to confuse istarget.
+if { ![istarget m68k-*-coff*] } then {
+ return
+}
+
+set testname "LD VERSADOS"
+
+
+proc inspect { whichone } {
+ global objdump
+ global exec_output
+ global srcdir
+ global subdir
+ global testname
+
+ send_log "$objdump -s tmpdir/$whichone.out >tmpdir/$whichone.dump\n"
+ catch "exec $objdump -s tmpdir/$whichone.out | grep -v srec >tmpdir/$whichone.dump" exec_output
+
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ unresolved $testname
+ return 0
+ }
+
+ send_log "$objdump -s $srcdir$subdir/$whichone.ook >tmpdir/$whichone.dok\n"
+ catch "exec $objdump -s $srcdir$subdir/$whichone.ook | grep -v srec >tmpdir/$whichone.dok" exec_output
+
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ unresolved $testname
+ return 0
+ }
+
+ # compare it with the correct output
+ catch "exec diff tmpdir/$whichone.dump tmpdir/$whichone.dok" exec_output
+ if ![string match "" $exec_output] {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ fail $testname
+ return 0
+ }
+
+ return 1
+}
+
+if ![ld_simple_link $ld tmpdir/t1.out \
+ " -T $srcdir$subdir/t1.ld $srcdir$subdir/t1-1.ro $srcdir$subdir/t1-2.ro"] {
+ fail $testname
+ return
+} else {
+ # Get a dump of what we've got, and what we should have
+ if ![inspect t1] {
+ return
+ }
+}
+
+
+if ![ld_simple_link $ld tmpdir/t2.out \
+ " -T $srcdir$subdir/t2.ld $srcdir$subdir/t2-2.ro \
+ $srcdir$subdir/t2-1.ro $srcdir$subdir/t2-3.ro"] {
+ fail $testname
+ return
+} else {
+ # Get a dump of what we've got, and what we should have
+ if ![inspect t2] {
+ return
+ }
+}
+
+pass $testname
diff --git a/gnu/usr.bin/binutils/ld/testsuite/lib/ld.exp b/gnu/usr.bin/binutils/ld/testsuite/lib/ld.exp
new file mode 100644
index 00000000000..a6dfdb03d0b
--- /dev/null
+++ b/gnu/usr.bin/binutils/ld/testsuite/lib/ld.exp
@@ -0,0 +1,337 @@
+#
+# default_ld_version
+# extract and print the version number of ld
+#
+proc default_ld_version { ld } {
+ global host_triplet
+
+ if { [which $ld] == 0 } then {
+ perror "$ld does not exist"
+ exit 1
+ }
+
+ catch "exec $ld --version" tmp
+ set tmp [prune_system_crud $host_triplet $tmp]
+ regexp "version.*$" $tmp version
+
+ if [info exists version] then {
+ clone_output "$ld $version\n"
+ }
+}
+
+#
+# default_ld_relocate
+# link an object using relocation
+#
+proc default_ld_relocate { ld target objects } {
+ global HOSTING_EMU
+ global host_triplet
+
+ if { [which $ld] == 0 } then {
+ perror "$ld does not exist"
+ return 0
+ }
+
+ send_log "$ld $HOSTING_EMU -o $target -r $objects\n"
+ verbose "$ld $HOSTING_EMU -o $target -r $objects"
+
+ catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ return 0
+ }
+}
+
+
+#
+# default_ld_link
+# link a program using ld
+#
+proc default_ld_link { ld target objects } {
+ global HOSTING_EMU
+ global HOSTING_CRT0
+ global HOSTING_LIBS
+ global host_triplet
+
+ set objs "$HOSTING_CRT0 $objects"
+ set libs "$HOSTING_LIBS"
+
+ if { [which $ld] == 0 } then {
+ perror "$ld does not exist"
+ return 0
+ }
+
+ send_log "$ld $HOSTING_EMU -o $target $objs $libs\n"
+ verbose "$ld $HOSTING_EMU -o $target $objs $libs"
+
+ catch "exec $ld $HOSTING_EMU -o $target $objs $libs" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ return 0
+ }
+}
+
+#
+# default_ld_simple_link
+# link a program using ld, without including any libraries
+#
+proc default_ld_simple_link { ld target objects } {
+ global host_triplet
+
+ if { [which $ld] == 0 } then {
+ perror "$ld does not exist"
+ return 0
+ }
+
+ send_log "$ld -o $target $objects\n"
+ verbose "$ld -o $target $objects"
+
+ catch "exec $ld -o $target $objects" exec_output
+ set exec_output [prune_system_crud $host_triplet $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.
+ regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ return 0
+ }
+}
+
+#
+# default_ld_compile
+# compile an object using cc
+#
+proc default_ld_compile { cc source object } {
+ global CFLAGS
+ global srcdir
+ global subdir
+ global host_triplet
+
+ set cc_prog $cc
+ if {[llength $cc_prog] > 1} then {
+ set cc_prog [lindex $cc_prog 0]
+ }
+ if {[which $cc_prog] == 0} then {
+ perror "$cc_prog does not exist"
+ return 0
+ }
+
+ catch "exec rm -f $object" exec_output
+
+ send_log "$cc -I$srcdir$subdir -c $CFLAGS $source -o $object\n"
+ verbose "$cc -I$srcdir$subdir -c $CFLAGS $source -o $object"
+
+ catch "exec $cc -I$srcdir$subdir -c $CFLAGS $source -o $object" exec_output
+ set exec_output [prune_system_crud $host_triplet $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 {
+ send_log "mv $realobj $object\n"
+ verbose "mv $realobj $object"
+ catch "exec mv $realobj $object" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if {![string match "" $exec_output]} then {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ perror "could not move $realobj to $object"
+ return 0
+ }
+ } else {
+ perror "$object not found after compilation"
+ return 0
+ }
+ }
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ perror "$source: compilation failed"
+ return 0
+ }
+}
+
+#
+# default_ld_assemble
+# assemble a file
+#
+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 "" }
+
+ send_log "$as $ASFLAGS -o $object $source\n"
+ verbose "$as $ASFLAGS -o $object $source"
+
+ catch "exec $as $ASFLAGS -o $object $source" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ perror "$source: assembly failed"
+ return 0
+ }
+}
+
+#
+# default_ld_nm
+# run nm on a file, putting the result in the array nm_output
+#
+proc default_ld_nm { nm object } {
+ global NMFLAGS
+ global nm_output
+ global host_triplet
+
+ if {[which $nm] == 0} then {
+ perror "$nm does not exist"
+ return 0
+ }
+
+ if ![info exists NMFLAGS] { set NMFLAGS "" }
+
+ send_log "$nm $NMFLAGS $object >tmpdir/nm.out\n"
+ verbose "$nm $NMFLAGS $object >tmpdir/nm.out"
+
+ catch "exec $nm $NMFLAGS $object >tmpdir/nm.out" exec_output
+ set exec_output [prune_system_crud $host_triplet $exec_output]
+ if [string match "" $exec_output] then {
+ set file [open tmpdir/nm.out r]
+ while { [gets $file line] != -1 } {
+ verbose "$line" 2
+ if [regexp "^(\[0-9a-fA-F\]+) \[a-zA-Z0-9\] (.+)$" $line whole value name] {
+ verbose "Setting nm_output($name) to 0x$value" 2
+ set nm_output($name) 0x$value
+ }
+ }
+ close $file
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ perror "$object: nm failed"
+ return 0
+ }
+}
+
+#
+# simple_diff
+# compares two files line-by-line
+# returns differences if exist
+# returns null if file(s) cannot be opened
+#
+proc simple_diff { file_1 file_2 } {
+ global target
+
+ set eof -1
+ set differences 0
+
+ if [file exists $file_1] then {
+ set file_a [open $file_1 r]
+ } else {
+ warning "$file_1 doesn't exist"
+ return
+ }
+
+ if [file exists $file_2] then {
+ set file_b [open $file_2 r]
+ } else {
+ fail "$file_2 doesn't exist"
+ return
+ }
+
+ verbose "# Diff'ing: $file_1 $file_2\n" 2
+
+ while { [gets $file_a line] != $eof } {
+ if [regexp "^#.*$" $line] then {
+ continue
+ } else {
+ lappend list_a $line
+ }
+ }
+ close $file_a
+
+ while { [gets $file_b line] != $eof } {
+ if [regexp "^#.*$" $line] then {
+ continue
+ } else {
+ lappend list_b $line
+ }
+ }
+ close $file_b
+
+ for { set i 0 } { $i < [llength $list_a] } { incr i } {
+ set line_a [lindex $list_a $i]
+ set line_b [lindex $list_b $i]
+
+ verbose "\t$file_1: $i: $line_a\n" 3
+ verbose "\t$file_2: $i: $line_b\n" 3
+ if [string compare $line_a $line_b] then {
+ verbose "\t$file_1: $i: $line_a\n" 1
+ verbose "\t$file_2: $i: $line_b\n" 1
+
+ send_log "\t$file_1: $i: $line_a\n"
+ send_log "\t$file_2: $i: $line_b\n"
+
+ fail "Test: $target"
+ return
+ }
+ }
+
+ if { [llength $list_a] != [llength $list_b] } {
+ fail "Test: $target"
+ return
+ }
+
+ if $differences<1 then {
+ pass "Test: $target"
+ }
+}
+
+# This definition is taken from an unreleased version of DejaGnu. Once
+# that version gets released, and has been out in the world for a few
+# months at least, it may be safe to delete this copy.
+if ![string length [info proc prune_system_crud]] {
+ #
+ # prune_system_crud -- delete various system verbosities from TEXT on SYSTEM
+ #
+ # An example is:
+ # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9
+ #
+ # SYSTEM is typical $target_triplet or $host_triplet.
+ #
+ # This is useful when trying to do pattern matches on program output.
+ # Sites with particular verbose os's may wish to override this in site.exp.
+ #
+ proc prune_system_crud { system text } {
+ # This is from sun4's. Do it for all machines for now.
+ # The "\\1" is to try to preserve a "\n" but only if necessary.
+ regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
+
+ # It might be tempting to get carried away and delete blank lines, etc.
+ # Just delete *exactly* what we're ask to, and that's it.
+ return $text
+ }
+}