summaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog731
-rw-r--r--ld/testsuite/config/default.exp171
-rw-r--r--ld/testsuite/ld-bootstrap/bootstrap.exp103
-rw-r--r--ld/testsuite/ld-cdtest/cdtest-bar.cc17
-rw-r--r--ld/testsuite/ld-cdtest/cdtest-foo.cc89
-rw-r--r--ld/testsuite/ld-cdtest/cdtest-foo.h24
-rw-r--r--ld/testsuite/ld-cdtest/cdtest-main.cc40
-rw-r--r--ld/testsuite/ld-cdtest/cdtest.dat15
-rw-r--r--ld/testsuite/ld-cdtest/cdtest.exp100
-rw-r--r--ld/testsuite/ld-checks/asm.s14
-rw-r--r--ld/testsuite/ld-checks/checks.exp72
-rw-r--r--ld/testsuite/ld-checks/script6
-rw-r--r--ld/testsuite/ld-elfvers/vers.exp808
-rw-r--r--ld/testsuite/ld-elfvers/vers1.c98
-rw-r--r--ld/testsuite/ld-elfvers/vers1.dsym9
-rw-r--r--ld/testsuite/ld-elfvers/vers1.map16
-rw-r--r--ld/testsuite/ld-elfvers/vers1.sym4
-rw-r--r--ld/testsuite/ld-elfvers/vers1.ver8
-rw-r--r--ld/testsuite/ld-elfvers/vers13.asym10
-rw-r--r--ld/testsuite/ld-elfvers/vers15.c35
-rw-r--r--ld/testsuite/ld-elfvers/vers15.dsym5
-rw-r--r--ld/testsuite/ld-elfvers/vers15.sym3
-rw-r--r--ld/testsuite/ld-elfvers/vers15.ver5
-rw-r--r--ld/testsuite/ld-elfvers/vers16.c10
-rw-r--r--ld/testsuite/ld-elfvers/vers16.dsym2
-rw-r--r--ld/testsuite/ld-elfvers/vers16.map3
-rw-r--r--ld/testsuite/ld-elfvers/vers16a.c8
-rw-r--r--ld/testsuite/ld-elfvers/vers16a.dsym3
-rw-r--r--ld/testsuite/ld-elfvers/vers16a.ver3
-rw-r--r--ld/testsuite/ld-elfvers/vers2.c10
-rw-r--r--ld/testsuite/ld-elfvers/vers2.dsym3
-rw-r--r--ld/testsuite/ld-elfvers/vers2.map4
-rw-r--r--ld/testsuite/ld-elfvers/vers2.ver8
-rw-r--r--ld/testsuite/ld-elfvers/vers3.c10
-rw-r--r--ld/testsuite/ld-elfvers/vers3.dsym1
-rw-r--r--ld/testsuite/ld-elfvers/vers3.ver4
-rw-r--r--ld/testsuite/ld-elfvers/vers4.c27
-rw-r--r--ld/testsuite/ld-elfvers/vers4.sym1
-rw-r--r--ld/testsuite/ld-elfvers/vers4a.dsym2
-rw-r--r--ld/testsuite/ld-elfvers/vers4a.sym1
-rw-r--r--ld/testsuite/ld-elfvers/vers4a.ver4
-rw-r--r--ld/testsuite/ld-elfvers/vers5.c51
-rw-r--r--ld/testsuite/ld-elfvers/vers6.c19
-rw-r--r--ld/testsuite/ld-elfvers/vers6.dsym4
-rw-r--r--ld/testsuite/ld-elfvers/vers6.sym4
-rw-r--r--ld/testsuite/ld-elfvers/vers6.ver6
-rw-r--r--ld/testsuite/ld-elfvers/vers7.c11
-rw-r--r--ld/testsuite/ld-elfvers/vers7.map6
-rw-r--r--ld/testsuite/ld-elfvers/vers7a.c18
-rw-r--r--ld/testsuite/ld-elfvers/vers7a.dsym2
-rw-r--r--ld/testsuite/ld-elfvers/vers7a.sym2
-rw-r--r--ld/testsuite/ld-elfvers/vers7a.ver4
-rw-r--r--ld/testsuite/ld-elfvers/vers8.c5
-rw-r--r--ld/testsuite/ld-elfvers/vers8.map18
-rw-r--r--ld/testsuite/ld-elfvers/vers8.ver8
-rw-r--r--ld/testsuite/ld-elfvers/vers9.c45
-rw-r--r--ld/testsuite/ld-elfvers/vers9.dsym4
-rw-r--r--ld/testsuite/ld-elfvers/vers9.sym4
-rw-r--r--ld/testsuite/ld-elfvers/vers9.ver5
-rw-r--r--ld/testsuite/ld-empic/empic.exp263
-rw-r--r--ld/testsuite/ld-empic/relax.t49
-rw-r--r--ld/testsuite/ld-empic/relax1.c22
-rw-r--r--ld/testsuite/ld-empic/relax2.c19
-rw-r--r--ld/testsuite/ld-empic/relax3.c3
-rw-r--r--ld/testsuite/ld-empic/relax4.c3
-rw-r--r--ld/testsuite/ld-empic/run.c160
-rw-r--r--ld/testsuite/ld-empic/runtest1.c117
-rw-r--r--ld/testsuite/ld-empic/runtest2.c26
-rw-r--r--ld/testsuite/ld-empic/runtesti.s94
-rw-r--r--ld/testsuite/ld-scripts/cross1.c6
-rw-r--r--ld/testsuite/ld-scripts/cross1.t6
-rw-r--r--ld/testsuite/ld-scripts/cross2.c5
-rw-r--r--ld/testsuite/ld-scripts/cross2.t6
-rw-r--r--ld/testsuite/ld-scripts/cross3.c7
-rw-r--r--ld/testsuite/ld-scripts/crossref.exp77
-rw-r--r--ld/testsuite/ld-scripts/defined.exp39
-rw-r--r--ld/testsuite/ld-scripts/defined.s2
-rw-r--r--ld/testsuite/ld-scripts/defined.t7
-rw-r--r--ld/testsuite/ld-scripts/phdrs.exp57
-rw-r--r--ld/testsuite/ld-scripts/phdrs.s8
-rw-r--r--ld/testsuite/ld-scripts/phdrs.t14
-rw-r--r--ld/testsuite/ld-scripts/script.exp64
-rw-r--r--ld/testsuite/ld-scripts/script.s8
-rw-r--r--ld/testsuite/ld-scripts/script.t16
-rw-r--r--ld/testsuite/ld-scripts/scriptm.t10
-rw-r--r--ld/testsuite/ld-scripts/sizeof.exp55
-rw-r--r--ld/testsuite/ld-scripts/sizeof.s1
-rw-r--r--ld/testsuite/ld-scripts/sizeof.t17
-rw-r--r--ld/testsuite/ld-scripts/weak.exp57
-rw-r--r--ld/testsuite/ld-scripts/weak.t12
-rw-r--r--ld/testsuite/ld-scripts/weak1.s11
-rw-r--r--ld/testsuite/ld-scripts/weak2.s11
-rw-r--r--ld/testsuite/ld-selective/1.c12
-rw-r--r--ld/testsuite/ld-selective/2.c19
-rw-r--r--ld/testsuite/ld-selective/3.cc33
-rw-r--r--ld/testsuite/ld-selective/4.cc28
-rw-r--r--ld/testsuite/ld-selective/5.cc32
-rw-r--r--ld/testsuite/ld-selective/selective.exp208
-rw-r--r--ld/testsuite/ld-sh/sh.exp143
-rw-r--r--ld/testsuite/ld-sh/sh1.s13
-rw-r--r--ld/testsuite/ld-sh/sh2.c120
-rw-r--r--ld/testsuite/ld-sh/start.s27
-rw-r--r--ld/testsuite/ld-shared/elf-offset.ld168
-rw-r--r--ld/testsuite/ld-shared/main.c81
-rw-r--r--ld/testsuite/ld-shared/sh1.c166
-rw-r--r--ld/testsuite/ld-shared/sh2.c14
-rw-r--r--ld/testsuite/ld-shared/shared.dat16
-rw-r--r--ld/testsuite/ld-shared/shared.exp264
-rw-r--r--ld/testsuite/ld-shared/sun4.dat16
-rw-r--r--ld/testsuite/ld-shared/xcoff.dat10
-rw-r--r--ld/testsuite/ld-srec/sr1.c25
-rw-r--r--ld/testsuite/ld-srec/sr2.c18
-rw-r--r--ld/testsuite/ld-srec/sr3.cc113
-rw-r--r--ld/testsuite/ld-srec/srec.exp374
-rw-r--r--ld/testsuite/ld-undefined/undefined.c10
-rw-r--r--ld/testsuite/ld-undefined/undefined.exp126
-rw-r--r--ld/testsuite/ld-versados/t1-1.robin0 -> 3840 bytes
-rw-r--r--ld/testsuite/ld-versados/t1-2.robin0 -> 256 bytes
-rw-r--r--ld/testsuite/ld-versados/t1.ld281
-rw-r--r--ld/testsuite/ld-versados/t1.ook133
-rw-r--r--ld/testsuite/ld-versados/t2-1.robin0 -> 256 bytes
-rw-r--r--ld/testsuite/ld-versados/t2-2.robin0 -> 2304 bytes
-rw-r--r--ld/testsuite/ld-versados/t2-3.robin0 -> 1024 bytes
-rw-r--r--ld/testsuite/ld-versados/t2.ld281
-rw-r--r--ld/testsuite/ld-versados/t2.ook99
-rw-r--r--ld/testsuite/ld-versados/versados.exp99
-rw-r--r--ld/testsuite/lib/ld-lib.exp327
127 files changed, 7211 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
new file mode 100644
index 00000000000..6610cbfb3e6
--- /dev/null
+++ b/ld/testsuite/ChangeLog
@@ -0,0 +1,731 @@
+1999-03-05 Nick Clifton <nickc@cygnus.com>
+
+ * ld-selective/selective.exp: Do not run tests for COFF or PE
+ based ports.
+
+1999-02-17 Nick Clifton <nickc@cygnus.com>
+
+ * ld-undefined/undefined.exp: Add expected failures for StrongARM
+ targets.
+
+ * ld-srec/srec.exp: Add expected failures for StrongARM targets.
+
+ * ld-selective/selective.exp: Add expected failure for ARM-COFF
+ targets.
+
+1999-02-16 Nick Clifton <nickc@cygnus.com>
+
+ * ld-checks/asm.s: Use .long instead of .word.
+ Replace custom section names with .text, .data and .bss.
+ * ld-checks/script: Replace custom section names with .text, .data
+ and .bss.
+ * ld-checks/checks.exp: Replace custom section names with .text,
+ .data and .bss.
+
+1999-02-11 Nick Clifton <nickc@cygnus.com>
+
+ * ld-checks: New directory: Tests for the linker's
+ --check-sections option.
+ * ld-checks/checks.exp: New file.
+ * ld-checks/script: Bogus linker script.
+ * ld-checks/asm.s: Simple test assembler file.
+
+Tue Feb 2 19:15:02 1999 Catherine Moore <clm@cygnus.com>
+
+ * ld-selective/selective.exp: Disable test for unsupported
+ targets. Change tests to check for absence of symbols instead
+ of address zero.
+
+Mon Jan 18 03:44:52 1999 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/default.exp (get_link_files): Quote target_triplet and CC
+ when invoking shell.
+ (get_target_emul): Likewise.
+
+1999-01-03 Ken Raeburn <raeburn@cygnus.com>
+
+ * config/default.exp (get_link_files, get_target_emul): New procs;
+ run shell commands to extract information from configure.host and
+ configure.tgt in the source tree.
+ (top level): Use them to get information needed to run tests, if
+ not otherwise provided.
+
+ * ld-shared/elf-offset.ld: New file. Builds a shared library, but
+ gives non-zero addresses for memory region.
+ * ld-shared/shared.exp: Run the non-PIC non-AIX test again using
+ the new linker script.
+
+Tue Dec 8 22:56:05 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * ld-srec/srec.exp: Delete xfails for PPC Linux targets,
+ newer glibc lets link succeed.
+
+Sun Dec 6 12:59:37 1998 H.J. Lu <hjl@gnu.org>
+
+ * ld-elfvers/vers1.c: Add missing return types and values.
+ * ld-elfvers/vers2.c: Likewise.
+ * ld-elfvers/vers3.c: Likewise.
+ * ld-elfvers/vers4.c: Likewise.
+ * ld-elfvers/vers5.c: Likewise.
+ * ld-elfvers/vers6.c: Likewise.
+ * ld-elfvers/vers7.c: Likewise.
+ * ld-elfvers/vers9.c: Likewise.
+ * ld-elfvers/vers15.c: Likewise.
+
+Fri Oct 23 16:28:29 1998 Catherine Moore <clm@cygnus.com>
+
+ * ld-selective: New directory with new files to test
+ selective linking.
+
+ * lib/ld-lib.exp (ld_nm): Strip leading underscore from $name.
+
+Sun Oct 4 22:17:05 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers16.dsym: Work correctly on a system without
+ versioned system libraries.
+
+Mon Sep 28 21:31:12 1998 Richard Henderson <rth@cygnus.com>
+
+ * ld-elfvers/vers.exp: Run tests on alpha-linux.
+ * ld-elfvers/*.sym, ld-elfvers/*.dsym: Adjust patters to match
+ Alpha's use of st_other.
+
+1998-09-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * ld-elfvers/vers.exp (vers16, vers16a): New tests.
+ * ld-elfvers/{vers16.*, vers16a.*}: New files.
+
+Thu Sep 17 17:18:19 1998 Nick Clifton <nickc@cygnus.com>
+
+ * ld-undefined/undefined.exp: Make undefined line test be an xfail
+ for arm/thunb elf toolchains.
+
+Wed Sep 9 14:10:15 1998 Nick Clifton <nickc@cygnus.com>
+
+ * ld-undefined/undefined.exp: change test for elf/dwarf2 targets.
+
+ * ld-srec/srec.exp: Arm-elf now passes this test.
+
+Wed Aug 19 11:59:19 1998 Nick Clifton <nickc@cygnus.com>
+
+ * ld-srec/srec.exp: Add arm/thumb-elf expected failures.
+
+Thu Aug 13 12:41:58 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: Don't run the --static bootstrap
+ test if we don't have a static libbfd.a.
+
+Wed Aug 12 15:19:35 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ Based on patch from H.J. Lu <hjl@gnu.org>:
+ * ld-srec/srec.exp: Add xfails for Alpha ELF targets.
+
+Mon Aug 10 15:42:20 1998 Richard Henderson <rth@cygnus.com>
+
+ * ld-scripts/weak.t (.text, .data): Focus data to be used.
+ (/DISCARD/): All the rest.
+ * ld-scripts/weak1.s, ld-scripts/weak2.s: Put stuff in .data.
+
+Fri Jul 24 18:37:17 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/default.exp: Create tmpdir/gas subdirectory, add a
+ symlink to as-new, and set gcc_gas_flag variable.
+ * lib/ld-lib.exp (default_ld_compile): If the compiler appears to
+ be gcc, use gcc_gas_flag when compiling.
+
+Thu Jul 23 12:23:29 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers.exp: Just check for i?86 rather than checking
+ for i386, i486, and i586.
+ (objdump_versionstuff): If we can't find the line, dump the file.
+
+Fri Jul 3 00:27:41 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/phdrs.exp: Run test on *-*-eabi*.
+ * ld-scripts/weak.exp: Likewise.
+
+Wed Jul 1 10:51:46 1998 Nick Clifton <nickc@cygnus.com>
+
+ * ld-srec/srec.exp: Add xfail for v850.
+
+ * ld-undefined/undefined.exp: arm and thumb PE toolchains now pass
+ these tests.
+
+Fri Jun 19 17:12:52 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/weak.exp: New test.
+ * ld-scripts/weak.t: New file.
+ * ld-scripts/weak1.s: New file.
+ * ld-scripts/weak2.s: New file.
+
+Tue Jun 16 12:40:38 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * ld-elfvers/vers.exp: Run tests on powerpc ELF targets.
+ * ld-shared/shared.exp: Likewise.
+ * ld-elfvers/vers1.dsym: Allow for .sdata.
+ * ld-srec/srec.exp: Add setup_xfails for PowerPC Linux.
+
+Fri May 29 15:02:50 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Add xfails for powerpc*-*-eabi.
+ (run_srec_test): On mn10200, define __truncsipsi2_do_d2.
+ * ld-srec/sr1.c (__main): Change return type to void.
+ * ld-srec/sr3.cc (__main): Likewise.
+ (__builtin_delete, __builtin_new): Likewise.
+ (__get_dynamic_handler_chain): Return 0.
+ (__get_eh_context): Likewise.
+
+Thu May 21 15:21:33 1998 Nick Clifton <nickc@cygnus.com>
+
+ * ld-undefined/undefined.exp: Add support for thumb-pe target.
+ * ld-srec/srec.exp: Add support for arm-pe and thumb-pe targets.
+
+Mon May 4 17:54:20 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * ld-shared/shared.exp: Remove setup_xfails for m68k-linux.
+
+Mon May 4 17:12:06 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-shared/main.c (shlib_overriddencall2): New function.
+ (main): Call shlib_shlibcall2.
+ * ld-shared/sh1.c (shlib_shlibcall2): New function.
+ (shlib_overriddencall2): New function.
+ * ld-shared/shared.dat: Add output line for new test.
+ * ld-shared/sun4.dat: Likewise.
+
+ * ld-srec/sr3.cc (__get_eh_context): New function.
+
+Tue Apr 7 12:50:17 1998 Manfred Hollstein <manfred@s-direktnet.de>
+
+ * ld-cdtest/cdtest-foo.h (class Foo): Declare len to be static to
+ avoid compiler warning.
+ * ld-srec/sr3.cc (class Foo): Likewise.
+
+Tue Feb 10 16:42:40 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/sr3.cc (__get_dynamic_handler_chain): New function.
+
+Mon Feb 2 14:17:48 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/phdrs.exp: Adjust phdrs_regexp for a 64 bit target.
+
+Thu Dec 18 11:13:28 1997 Nick Clifton <nickc@cygnus.com>
+
+ * ld-srec/srec.exp: Duplicated Arm patch for Thumb targets.
+
+Tue Dec 2 09:50:19 1997 Nick Clifton <nickc@cygnus.com>
+
+ * ld-srec/srec.exp: Applied patch from Tony.Thompson@arm.com which
+ fixes ARM tests.
+
+Mon Dec 1 16:12:05 1997 Nick Clifton <nickc@cygnus.com>
+
+ * ld-srec/srec.exp: Add expected failures of tests 1 and 2 for ARM
+ coff targets.
+
+Wed Nov 12 14:18:31 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-cdtest/cdtest-foo.h (class Foo): Declare len to be int to
+ avoid compiler warning.
+ * ld-srec/sr3.cc (class Foo): Likewise.
+
+Mon Nov 10 14:25:43 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * lib/ld-lib.exp (default_ld_simple_link): Permit the linker to
+ have any name when looking for entry symbol warnings.
+
+ * ld-srec/sr3.cc (__eh_pc): Define.
+
+Mon Oct 20 14:36:39 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/sr3.cc: Add definitions for terminate, __terminate, and
+ __throw, since the current g++ expects them to be defined.
+
+Fri Oct 3 12:24:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers.exp (objdump_emptyverstuff): Accept the output
+ file if the string libc appears in it.
+ (objdump_versionstuff): Accept unexpected lines in the output
+ file. Compare lines using string match.
+ * ld-elfvers/vers6.ver: Permit any value in the vna_other field.
+
+Tue Aug 12 16:01:22 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/crossref.exp: Correct string quoting.
+
+Sat Aug 9 00:56:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/default.exp: Change ld, as, nm and strip from .new to
+ -new. Load ld-lib.exp rather than ld.exp.
+ * ld-bootstrap/bootstrap.exp: Use ld-new rather than ld.new.
+ * lib/ld-lib.exp: Rename from lib/ld.exp, for the benefit of
+ DejaGnu changes.
+
+Thu Jun 26 12:07:03 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers.exp: Use egrep rather than grep when looking for
+ an alternation. From Greg Margo <gmargo@dl.com>.
+
+Wed Jun 25 12:47:22 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * ld-shared/shared.exp: Add setup_xfail for m68k-linux on tests
+ with non PIC shared libraries.
+
+Fri Jun 6 17:35:47 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers6.ver: Update for recent elflink.h patch to
+ version handling.
+
+Wed Jun 4 12:06:48 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Define ___get_dynamic_handler_chain as well.
+
+Fri May 30 12:21:39 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Define __get_dynamic_handler_chain when
+ linking.
+
+Mon May 12 11:17:55 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * config/default.exp: Use $base_dir rather than $objdir when
+ setting ld. From John David Anglin <dave@hiauly1.hia.nrc.ca>.
+
+Fri Apr 25 09:07:00 1997 Jeffrey A Law (law@cygnus.com)
+
+ * ld-srec/srec.exp: Define various out of line prologue/epilogue
+ functions for the mn10200 to avoid needing libgcc.a.
+
+Wed Mar 26 13:56:10 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Don't expect failures on mips*-*-elf*.
+
+Mon Mar 17 19:27:13 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-elfvers/vers.exp: Don't run on SunOS or AIX.
+
+Wed Mar 12 21:44:19 1997 Eric Youngdale <eric@andante.jic.com>
+
+ * ld-elfvers/vers.exp, *: New tests for symbol versioning.
+ * config/default.exp: Set ar and strip.
+
+Fri Feb 7 16:47:02 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: Use prune_warnings instead of
+ prune_system_crud.
+ * ld-cdtest/cdtest.exp: Ditto.
+ * ld-scripts/crossref.exp: Ditto.
+ * ld-sh/sh.exp: Ditto.
+ * ld-shared/shared.exp: Ditto.
+ * ld-srec/srec.exp: Ditto.
+ * lib/ld.exp: Ditto.
+
+Wed Jan 29 00:47:29 1997 Bob Manson <manson@charmed.cygnus.com>
+
+ * ld-cdtest/cdtest.exp: Put a slash between $srcdir/$subdir.
+ * ld-scripts/script.exp: Ditto.
+ * ld-sh/sh.exp: Ditto.
+ * ld-undefined/undefined.exp: Ditto.
+ * ld-versados/versados.exp: Ditto.
+ * lib/ld.exp: Ditto.
+
+Mon Dec 30 17:08:04 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/crossref.exp: Fix quoting for --defsym $global$.
+
+Tue Oct 1 15:52:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * lib/ld.exp (default_ld_version): Fix for current version
+ printing.
+
+Fri Sep 13 15:51:45 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/crossref.exp: Define $global$ for hppa-elf.
+
+Thu Aug 8 14:29:32 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/cross2.t: Map XCOFF sections to .text or .data.
+
+ * lib/ld.exp: Use verbose -log instead of calling both verbose and
+ send_log.
+
+Wed Aug 7 18:00:58 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/phdrs.exp: New test.
+ * ld-scripts/phdrs.s, ld-scripts/phdrs.t: New files.
+
+Sun Aug 4 21:58:12 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/crossref.exp: On a29k targets, use --defsym to define
+ V_SPILL and V_FILL.
+
+Thu Aug 1 14:10:27 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-scripts/crossref.exp: New test.
+ * ld-scripts/{cross1.c, cross2.c, cross3.c}: New files.
+ * ld-scripts/{cross1.t, cross2.t}: New files.
+
+Sat Jun 29 13:40:11 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-sh/sh.exp: Fix debugging messages.
+ * ld-sh/sh1.s: Use .align 4.
+
+Wed May 1 16:45:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-sh/sh.exp: Use -O when compiling with -mrelax.
+
+Mon Apr 29 10:33:10 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * ld-shared/shared.exp: Run the shared library tests on
+ Linux/m68k.
+
+Fri Apr 5 16:20:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-shared/shared.exp: Run the shared library tests on Linux.
+
+Mon Feb 26 12:45:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-shared/shared.exp: Don't use -fpic on MIPS targets.
+
+Wed Jan 31 15:09:57 1996 Jeffrey A Law (law@cygnus.com)
+
+ * ld-srec/srec.exp: Add xfails for hppa*-*-*elf*.
+ * ld-undefined/undefined.exp: Likewise.
+
+Fri Jan 26 18:43:03 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-undefined/undefined.exp: ELF targets should now pass the
+ undefined line test.
+
+Thu Jan 25 15:36:13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-empic/empic.exp: Update for change to MIPS disassembler.
+
+Mon Jan 15 15:05:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: Expect failure for mips*-*-irix5*
+ when doing the --static test.
+ * ld-shared/shared.exp: Run tests on mips*-*-irix5*.
+
+Fri Dec 29 12:33:09 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-bootstrap/bootstrap.exp: On AIX, don't pass the -bI option
+ when creating ld-partial.o.
+
+Tue Dec 26 17:37:23 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: If powerpc*-*-eabi*, use --defsym to define
+ __eabi.
+
+Tue Dec 19 18:01:01 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Add setup_xfails for XCOFF targets.
+
+Fri Dec 15 16:36:17 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: On a29k targets, use --defsym to define
+ V_SPILL and V_FILL.
+ * ld-srec/sr1.c (V_SPILL, V_FILL): Remove definitions.
+ * ld-srec/sr3.cc: Likewise.
+
+ * ld-srec/srec.exp: Remove i960 COFF setup_xfail.
+
+Sat Dec 2 01:20:31 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Don't use [] in setup_xfail expressions.
+
+Fri Dec 1 13:18:18 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Add setup_xfails for MIPS ELF targets.
+
+Wed Nov 29 13:01:10 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Add setup_xfail for i960 COFF targets.
+
+Mon Nov 27 14:36:11 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-srec/srec.exp: Add setup_xfail calls for i[345]86-*-aout*.
+
+ * ld-srec/sr1.c (V_SPILL, V_FILL): Define.
+ * ld-srec/sr3.cc: Likewise.
+
+Tue Nov 21 16:05:53 1995 Ian Lance Taylor <ian@cygnus.com>
+
+ * ld-empic/empic.exp: Update for changes in objdump output.
+
+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/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
new file mode 100644
index 00000000000..0a0fdea16d5
--- /dev/null
+++ b/ld/testsuite/config/default.exp
@@ -0,0 +1,171 @@
+# Basic expect script for LD Regression Tests
+# Copyright (C) 1993, 94, 95, 97, 98, 1999 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 $base_dir/ld-new $base_dir/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 ![info exists ar] then {
+ set ar [findfile $base_dir/../binutils/ar]
+}
+
+if ![info exists strip] then {
+ set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]]
+}
+
+if {![file isdirectory tmpdir]} then {
+ catch "exec mkdir tmpdir" status
+}
+
+# Make a symlink from tmpdir/as to the assembler in the build tree, so
+# that we can use a -B option to gcc to force it to use the newly
+# built assembler.
+if {![file isdirectory tmpdir/gas]} then {
+ catch "exec mkdir tmpdir/gas" status
+ catch "exec ln -s ../../../gas/as-new tmpdir/gas/as" status
+}
+set gcc_gas_flag "-B[pwd]/tmpdir/gas/"
+
+# load the utility procedures
+load_lib ld-lib.exp
+
+proc get_link_files {varname} {
+ global $varname
+ global target_triplet
+ global srcdir
+ global CC
+ if ![info exists $varname] {
+ set status [catch "exec sh -c \"host='$target_triplet' && CC='$CC' && . $srcdir/../configure.host && eval echo \\$$varname\"" result]
+ if $status { error "Error getting native link files: $result" }
+ set $varname $result
+ }
+}
+
+proc get_target_emul {} {
+ global target_triplet
+ global srcdir
+ set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
+ if $status { error "Error getting emulation name: $result" }
+ return $result
+}
+
+if [isnative] {
+ foreach x {HOSTING_CRT0 HOSTING_LIBS} {
+ get_link_files $x
+ }
+} else {
+ foreach x {HOSTING_CRT0 HOSTING_LIBS} { set $x "" }
+}
+if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
+
+#
+# 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/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
new file mode 100644
index 00000000000..0e4b820cb20
--- /dev/null
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -0,0 +1,103 @@
+# Expect script for LD Bootstrap Tests
+# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998 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"
+ }
+
+ # 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 we only have a shared libbfd, we probably can't run the
+ # --static test.
+ if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
+ untested $testname
+ continue
+ }
+
+ if ![ld_relocate $ld tmpdir/ld-partial.o "$flags $OFILES"] {
+ fail $testname
+ continue
+ }
+
+ # On AIX, you need to specify an import list when using --static.
+ # You only want the import list when creating the final
+ # executable.
+ if [istarget "*-*-aix*"] {
+ if {"$flags" == "--static"} {
+ set flags "--static -bI:/lib/syscalls.exp"
+ }
+ }
+
+ # On Irix 5, linking with --static only works if all the files are
+ # compiled using -non_shared.
+ if {"$flags" == "--static"} {
+ setup_xfail "mips*-*-irix5*"
+ }
+
+ 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_warnings $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/ld/testsuite/ld-cdtest/cdtest-bar.cc b/ld/testsuite/ld-cdtest/cdtest-bar.cc
new file mode 100644
index 00000000000..79000e33954
--- /dev/null
+++ b/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/ld/testsuite/ld-cdtest/cdtest-foo.cc b/ld/testsuite/ld-cdtest/cdtest-foo.cc
new file mode 100644
index 00000000000..615e33cea78
--- /dev/null
+++ b/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/ld/testsuite/ld-cdtest/cdtest-foo.h b/ld/testsuite/ld-cdtest/cdtest-foo.h
new file mode 100644
index 00000000000..0afe52a829f
--- /dev/null
+++ b/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;
+ static const int 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/ld/testsuite/ld-cdtest/cdtest-main.cc b/ld/testsuite/ld-cdtest/cdtest-main.cc
new file mode 100644
index 00000000000..4b99b5c5f0f
--- /dev/null
+++ b/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/ld/testsuite/ld-cdtest/cdtest.dat b/ld/testsuite/ld-cdtest/cdtest.dat
new file mode 100644
index 00000000000..39be0dbc2c7
--- /dev/null
+++ b/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/ld/testsuite/ld-cdtest/cdtest.exp b/ld/testsuite/ld-cdtest/cdtest.exp
new file mode 100644
index 00000000000..ccbe35e3709
--- /dev/null
+++ b/ld/testsuite/ld-cdtest/cdtest.exp
@@ -0,0 +1,100 @@
+# Expect script for LD cdtest Tests
+# Copyright (C) 1993,1994,1995, 1997 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_warnings $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_warnings $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/ld/testsuite/ld-checks/asm.s b/ld/testsuite/ld-checks/asm.s
new file mode 100644
index 00000000000..e4e0c332470
--- /dev/null
+++ b/ld/testsuite/ld-checks/asm.s
@@ -0,0 +1,14 @@
+.text
+ .global foo
+foo:
+ .long 0x12345678
+
+.data
+ .global bar
+bar:
+ .long 0x87654321
+
+ .lcomm 0x12
+
+
+ \ No newline at end of file
diff --git a/ld/testsuite/ld-checks/checks.exp b/ld/testsuite/ld-checks/checks.exp
new file mode 100644
index 00000000000..af3ef7d70a4
--- /dev/null
+++ b/ld/testsuite/ld-checks/checks.exp
@@ -0,0 +1,72 @@
+# Expect script for LD section checks tests
+# Copyright (C) 1999 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 Nick Clifton (nickc@cygnus.com)
+
+proc section_check {} {
+ global ld_flags
+ global as
+ global ld
+ global srcdir
+ global subdir
+
+ set test "check sections"
+
+ set ldflags "--check-sections"
+
+ if { ![ld_assemble $as $srcdir/$subdir/asm.s tmpdir/asm.o]} {
+ unresolved $test
+ return
+ }
+
+ if ![ld_simple_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
+ fail "$test : using default linker script"
+ } else {
+ pass $test
+ }
+
+ # Change the linker flags so that our "buggy" linker
+ # script is used.
+ set ldflags "--check-sections -T $srcdir/$subdir/script -e foo"
+
+ # Perform the equivalent of invoking ld_simple_link
+ # except that we need to massage the output futher.
+
+ catch "exec $ld -o tmpdir/asm.x $ldflags tmpdir/asm.o" exec_output
+ set exec_output [prune_warnings $exec_output]
+
+ # Make sure that we got some output from the linker
+ if [string match "" $exec_output] then {
+ fail "$test - error message expected but not found"
+ }
+
+ # Now remove our expected error message
+ regsub -all ".*: section .data .* overlaps section .text .*" $exec_output "" exec_output
+
+ # And check to see if anything else, (unexpected) was left
+ if [string match "" $exec_output] then {
+ pass $test
+ } else {
+ verbose -log "Unexpected linker message(s): $exec_output"
+
+ fail "$test - using erroneous linker script"
+ }
+}
+
+section_check
+
+
diff --git a/ld/testsuite/ld-checks/script b/ld/testsuite/ld-checks/script
new file mode 100644
index 00000000000..44c6a08420a
--- /dev/null
+++ b/ld/testsuite/ld-checks/script
@@ -0,0 +1,6 @@
+SECTIONS {
+ .text 0x100 : { *(.text) }
+ .data 0x100 : AT (0x100) { *(.data) }
+ .bss 0x100 : AT (0x4000) { *(.bss) }
+}
+
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
new file mode 100644
index 00000000000..5dfaa93346e
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -0,0 +1,808 @@
+# Expect script for ld-version tests
+# Copyright (C) 1997, 1998 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 Eric Youngdale (eric@andante.jic.com)
+
+#
+
+# 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.
+# This is similar to the test that is used in ld-shared, BTW.
+if { ![istarget i?86-*-sysv4*] \
+ && ![istarget i?86-*-unixware] \
+ && ![istarget i?86-*-elf*] \
+ && ![istarget i?86-*-linux*] \
+ && ![istarget m68k-*-linux*] \
+ && ![istarget mips*-*-irix5*] \
+ && ![istarget powerpc-*-elf*] \
+ && ![istarget powerpc-*-linux*] \
+ && ![istarget powerpc-*-sysv4*] \
+ && ![istarget sparc*-*-elf] \
+ && ![istarget sparc*-*-solaris2*]
+ && ![istarget alpha*-*-linux*] } {
+ return
+}
+
+if { [istarget i?86-*-linuxaout*] \
+ || [istarget i?86-*-linuxoldld*] \
+ || [istarget m68k-*-linuxaout*] } {
+ return
+}
+
+if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+ return
+}
+
+set diff diff
+set tmpdir tmpdir
+set VOBJDUMP_FLAGS --private-headers
+set DOBJDUMP_FLAGS --dynamic-syms
+set SOBJDUMP_FLAGS --syms
+set shared --shared
+set script --version-script
+
+proc test_ar { test lib object expect } {
+ global ar
+ global nm
+ global tmpdir
+ global srcdir
+ global subdir
+ global diff
+
+ verbose -log "$ar -cr $tmpdir/$lib $tmpdir/$object"
+ catch "exec $ar -cr $tmpdir/$lib $tmpdir/$object" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if ![string match "" $exec_output] {
+ verbose -log "$exec_output"
+ unresolved "$test"
+ return
+ }
+
+ verbose -log "$nm --print-armap $tmpdir/$lib | grep \" in \" | egrep \"VERS\\|bar\\|foo\" | sort > $tmpdir/nm.out"
+
+ catch "exec $nm --print-armap $tmpdir/$lib | grep \\\ in\\\ | egrep VERS\\\|bar\\\|foo | sort > $tmpdir/nm.out" exec_output
+ if [string match "" $exec_output] then {
+ catch "exec $diff -q $tmpdir/nm.out $srcdir/$subdir/$expect" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ pass $test
+ return
+ } else {
+ verbose -log "$exec_output"
+ fail "$test"
+ return
+ }
+ } else {
+ verbose -log "$exec_output"
+ fail "$test"
+ }
+}
+
+#
+# objdump_emptysymstuff
+# Check non-dynamic symbols and make sure there are none with '@'.
+#
+proc objdump_emptysymstuff { objdump object } {
+ global SOBJDUMP_FLAGS
+ global version_output
+ global diff
+
+ if ![info exists SOBJDUMP_FLAGS] { set SOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $SOBJDUMP_FLAGS $object | sed -n /\@/p"
+
+ catch "exec $objdump $SOBJDUMP_FLAGS $object | sed -n /\@/p" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+# We shouldn't get anything here.
+ return 1
+ } else {
+# it is not normal to come here - we have no output to compare.
+ verbose -log "$exec_output"
+ verbose -log "objdump_emptysymstuff: did not expect any output from objdump"
+ return 0
+ }
+
+}
+
+#
+# objdump_emptydynsymstuff
+# Check dynamic symbols and make sure there are none with '@'.
+#
+proc objdump_emptydynsymstuff { objdump object } {
+ global DOBJDUMP_FLAGS
+ global version_output
+ global diff
+
+ if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p"
+
+ catch "exec $objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+# We shouldn't get anything here.
+ return 1
+ } else { if [string match "*objdump: *: not a dynamic object" $exec_output] then {
+ return 1
+ } else {
+# it is not normal to come here - we have no output to compare.
+ verbose -log "$exec_output"
+ verbose -log "objdump_emptydynsymstuff: did not expect any output from objdump"
+ return 0
+ } }
+}
+
+#
+# objdump_emptyverstuff
+# Make sure there is no version information
+#
+proc objdump_emptyverstuff { objdump object } {
+ global VOBJDUMP_FLAGS
+ global version_output
+ global diff
+ global tmpdir
+
+ if {[which $objdump] == 0} then {
+ perror "$objdump does not exist"
+ return 0
+ }
+
+ if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out"
+
+ catch "exec $objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+# it is normal to fail here - we have no output to compare.
+ return 1
+ } else { if { [string match "*libc*" $exec_output] } then {
+# this probably means that there is version information in libc, so we
+# can't really perform this test.
+ return 1
+ } else {
+ verbose -log "$exec_output"
+ verbose -log "objdump_emptyverstuff: did not expect any output from objdump"
+ return 0
+ } }
+
+}
+
+#
+# objdump_symstuff
+# Dump non-dynamic symbol stuff and make sure that it is sane.
+#
+proc objdump_symstuff { objdump object expectfile } {
+ global SOBJDUMP_FLAGS
+ global version_output
+ global diff
+ global tmpdir
+
+ if ![info exists SOBJDUMP_FLAGS] { set SOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $SOBJDUMP_FLAGS $object | grep \@ | sort > $tmpdir/objdump.out"
+
+ catch "exec $objdump $SOBJDUMP_FLAGS $object | grep \@ | sort > $tmpdir/objdump.out" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+
+# Now do a line-by-line comparison to effectively diff the darned things
+# The stuff coming from the expectfile is actually a regex, so we can
+# skip over the actual addresses and so forth. This is currently very
+# simpleminded - it expects a one-to-one correspondence in terms of line
+# numbers.
+
+ if [file exists $expectfile] then {
+ set file_a [open $expectfile r]
+ } else {
+ perror "$expectfile doesn't exist"
+ return 0
+ }
+
+ if [file exists $tmpdir/objdump.out] then {
+ set file_b [open $tmpdir/objdump.out r]
+ } else {
+ perror "$tmpdir/objdump.out doesn't exist"
+ return 0
+ }
+
+ verbose "# Diff'ing: $expectfile $tmpdir/objdump.out" 2
+
+ set eof -1
+ set differences 0
+
+ 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$expectfile: $i: $line_a" 3
+ verbose "\t/tmp/objdump.out: $i: $line_b" 3
+ if [regexp $line_a $line_b] then {
+ continue
+ } else {
+ verbose -log "\t$expectfile: $i: $line_a"
+ verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
+
+ return 0
+ }
+ }
+
+ if { [llength $list_a] != [llength $list_b] } {
+ verbose -log "Line count"
+ return 0
+ }
+
+ if $differences<1 then {
+ return 1
+ }
+
+ return 0
+ } else {
+ verbose -log "$exec_output"
+ return 0
+ }
+
+}
+
+#
+# objdump_dymsymstuff
+# Dump dynamic symbol stuff and make sure that it is sane.
+#
+proc objdump_dynsymstuff { objdump object expectfile } {
+ global DOBJDUMP_FLAGS
+ global version_output
+ global diff
+ global tmpdir
+
+ if ![info exists DOBJDUMP_FLAGS] { set DOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p | sort | uniq > $tmpdir/objdump.out"
+
+ catch "exec $objdump $DOBJDUMP_FLAGS $object | sed -n /VERS/p\\\;/show/p | sort | uniq > $tmpdir/objdump.out" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+
+# Now do a line-by-line comparison to effectively diff the darned things
+# The stuff coming from the expectfile is actually a regex, so we can
+# skip over the actual addresses and so forth. This is currently very
+# simpleminded - it expects a one-to-one correspondence in terms of line
+# numbers.
+
+ if [file exists $expectfile] then {
+ set file_a [open $expectfile r]
+ } else {
+ warning "$expectfile doesn't exist"
+ return 0
+ }
+
+ if [file exists $tmpdir/objdump.out] then {
+ set file_b [open $tmpdir/objdump.out r]
+ } else {
+ fail "$tmpdir/objdump.out doesn't exist"
+ return 0
+ }
+
+ verbose "# Diff'ing: $expectfile $tmpdir/objdump.out" 2
+
+ set eof -1
+ set differences 0
+
+ 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_b] } { incr i } {
+ set line_b [lindex $list_b $i]
+
+# The tests are rigged so that we should never export a symbol with the
+# word 'hide' in it. Thus we just search for it, and bail if we find it.
+ if [regexp "hide" $line_b] then {
+ verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
+
+ return 0
+ }
+
+ verbose "\t$expectfile: $i: $line_b" 3
+
+ # We can't assume that the sort is consistent across
+ # systems, so we must check each regexp. When we find a
+ # regexp, we null it out, so we don't match it twice.
+ for { set j 0 } { $j < [llength $list_a] } { incr j } {
+ set line_a [lindex $list_a $j]
+
+ if [regexp $line_a $line_b] then {
+ lreplace $list_a $j $j "CAN NOT MATCH"
+ break
+ }
+ }
+
+ if { $j >= [llength $list_a] } {
+ verbose -log "\t$tmpdir/objdump.out: $i: $line_b"
+
+ return 0
+ }
+ }
+
+ if { [llength $list_a] != [llength $list_b] } {
+ verbose -log "Line count"
+ return 0
+ }
+
+ if $differences<1 then {
+ return 1
+ }
+
+ return 0
+ } else {
+ verbose -log "$exec_output"
+ return 0
+ }
+
+}
+
+#
+# objdump_versionstuff
+# Dump version definitions/references and make sure that it is sane.
+#
+proc objdump_versionstuff { objdump object expectfile } {
+ global VOBJDUMP_FLAGS
+ global version_output
+ global diff
+ global tmpdir
+
+ if {[which $objdump] == 0} then {
+ perror "$objdump does not exist"
+ return 0
+ }
+
+ if ![info exists VOBJDUMP_FLAGS] { set VOBJDUMP_FLAGS "" }
+
+ verbose -log "$objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out"
+
+ catch "exec $objdump $VOBJDUMP_FLAGS $object | sed -n /Version/,\\\$p > $tmpdir/objdump.out" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+
+ # It's OK if there are extra lines in the actual output; they
+ # may come from version information in libc. We require that
+ # every line in EXPECTFILE appear in the output in order.
+
+ set f1 [open $tmpdir/objdump.out r]
+ set f2 [open $expectfile r]
+ gets $f2 l2
+ while { [gets $f1 l1] != -1 } {
+ if { [string match $l2 $l1] } then {
+ if { [gets $f2 l2] == -1 } then {
+ close $f1
+ close $f2
+ return 1
+ }
+ }
+ }
+
+ # We reached the end of the output without seeing the line we
+ # expected. This is a test failure.
+
+ close $f1
+ close $f2
+
+ verbose -log "Did not find \"$l2\""
+ set f1 [open $tmpdir/objdump.out r]
+ while { [gets $f1 l1] != -1 } {
+ verbose -log $l1
+ }
+
+ verbose -log "$exec_output"
+ return 0
+ } else {
+ verbose -log "$exec_output"
+ return 0
+ }
+}
+
+proc build_vers_lib { test source libname other mapfile verexp versymexp symexp } {
+ global ld
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+ global as
+ global objdump
+ global CC
+ global CFLAGS
+ global shared
+ global script
+
+ if ![ld_compile "$CC -S $CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] {
+ unresolved "$test"
+ return
+ }
+
+ if ![ld_assemble $as $tmpdir/$libname.s $tmpdir/$libname.o ] {
+ unresolved "$test"
+ return
+ }
+
+ if [string match "" $other] then {
+ set other_lib ""
+ } else {
+ set other_lib $tmpdir/$other
+ }
+
+ if [string match "" $mapfile] then {
+ set script_arg ""
+ } else {
+ set script_arg "$script $srcdir/$subdir/$mapfile"
+ }
+
+ if {![ld_simple_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg"]} {
+ fail "$test"
+ return
+ }
+
+ if {![objdump_versionstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$verexp ]} {
+ fail "$test"
+ return
+ }
+
+ if {![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$versymexp ]} {
+ fail "$test"
+ return
+ }
+
+ if [string match "" $symexp] then {
+ if {![objdump_emptysymstuff $objdump $tmpdir/$libname.o ]} {
+ fail "$test"
+ return
+ }
+ } else {
+ if {![objdump_symstuff $objdump $tmpdir/$libname.o $srcdir/$subdir/$symexp ]} {
+ fail "$test"
+ return
+ }
+ }
+
+ pass $test
+
+}
+
+proc test_ldfail { test flag source execname other mapfile whyfail } {
+ global ld
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+ global as
+ global objdump
+ global CC
+ global CFLAGS
+ global script
+
+ if [string match "" $other] then {
+ set other_lib ""
+ } else {
+ set other_lib $tmpdir/$other
+ }
+
+ if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
+ unresolved "$test"
+ return
+ }
+
+ if ![ld_assemble $as $tmpdir/$execname.s $tmpdir/$execname.o ] {
+ unresolved "$test"
+ return
+ }
+
+ verbose -log "This link should fail because of $whyfail"
+
+ if [string match "" $mapfile] then {
+ set script_arg ""
+ } else {
+ set script_arg "$script $srcdir/$subdir/$mapfile"
+ }
+
+ if {![ld_link $ld $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]} {
+ pass "$test"
+ return
+ }
+ fail "$test"
+}
+
+proc test_asfail { test flag source execname whyfail } {
+ global srcdir
+ global subdir
+ global tmpdir
+ global as
+ global CC
+ global CFLAGS
+
+ if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
+ unresolved "$test"
+ return
+ }
+
+ verbose -log "This assemble should fail because of $whyfail"
+ catch "exec $as -o $tmpdir/$execname.o $tmpdir/$execname.s" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ fail "$test"
+ return
+ }
+ verbose -log "$exec_output"
+ pass "$test"
+}
+
+proc test_strip_vers_lib { test srclib libname verexp versymexp } {
+ global strip
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+ global objdump
+
+ verbose -log "cp $tmpdir/$srclib $tmpdir/$libname.so"
+ exec cp $tmpdir/$srclib $tmpdir/$libname.so
+
+ verbose -log "$strip $tmpdir/$libname.so"
+ catch "exec $strip $tmpdir/$libname.so" exec_output
+ if [string match "" $exec_output] then {
+
+# If strip went OK, then run the usual tests on the thing to make sure that
+# it is sane.
+ if {![objdump_versionstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$verexp ]} {
+ fail "$test"
+ return
+ }
+
+ if {![objdump_dynsymstuff $objdump $tmpdir/$libname.so $srcdir/$subdir/$versymexp ]} {
+ fail "$test"
+ return
+ }
+
+ } else {
+ verbose -log "$exec_output"
+ fail "$test"
+ return
+ }
+ pass $test
+}
+
+
+proc build_exec { test source execname flags solibname verexp versymexp symexp } {
+ global ld
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+ global as
+ global objdump
+ global CC
+ global CFLAGS
+
+ set shared --shared
+ set script --version-script
+ if ![ld_compile "$CC -S $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
+ unresolved "$test"
+ return
+ }
+
+ if ![ld_assemble $as $tmpdir/$execname.s $tmpdir/$execname.o ] {
+ unresolved "$test"
+ return
+ }
+
+ if [string match "" $solibname] then {
+ set solibname_lib ""
+ } else {
+ set solibname_lib $tmpdir/$solibname
+ }
+
+ if {![ld_link $ld $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]} {
+ fail "$test"
+ return
+ }
+
+ if [string match "" $verexp] then {
+#
+# Make sure we get nothing back.
+#
+ if {![objdump_emptyverstuff $objdump $tmpdir/$execname ]} {
+ fail "$test"
+ return
+ }
+ } else {
+ if {![objdump_versionstuff $objdump $tmpdir/$execname $srcdir/$subdir/$verexp ]} {
+ fail "$test"
+ return
+ }
+ }
+
+ if [string match "" $versymexp] then {
+ if {![objdump_emptydynsymstuff $objdump $tmpdir/$execname ]} {
+ fail "$test"
+ return
+ }
+ } else {
+ if {![objdump_dynsymstuff $objdump $tmpdir/$execname $srcdir/$subdir/$versymexp ]} {
+ fail "$test"
+ return
+ }
+ }
+
+ if [string match "" $symexp] then {
+ if {![objdump_emptysymstuff $objdump $tmpdir/$execname.o ]} {
+ fail "$test"
+ return
+ }
+ } else {
+ if {![objdump_symstuff $objdump $tmpdir/$execname.o $srcdir/$subdir/$symexp ]} {
+ fail "$test"
+ return
+ }
+ }
+
+ pass $test
+}
+
+
+#
+# Basic test - build a library with versioned symbols.
+#
+build_vers_lib "vers1" vers1.c vers1 "" vers1.map vers1.ver vers1.dsym vers1.sym
+
+
+#
+# Test #2 - build a library, and link it against the library we built in step
+# 1.
+#
+build_vers_lib "vers2" vers2.c vers2 vers1.so vers2.map vers2.ver vers2.dsym ""
+
+#
+# Test #3 - build an executable, and link it against vers1.so.
+#
+build_exec "vers3" vers3.c vers3 "" vers1.so vers3.ver vers3.dsym ""
+
+#
+# Test #4 - Make sure a version implicitly defined in an executable
+# causes a version node to be created. Verify this both with and without
+# --export-dynamic.
+#
+
+# This test fails on MIPS. On the MIPS we must put foo in the dynamic
+# symbol table, which the test does not expect.
+setup_xfail "mips*-*-*"
+build_exec "vers4" vers4.c vers4 "" "" "" "" vers4.sym
+
+build_exec "vers4a" vers4.c vers4a "-export-dynamic" "" vers4a.ver vers4a.dsym vers4a.sym
+
+
+#
+# Try multiple definitions foo@BAR and foo@@BAR and make sure the linker
+# complains.
+#
+test_ldfail "vers5" "" vers5.c vers5 "" "" "multiple definition of foo@VERS_1.2"
+
+#
+#
+# Now build a test that should reference a bunch of versioned symbols.
+# All of them should be correctly referenced.
+#
+build_exec "vers6" vers6.c vers6 "" vers1.so vers6.ver vers6.dsym vers6.sym
+
+#
+# Another test to verify that something made local via 'local' is truly not
+# accessible.
+#
+build_vers_lib "vers7a" vers7a.c vers7a "" vers7.map vers7a.ver vers7a.dsym vers7a.sym
+
+test_ldfail "vers7" "" vers7.c vers7 vers7a.so "" "undefined reference to hide_a"
+
+
+#
+# This test is designed to verify that we can pass a linker script on the
+# command line as if it were a normal .o file.
+#
+catch "exec cp $srcdir/$subdir/vers8.map $tmpdir/" ignore_output
+build_vers_lib "vers8" vers1.c vers8 vers8.map "" vers8.ver vers1.dsym vers1.sym
+
+#
+# This test tries to make sure that version references to versioned symbols
+# don't collide with default definitions with the same symbol.
+#
+build_exec "vers9" vers9.c vers9 "-export-dynamic" "" vers9.ver vers9.dsym vers9.sym
+
+
+#
+# Try and use a non-existant version node. The linker should fail with
+# an error message.
+#
+test_ldfail "vers10" "-DDO_TEST10" vers1.c vers10 "" "vers1.map --shared" "invalid version"
+
+#
+# Try and some things the assembler should complain about.
+#
+test_asfail "vers11" "-DDO_TEST11" vers1.c vers11 "no @ in symver"
+
+test_asfail "vers12" "-DDO_TEST12" vers1.c vers12 "extern version definition"
+
+#
+# Put a shared library in an archive library, and make sure the global
+# archive symbol table is sane.
+#
+test_ar "ar with versioned solib" vers13.a vers1.so vers13.asym
+
+#
+# Strip a shared library, and make sure we didn't screw something up in there.
+#
+test_strip_vers_lib "vers14" vers1.so vers14 vers1.ver vers1.dsym
+
+
+#
+# Build another test with some versioned symbols. Here we are going to
+# try and override something from the library, and we shouldn't get
+# any errors.
+#
+build_exec "vers15" vers15.c vers15 "" vers1.so vers15.ver vers15.dsym vers15.sym
+
+#
+# Test that when we override a versioned symbol from the library this
+# symbol appears in the dynamic symbol table of the executable.
+#
+build_vers_lib "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym ""
+build_exec "vers16" vers16.c vers16 "" vers16a.so "" vers16.dsym ""
diff --git a/ld/testsuite/ld-elfvers/vers1.c b/ld/testsuite/ld-elfvers/vers1.c
new file mode 100644
index 00000000000..1d41fd9d04b
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers1.c
@@ -0,0 +1,98 @@
+/*
+ * Basic test of versioning. The idea with this is that we define
+ * a bunch of definitions of the same symbol, and we can theoretically
+ * then link applications against varying sets of these.
+ */
+const char * show_bar1 = "asdf";
+const char * show_bar2 = "asdf";
+
+int
+bar()
+{
+ return 3;
+}
+
+/*
+ * The 'hide' prefix is something so that we can automatically search the
+ * symbol table and verify that none of these symbols were actually exported.
+ */
+int
+hide_original_foo()
+{
+ return 1+bar();
+
+}
+
+int
+hide_old_foo()
+{
+ return 10+bar();
+
+}
+
+int
+hide_old_foo1()
+{
+ return 100+bar();
+
+}
+
+int
+hide_new_foo()
+{
+ return 1000+bar();
+
+}
+
+__asm__(".symver hide_original_foo,show_foo@");
+__asm__(".symver hide_old_foo,show_foo@VERS_1.1");
+__asm__(".symver hide_old_foo1,show_foo@VERS_1.2");
+__asm__(".symver hide_new_foo,show_foo@@VERS_2.0");
+
+
+
+#ifdef DO_TEST10
+/* In test 10, we try and define a non-existant version node. The linker
+ * should catch this and complain. */
+int
+hide_new_bogus_foo()
+{
+ return 1000+bar();
+
+}
+__asm__(".symver hide_new_bogus_foo,show_foo@VERS_2.2");
+#endif
+
+
+
+
+#ifdef DO_TEST11
+/*
+ * This test is designed to catch a couple of syntactic errors. The assembler
+ * should complain about both of the directives below.
+ */
+int
+xyzzz()
+{
+ new2_foo();
+ bar33();
+}
+
+__asm__(".symver new2_foo,fooVERS_2.0");
+__asm__(".symver bar33,bar@@VERS_2.0");
+#endif
+
+#ifdef DO_TEST12
+/*
+ * This test is designed to catch a couple of syntactic errors. The assembler
+ * should complain about both of the directives below.
+ */
+int
+xyzzz()
+{
+ new2_foo();
+ bar33();
+}
+
+__asm__(".symver bar33,bar@@VERS_2.0");
+#endif
diff --git a/ld/testsuite/ld-elfvers/vers1.dsym b/ld/testsuite/ld-elfvers/vers1.dsym
new file mode 100644
index 00000000000..834434bc7f4
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers1.dsym
@@ -0,0 +1,9 @@
+[0]* g DO \*ABS\* [0]* VERS_1.1 VERS_1.1
+[0]* g DO \*ABS\* [0]* VERS_1.2 VERS_1.2
+[0]* g DO \*ABS\* [0]* VERS_2.0 VERS_2.0
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(Base\) (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(VERS_1.1\) (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(VERS_1.2\) (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_2.0 (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DO (.s?data|\*ABS\*) [0-9a-f]* VERS_2.0 show_bar1
+[0-9a-f]* g DO (.s?data|\*ABS\*) [0-9a-f]* VERS_2.0 show_bar2
diff --git a/ld/testsuite/ld-elfvers/vers1.map b/ld/testsuite/ld-elfvers/vers1.map
new file mode 100644
index 00000000000..8fc37bcaf0f
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers1.map
@@ -0,0 +1,16 @@
+VERS_1.1 {
+ global:
+ foo1;
+ local:
+ hide_old*;
+ hide_original*;
+ hide_new*;
+};
+
+VERS_1.2 {
+ foo2;
+} VERS_1.1;
+
+VERS_2.0 {
+ show_bar1; show_bar2;
+} VERS_1.2;
diff --git a/ld/testsuite/ld-elfvers/vers1.sym b/ld/testsuite/ld-elfvers/vers1.sym
new file mode 100644
index 00000000000..70ff85571fe
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers1.sym
@@ -0,0 +1,4 @@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@VERS_1.1
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@VERS_1.2
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@@VERS_2.0
diff --git a/ld/testsuite/ld-elfvers/vers1.ver b/ld/testsuite/ld-elfvers/vers1.ver
new file mode 100644
index 00000000000..3e7312b643e
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers1.ver
@@ -0,0 +1,8 @@
+Version definitions:
+1 0x01 0x0a26881f tmpdir/vers1.so
+2 0x00 0x0a7927b1 VERS_1.1
+3 0x00 0x0a7927b2 VERS_1.2
+ VERS_1.1
+4 0x00 0x0a7922b0 VERS_2.0
+ VERS_1.2
+
diff --git a/ld/testsuite/ld-elfvers/vers13.asym b/ld/testsuite/ld-elfvers/vers13.asym
new file mode 100644
index 00000000000..d446144e2d2
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers13.asym
@@ -0,0 +1,10 @@
+VERS_1.1 in vers1.so
+VERS_1.2 in vers1.so
+VERS_2.0 in vers1.so
+bar in vers1.so
+show_bar1 in vers1.so
+show_bar2 in vers1.so
+show_foo@ in vers1.so
+show_foo@@VERS_2.0 in vers1.so
+show_foo@VERS_1.1 in vers1.so
+show_foo@VERS_1.2 in vers1.so
diff --git a/ld/testsuite/ld-elfvers/vers15.c b/ld/testsuite/ld-elfvers/vers15.c
new file mode 100644
index 00000000000..d32be3ffd55
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers15.c
@@ -0,0 +1,35 @@
+/*
+ * Testcase to make sure that if we externally reference a versioned symbol
+ * that we always get the right one.
+ */
+
+int
+foo_1()
+{
+ return 1034;
+}
+
+int
+foo_2()
+{
+ return 1343;
+}
+
+int
+foo_3()
+{
+ return 1334;
+}
+
+int
+main()
+{
+ printf("Expect 4, get %d\n", foo_1());
+ printf("Expect 13, get %d\n", foo_2());
+ printf("Expect 103, get %d\n", foo_3());
+ return 0;
+}
+
+__asm__(".symver foo_1,show_foo@");
+__asm__(".symver foo_2,show_foo@VERS_1.1");
+__asm__(".symver foo_3,show_foo@@VERS_1.2");
diff --git a/ld/testsuite/ld-elfvers/vers15.dsym b/ld/testsuite/ld-elfvers/vers15.dsym
new file mode 100644
index 00000000000..1f5e15c4af0
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers15.dsym
@@ -0,0 +1,5 @@
+[0]* g DO \*ABS\* [0]* VERS_1.1 VERS_1.1
+[0]* g DO \*ABS\* [0]* VERS_1.2 VERS_1.2
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(Base\) (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(VERS_1.1\) (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_1.2 (0x[0-9a-f][0-9a-f] )?show_foo
diff --git a/ld/testsuite/ld-elfvers/vers15.sym b/ld/testsuite/ld-elfvers/vers15.sym
new file mode 100644
index 00000000000..87bab62c9e4
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers15.sym
@@ -0,0 +1,3 @@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@VERS_1.1
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo@@VERS_1.2
diff --git a/ld/testsuite/ld-elfvers/vers15.ver b/ld/testsuite/ld-elfvers/vers15.ver
new file mode 100644
index 00000000000..3d2ec588ffc
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers15.ver
@@ -0,0 +1,5 @@
+Version definitions:
+1 0x01 0x0d8a2605 tmpdir/vers15
+2 0x00 0x0a7927b2 VERS_1.2
+3 0x00 0x0a7927b1 VERS_1.1
+
diff --git a/ld/testsuite/ld-elfvers/vers16.c b/ld/testsuite/ld-elfvers/vers16.c
new file mode 100644
index 00000000000..6668bc60621
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16.c
@@ -0,0 +1,10 @@
+int show_bar ()
+{
+ return 0;
+}
+extern int show_foo ();
+
+int main ()
+{
+ return show_foo ();
+}
diff --git a/ld/testsuite/ld-elfvers/vers16.dsym b/ld/testsuite/ld-elfvers/vers16.dsym
new file mode 100644
index 00000000000..6c424c31738
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16.dsym
@@ -0,0 +1,2 @@
+[0-9a-f]* g DF (\.text|\*ABS\*) [0-9a-f]*( Base )? (0x[0-9a-f][0-9a-f] )?show_bar
+[0-9a-f]* DF \*UND\* [0-9a-f]*( )? (0x[0-9a-f][0-9a-f] )?show_foo
diff --git a/ld/testsuite/ld-elfvers/vers16.map b/ld/testsuite/ld-elfvers/vers16.map
new file mode 100644
index 00000000000..766332fcfb2
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16.map
@@ -0,0 +1,3 @@
+VERS_1.1 {
+ global: show_bar;
+};
diff --git a/ld/testsuite/ld-elfvers/vers16a.c b/ld/testsuite/ld-elfvers/vers16a.c
new file mode 100644
index 00000000000..153b1fdc779
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16a.c
@@ -0,0 +1,8 @@
+int show_bar ()
+{
+ return 1;
+}
+int show_foo ()
+{
+ return show_bar ();
+}
diff --git a/ld/testsuite/ld-elfvers/vers16a.dsym b/ld/testsuite/ld-elfvers/vers16a.dsym
new file mode 100644
index 00000000000..058df47ee8e
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16a.dsym
@@ -0,0 +1,3 @@
+[0-9a-f]* g DO (\.text|\*ABS\*) [0-9a-f]* VERS_1\.1 VERS_1\.1
+[0-9a-f]* g DF (\.text|\*ABS\*) [0-9a-f]* VERS_1\.1 (0x[0-9a-f][0-9a-f] )?show_bar
+[0-9a-f]* g DF (\.text|\*ABS\*) [0-9a-f]* Base (0x[0-9a-f][0-9a-f] )?show_foo
diff --git a/ld/testsuite/ld-elfvers/vers16a.ver b/ld/testsuite/ld-elfvers/vers16a.ver
new file mode 100644
index 00000000000..bccf1df7cc9
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers16a.ver
@@ -0,0 +1,3 @@
+Version definitions:
+1 0x01 0x0601cfbf tmpdir/vers16a.so
+2 0x00 0x0a7927b1 VERS_1.1
diff --git a/ld/testsuite/ld-elfvers/vers2.c b/ld/testsuite/ld-elfvers/vers2.c
new file mode 100644
index 00000000000..d6a537ea4fa
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers2.c
@@ -0,0 +1,10 @@
+/*
+ * Test function. This is built into a shared library, and references a
+ * versioned symbol foo that is in test.so.
+ */
+
+void
+show_xyzzy()
+{
+ printf("%d", show_foo());
+}
diff --git a/ld/testsuite/ld-elfvers/vers2.dsym b/ld/testsuite/ld-elfvers/vers2.dsym
new file mode 100644
index 00000000000..99985c237a3
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers2.dsym
@@ -0,0 +1,3 @@
+[0-9a-f]* DF \*UND\* [0-9a-f]* VERS_2.0 (0x[0-9a-f][0-9a-f] )?show_foo
+[0]* g DO \*ABS\* [0]* VERS_XXX_1.1 VERS_XXX_1.1
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_XXX_1.1 (0x[0-9a-f][0-9a-f] )?show_xyzzy
diff --git a/ld/testsuite/ld-elfvers/vers2.map b/ld/testsuite/ld-elfvers/vers2.map
new file mode 100644
index 00000000000..cd57d7e53bb
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers2.map
@@ -0,0 +1,4 @@
+
+VERS_XXX_1.1 {
+ show_xyzzy;
+};
diff --git a/ld/testsuite/ld-elfvers/vers2.ver b/ld/testsuite/ld-elfvers/vers2.ver
new file mode 100644
index 00000000000..b52634359b6
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers2.ver
@@ -0,0 +1,8 @@
+Version definitions:
+1 0x01 0x0a26181f tmpdir/vers2.so
+2 0x00 0x08785b51 VERS_XXX_1.1
+
+Version References:
+ required from tmpdir/vers1.so:
+ 0x0a7922b0 0x00 03 VERS_2.0
+
diff --git a/ld/testsuite/ld-elfvers/vers3.c b/ld/testsuite/ld-elfvers/vers3.c
new file mode 100644
index 00000000000..b006d7717e9
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers3.c
@@ -0,0 +1,10 @@
+/*
+ * Main program for test1, test2.
+ */
+
+int
+main()
+{
+ printf("%d\n", show_foo());
+ return 0;
+}
diff --git a/ld/testsuite/ld-elfvers/vers3.dsym b/ld/testsuite/ld-elfvers/vers3.dsym
new file mode 100644
index 00000000000..c9c2642389f
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers3.dsym
@@ -0,0 +1 @@
+[0-9a-f]* DF \*UND\* [0-9a-f]* VERS_2.0 (0x[0-9a-f][0-9a-f] )?show_foo
diff --git a/ld/testsuite/ld-elfvers/vers3.ver b/ld/testsuite/ld-elfvers/vers3.ver
new file mode 100644
index 00000000000..aa230eea3ee
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers3.ver
@@ -0,0 +1,4 @@
+Version References:
+ required from tmpdir/vers1.so:
+ 0x0a7922b0 0x00 02 VERS_2.0
+
diff --git a/ld/testsuite/ld-elfvers/vers4.c b/ld/testsuite/ld-elfvers/vers4.c
new file mode 100644
index 00000000000..15497cacc81
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers4.c
@@ -0,0 +1,27 @@
+/*
+ * Testcase to make sure that a versioned symbol definition in an
+ * application correctly defines the version node, if and only if
+ * the actual symbol is exported. This is built both with and without
+ * -export-dynamic.
+ */
+int
+bar()
+{
+ return 3;
+}
+
+int
+new_foo()
+{
+ return 1000+bar();
+
+}
+
+__asm__(".symver new_foo,foo@@VERS_2.0");
+
+int
+main()
+{
+ printf("%d\n", foo());
+ return 0;
+}
diff --git a/ld/testsuite/ld-elfvers/vers4.sym b/ld/testsuite/ld-elfvers/vers4.sym
new file mode 100644
index 00000000000..7449446e803
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers4.sym
@@ -0,0 +1 @@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?foo@@VERS_2.0
diff --git a/ld/testsuite/ld-elfvers/vers4a.dsym b/ld/testsuite/ld-elfvers/vers4a.dsym
new file mode 100644
index 00000000000..f7f9fdacfd6
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers4a.dsym
@@ -0,0 +1,2 @@
+[0]* g DO \*ABS\* [0]* VERS_2.0 VERS_2.0
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_2.0 (0x[0-9a-f][0-9a-f] )?foo
diff --git a/ld/testsuite/ld-elfvers/vers4a.sym b/ld/testsuite/ld-elfvers/vers4a.sym
new file mode 100644
index 00000000000..7449446e803
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers4a.sym
@@ -0,0 +1 @@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?foo@@VERS_2.0
diff --git a/ld/testsuite/ld-elfvers/vers4a.ver b/ld/testsuite/ld-elfvers/vers4a.ver
new file mode 100644
index 00000000000..876cedc87b3
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers4a.ver
@@ -0,0 +1,4 @@
+Version definitions:
+1 0x01 0x0d8a26e1 tmpdir/vers4a
+2 0x00 0x0a7922b0 VERS_2.0
+
diff --git a/ld/testsuite/ld-elfvers/vers5.c b/ld/testsuite/ld-elfvers/vers5.c
new file mode 100644
index 00000000000..cc6ea40b678
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers5.c
@@ -0,0 +1,51 @@
+/*
+ * Testcase to verify that foo@BAR and foo@@BAR are correctly detected
+ * as a multiply defined symbol.
+ */
+const char * bar1 = "asdf";
+const char * bar2 = "asdf";
+
+int
+bar()
+{
+ return 3;
+}
+
+int
+original_foo()
+{
+ return 1+bar();
+
+}
+
+int
+old_foo()
+{
+ return 10+bar();
+
+}
+
+int
+old_foo1()
+{
+ return 100+bar();
+
+}
+
+int
+new_foo()
+{
+ return 1000+bar();
+
+}
+
+__asm__(".symver original_foo,foo@");
+__asm__(".symver old_foo,foo@VERS_1.1");
+__asm__(".symver old_foo1,foo@VERS_1.2");
+__asm__(".symver new_foo,foo@@VERS_1.2");
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-elfvers/vers6.c b/ld/testsuite/ld-elfvers/vers6.c
new file mode 100644
index 00000000000..b5868bf3794
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers6.c
@@ -0,0 +1,19 @@
+/*
+ * Testcase to make sure that if we externally reference a versioned symbol
+ * that we always get the right one.
+ */
+
+int
+main()
+{
+ printf("Expect 4, get %d\n", foo_1());
+ printf("Expect 13, get %d\n", foo_2());
+ printf("Expect 103, get %d\n", foo_3());
+ printf("Expect 1003, get %d\n", foo_4());
+ return 0;
+}
+
+__asm__(".symver foo_1,show_foo@");
+__asm__(".symver foo_2,show_foo@VERS_1.1");
+__asm__(".symver foo_3,show_foo@VERS_1.2");
+__asm__(".symver foo_4,show_foo@VERS_2.0");
diff --git a/ld/testsuite/ld-elfvers/vers6.dsym b/ld/testsuite/ld-elfvers/vers6.dsym
new file mode 100644
index 00000000000..7e851d457ab
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers6.dsym
@@ -0,0 +1,4 @@
+[0-9a-f]* DF \*UND\* [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* DF \*UND\* [0-9a-f]* VERS_2.0 (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* DF \*UND\* [0-9a-f]* VERS_1.2 (0x[0-9a-f][0-9a-f] )?show_foo
+[0-9a-f]* DF \*UND\* [0-9a-f]* VERS_1.1 (0x[0-9a-f][0-9a-f] )?show_foo
diff --git a/ld/testsuite/ld-elfvers/vers6.sym b/ld/testsuite/ld-elfvers/vers6.sym
new file mode 100644
index 00000000000..d7b5cc75bbe
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers6.sym
@@ -0,0 +1,4 @@
+[0]* *F? *\*UND\* [0]* show_foo@
+[0]* *F? *\*UND\* [0]* show_foo@VERS_1.1
+[0]* *F? *\*UND\* [0]* show_foo@VERS_1.2
+[0]* *F? *\*UND\* [0]* show_foo@VERS_2.0
diff --git a/ld/testsuite/ld-elfvers/vers6.ver b/ld/testsuite/ld-elfvers/vers6.ver
new file mode 100644
index 00000000000..48a2b465f4c
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers6.ver
@@ -0,0 +1,6 @@
+Version References:
+ required from tmpdir/vers1.so:
+ 0x0a7927b1 0x00 ?? VERS_1.1
+ 0x0a7927b2 0x00 ?? VERS_1.2
+ 0x0a7922b0 0x00 ?? VERS_2.0
+
diff --git a/ld/testsuite/ld-elfvers/vers7.c b/ld/testsuite/ld-elfvers/vers7.c
new file mode 100644
index 00000000000..d25b7e00628
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7.c
@@ -0,0 +1,11 @@
+/*
+ * Test program that goes with test7.so
+ */
+
+
+int
+main()
+{
+ return hide_a(1) + show_b(1);
+ return 0;
+}
diff --git a/ld/testsuite/ld-elfvers/vers7.map b/ld/testsuite/ld-elfvers/vers7.map
new file mode 100644
index 00000000000..65fd501d2c3
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7.map
@@ -0,0 +1,6 @@
+VERS_1 {
+ global:
+ show_b ;
+ local:
+ hide_a;
+};
diff --git a/ld/testsuite/ld-elfvers/vers7a.c b/ld/testsuite/ld-elfvers/vers7a.c
new file mode 100644
index 00000000000..7bee8c70bfe
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7a.c
@@ -0,0 +1,18 @@
+/*
+ * Test supplied by Ulrich. Verify that we can correctly force 'a'
+ * to local scope.
+ */
+int
+__a_internal (int e)
+{
+ return e + 10;
+}
+
+int
+__b_internal (int e)
+{
+ return e + 42;
+}
+
+asm (".symver __a_internal,hide_a@@VERS_1");
+asm (".symver __b_internal,show_b@@VERS_1");
diff --git a/ld/testsuite/ld-elfvers/vers7a.dsym b/ld/testsuite/ld-elfvers/vers7a.dsym
new file mode 100644
index 00000000000..06696c75358
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7a.dsym
@@ -0,0 +1,2 @@
+[0]* g DO \*ABS\* [0]* VERS_1 VERS_1
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_1 (0x[0-9a-f][0-9a-f] )?show_b
diff --git a/ld/testsuite/ld-elfvers/vers7a.sym b/ld/testsuite/ld-elfvers/vers7a.sym
new file mode 100644
index 00000000000..b99bd61cc3c
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7a.sym
@@ -0,0 +1,2 @@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?hide_a@@VERS_1
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?show_b@@VERS_1
diff --git a/ld/testsuite/ld-elfvers/vers7a.ver b/ld/testsuite/ld-elfvers/vers7a.ver
new file mode 100644
index 00000000000..37ef8a824cc
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers7a.ver
@@ -0,0 +1,4 @@
+Version definitions:
+1 0x01 0x0269fd3f tmpdir/vers7a.so
+2 0x00 0x05aa7921 VERS_1
+
diff --git a/ld/testsuite/ld-elfvers/vers8.c b/ld/testsuite/ld-elfvers/vers8.c
new file mode 100644
index 00000000000..a14586cbc8a
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers8.c
@@ -0,0 +1,5 @@
+int
+main()
+{
+ return a(1) + b(1);
+}
diff --git a/ld/testsuite/ld-elfvers/vers8.map b/ld/testsuite/ld-elfvers/vers8.map
new file mode 100644
index 00000000000..26359559d9f
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers8.map
@@ -0,0 +1,18 @@
+VERSION {
+ VERS_1.1 {
+ global:
+ foo1;
+ local:
+ hide_old*;
+ hide_original*;
+ hide_new*;
+ };
+
+ VERS_1.2 {
+ foo2;
+ } VERS_1.1;
+
+ VERS_2.0 {
+ show_bar1; show_bar2;
+ } VERS_1.2;
+}
diff --git a/ld/testsuite/ld-elfvers/vers8.ver b/ld/testsuite/ld-elfvers/vers8.ver
new file mode 100644
index 00000000000..ef59023ccee
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers8.ver
@@ -0,0 +1,8 @@
+Version definitions:
+1 0x01 0x0a26f81f tmpdir/vers8.so
+2 0x00 0x0a7927b1 VERS_1.1
+3 0x00 0x0a7927b2 VERS_1.2
+ VERS_1.1
+4 0x00 0x0a7922b0 VERS_2.0
+ VERS_1.2
+
diff --git a/ld/testsuite/ld-elfvers/vers9.c b/ld/testsuite/ld-elfvers/vers9.c
new file mode 100644
index 00000000000..432fddb19b3
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers9.c
@@ -0,0 +1,45 @@
+/*
+ * Testcase to verify that reference to foo@BAR and a definition of foo@@BAR
+ * are not treated as a multiple def.
+ */
+const char * bar1 = "asdf";
+const char * bar2 = "asdf";
+
+int
+bar()
+{
+ return 3;
+}
+
+int
+original_foo()
+{
+ return 1+bar();
+
+}
+
+int
+old_foo()
+{
+ return 10+bar();
+
+}
+
+int
+new_foo()
+{
+ return 1000+bar();
+
+}
+
+int
+main()
+{
+ old_foo1();
+ return 0;
+}
+
+__asm__(".symver original_foo,foo@");
+__asm__(".symver old_foo,foo@VERS_1.1");
+__asm__(".symver old_foo1,foo@VERS_1.2");
+__asm__(".symver new_foo,foo@@VERS_1.2");
diff --git a/ld/testsuite/ld-elfvers/vers9.dsym b/ld/testsuite/ld-elfvers/vers9.dsym
new file mode 100644
index 00000000000..97930025842
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers9.dsym
@@ -0,0 +1,4 @@
+[0]* g DO \*ABS\* [0]* VERS_1.1 VERS_1.1
+[0]* g DO \*ABS\* [0]* VERS_1.2 VERS_1.2
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* \(VERS_1.1\) (0x[0-9a-f][0-9a-f] )?foo
+[0-9a-f]* g DF (.text|\*ABS\*) [0-9a-f]* VERS_1.2 (0x[0-9a-f][0-9a-f] )?foo
diff --git a/ld/testsuite/ld-elfvers/vers9.sym b/ld/testsuite/ld-elfvers/vers9.sym
new file mode 100644
index 00000000000..8231516bfc9
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers9.sym
@@ -0,0 +1,4 @@
+[0]* *F? *\*UND\* [0]* foo@VERS_1.2
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?foo@
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?foo@VERS_1.1
+[0-9a-f]* g F .text [0-9a-f]* (0x[0-9a-f][0-9a-f] )?foo@@VERS_1.2
diff --git a/ld/testsuite/ld-elfvers/vers9.ver b/ld/testsuite/ld-elfvers/vers9.ver
new file mode 100644
index 00000000000..673ba72ab45
--- /dev/null
+++ b/ld/testsuite/ld-elfvers/vers9.ver
@@ -0,0 +1,5 @@
+Version definitions:
+1 0x01 0x04d8a269 tmpdir/vers9
+2 0x00 0x0a7927b1 VERS_1.1
+3 0x00 0x0a7927b2 VERS_1.2
+
diff --git a/ld/testsuite/ld-empic/empic.exp b/ld/testsuite/ld-empic/empic.exp
new file mode 100644
index 00000000000..2d528bef1f6
--- /dev/null
+++ b/ld/testsuite/ld-empic/empic.exp
@@ -0,0 +1,263 @@
+# Expect script for ld-empic tests
+# Copyright (C) 1994,1995, 1996, 1997 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 "fail 1\n"
+ 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 "fail 2\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose $l
+
+ if [string match "*sll*" $l] {
+ continue
+ }
+ if ![regexp "lui (\[\$a-z0-9\]+),(\[0-9a-fA-Fx\]+)" $l whole reg upper] {
+ send_log "fail 3\n"
+ send_log "$line\n"
+ send_log "$l\n"
+ fail $testname
+ return
+ }
+
+ if { [gets $file l] == -1 } {
+ send_log "fail 4\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose "$l"
+ if ![regexp "addiu \\$reg,\\$reg,(\[-0-9\]+)" $l whole lower] {
+ send_log "fail 5\n"
+ 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 "fail 6\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose "$l"
+ if ![regexp "addu \\$reg,\\$reg,\\\$ra" $l] {
+ send_log "fail 7\n"
+ 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 "fail 8\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ verbose "$l"
+ 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 "fail 9\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ } else {
+ set dest [expr ($upper << 16) + $lower]
+ if ![regexp "<(\[.a-z\]+)\\+(\[0-9a-fA-F\]+)>" $label whole base offset] {
+ send_log "fail 10\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ set offset 0x$offset
+ if { $base == ".foo" } {
+ set offset [expr $offset - ($nm_output(foo) - 0x30)]
+ }
+ if { $offset + 8 != - $dest } {
+ send_log "fail 11\n"
+ send_log "$line\n"
+ fail $testname
+ return
+ }
+ }
+ }
+ }
+
+ close $file
+
+ if {$balcnt < 10} {
+ send_log "fail 12\n"
+ 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/ld/testsuite/ld-empic/relax.t b/ld/testsuite/ld-empic/relax.t
new file mode 100644
index 00000000000..8c18b69a86e
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/relax1.c b/ld/testsuite/ld-empic/relax1.c
new file mode 100644
index 00000000000..20ec39efc9c
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/relax2.c b/ld/testsuite/ld-empic/relax2.c
new file mode 100644
index 00000000000..58854a03aa9
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/relax3.c b/ld/testsuite/ld-empic/relax3.c
new file mode 100644
index 00000000000..1aaa532bc2f
--- /dev/null
+++ b/ld/testsuite/ld-empic/relax3.c
@@ -0,0 +1,3 @@
+/* Third source file in relaxation test. */
+
+int quux () { return 0; }
diff --git a/ld/testsuite/ld-empic/relax4.c b/ld/testsuite/ld-empic/relax4.c
new file mode 100644
index 00000000000..21cfb05b67d
--- /dev/null
+++ b/ld/testsuite/ld-empic/relax4.c
@@ -0,0 +1,3 @@
+/* Fourth source file in relaxation test. */
+
+int xyzzy () { return 0; }
diff --git a/ld/testsuite/ld-empic/run.c b/ld/testsuite/ld-empic/run.c
new file mode 100644
index 00000000000..9a0377e02e5
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/runtest1.c b/ld/testsuite/ld-empic/runtest1.c
new file mode 100644
index 00000000000..f9ab6eb6681
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/runtest2.c b/ld/testsuite/ld-empic/runtest2.c
new file mode 100644
index 00000000000..000525f11ea
--- /dev/null
+++ b/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/ld/testsuite/ld-empic/runtesti.s b/ld/testsuite/ld-empic/runtesti.s
new file mode 100644
index 00000000000..efa195301fb
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/cross1.c b/ld/testsuite/ld-scripts/cross1.c
new file mode 100644
index 00000000000..56789452a5b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/cross1.c
@@ -0,0 +1,6 @@
+extern int foo ();
+int
+func ()
+{
+ return foo ();
+}
diff --git a/ld/testsuite/ld-scripts/cross1.t b/ld/testsuite/ld-scripts/cross1.t
new file mode 100644
index 00000000000..e1948c9e09f
--- /dev/null
+++ b/ld/testsuite/ld-scripts/cross1.t
@@ -0,0 +1,6 @@
+NOCROSSREFS ( .text .data )
+SECTIONS
+{
+ .text : { tmpdir/cross1.o }
+ .data : { tmpdir/cross2.o }
+}
diff --git a/ld/testsuite/ld-scripts/cross2.c b/ld/testsuite/ld-scripts/cross2.c
new file mode 100644
index 00000000000..414317712d1
--- /dev/null
+++ b/ld/testsuite/ld-scripts/cross2.c
@@ -0,0 +1,5 @@
+int
+foo ()
+{
+ return 1;
+}
diff --git a/ld/testsuite/ld-scripts/cross2.t b/ld/testsuite/ld-scripts/cross2.t
new file mode 100644
index 00000000000..cf046f6c36b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/cross2.t
@@ -0,0 +1,6 @@
+NOCROSSREFS ( .text .data )
+SECTIONS
+{
+ .text : { *(.text) *(.pr) }
+ .data : { *(.data) *(.sdata) *(.rw) *(.tc0) *(.tc) }
+}
diff --git a/ld/testsuite/ld-scripts/cross3.c b/ld/testsuite/ld-scripts/cross3.c
new file mode 100644
index 00000000000..1848c32fd0b
--- /dev/null
+++ b/ld/testsuite/ld-scripts/cross3.c
@@ -0,0 +1,7 @@
+int i = 4;
+
+int
+foo ()
+{
+ return i;
+}
diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp
new file mode 100644
index 00000000000..fee97595a37
--- /dev/null
+++ b/ld/testsuite/ld-scripts/crossref.exp
@@ -0,0 +1,77 @@
+# Test NOCROSSREFS in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+
+set test1 "NOCROSSREFS 1"
+set test2 "NOCROSSREFS 2"
+
+if { [which $CC] == 0 } {
+ untested $test1
+ untested $test2
+ return
+}
+
+if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
+ || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
+ unresolved $test1
+ unresolved $test2
+ return
+}
+
+set flags ""
+
+# The a29k compiled code calls V_SPILL and V_FILL. Since we don't
+# need to run this code, but we don't have definitions for those
+# functions, we just define them out.
+if [istarget a29k*-*-*] {
+ set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
+}
+
+# hppa-elf needs a definition for $global$.
+if [istarget hppa*-*-*] {
+ set flags "$flags --defsym '\$global\$'=0"
+}
+
+verbose -log "$ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"
+
+catch "exec $ld $flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o" exec_output
+
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+ fail $test1
+} else {
+ verbose -log "$exec_output"
+ if [regexp "prohibited cross reference from .* to `foo' in" $exec_output] {
+ pass $test1
+ } else {
+ fail $test1
+ }
+}
+
+# Check cross references within a single object.
+
+if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
+ unresolved $test2
+ return
+}
+
+verbose -log "$ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"
+
+catch "exec $ld $flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o" exec_output
+
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+ fail $test2
+} else {
+ verbose -log "$exec_output"
+ if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
+ pass $test2
+ } else {
+ fail $test2
+ }
+}
diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
new file mode 100644
index 00000000000..6da26bc3bc2
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/defined.s b/ld/testsuite/ld-scripts/defined.s
new file mode 100644
index 00000000000..a364bbbbe6c
--- /dev/null
+++ b/ld/testsuite/ld-scripts/defined.s
@@ -0,0 +1,2 @@
+ .globl defined
+ defined = 1
diff --git a/ld/testsuite/ld-scripts/defined.t b/ld/testsuite/ld-scripts/defined.t
new file mode 100644
index 00000000000..c1ef1b6a798
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/phdrs.exp b/ld/testsuite/ld-scripts/phdrs.exp
new file mode 100644
index 00000000000..34ee00f899c
--- /dev/null
+++ b/ld/testsuite/ld-scripts/phdrs.exp
@@ -0,0 +1,57 @@
+# Test PHDRS in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+
+# PHDRS is only meaningful for ELF.
+if { ![istarget *-*-sysv4*] \
+ && ![istarget *-*-unixware*] \
+ && ![istarget *-*-elf*] \
+ && ![istarget *-*-eabi*] \
+ && ![istarget *-*-linux*] \
+ && ![istarget *-*-irix5*] \
+ && ![istarget *-*-irix6*] \
+ && ![istarget *-*-solaris2*] } {
+ return
+}
+
+if { [istarget *-*-linuxaout*] \
+ || [istarget *-*-linuxoldld*] } {
+ return
+}
+
+# This is a very simplistic test.
+
+set testname "PHDRS"
+
+if ![ld_assemble $as $srcdir/$subdir/phdrs.s tmpdir/phdrs.o] {
+ unresolved $testname
+ return
+}
+
+set phdrs_regexp \
+".*Program Header:.*PHDR *off *0x00*34 *vaddr *0x00*80034 *paddr *0x00*80034.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*80000 *paddr *0x00*80000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
+
+# On a 64 bit ELF format, we need different numbers.
+if { [istarget alpha*-*-*] } then {
+ set phdrs_regexp \
+".*Program Header:.*PHDR *off *0x00*40 *vaddr *0x00*80040 *paddr *0x00*80040.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*80000 *paddr *0x00*80000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
+}
+
+if ![ld_simple_link $ld tmpdir/phdrs "-T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"] {
+ fail $testname
+} else {
+ if {[which $objdump] == 0} {
+ unresolved $testname
+ return
+ }
+
+ verbose -log "$objdump --private tmpdir/phdrs"
+ catch "exec $objdump --private tmpdir/phdrs" exec_output
+ set exec_output [prune_warnings $exec_output]
+ verbose -log $exec_output
+
+ if [regexp $phdrs_regexp $exec_output] {
+ pass $testname
+ } else {
+ fail $testname
+ }
+}
diff --git a/ld/testsuite/ld-scripts/phdrs.s b/ld/testsuite/ld-scripts/phdrs.s
new file mode 100644
index 00000000000..ec1f0d17e6e
--- /dev/null
+++ b/ld/testsuite/ld-scripts/phdrs.s
@@ -0,0 +1,8 @@
+ .text
+
+ .long 1
+
+ .data
+
+ .long 2
+
diff --git a/ld/testsuite/ld-scripts/phdrs.t b/ld/testsuite/ld-scripts/phdrs.t
new file mode 100644
index 00000000000..8f710e23fdc
--- /dev/null
+++ b/ld/testsuite/ld-scripts/phdrs.t
@@ -0,0 +1,14 @@
+PHDRS
+{
+ header PT_PHDR PHDRS ;
+ text PT_LOAD FILEHDR PHDRS ;
+ data PT_LOAD ;
+}
+
+SECTIONS
+{
+ . = 0x80000 + SIZEOF_HEADERS;
+ .text : { *(.text) } :text
+ .data : { *(.data) } :data
+ /DISCARD/ : { *(.reginfo) }
+}
diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp
new file mode 100644
index 00000000000..fe0a0411188
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/script.s b/ld/testsuite/ld-scripts/script.s
new file mode 100644
index 00000000000..d7b65b0df55
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/script.t b/ld/testsuite/ld-scripts/script.t
new file mode 100644
index 00000000000..ee7a48a9f60
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/scriptm.t b/ld/testsuite/ld-scripts/scriptm.t
new file mode 100644
index 00000000000..57ccae13662
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sizeof.exp b/ld/testsuite/ld-scripts/sizeof.exp
new file mode 100644
index 00000000000..3bdefd4f0dc
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/sizeof.s b/ld/testsuite/ld-scripts/sizeof.s
new file mode 100644
index 00000000000..e221ca3c0b3
--- /dev/null
+++ b/ld/testsuite/ld-scripts/sizeof.s
@@ -0,0 +1 @@
+ .space 16
diff --git a/ld/testsuite/ld-scripts/sizeof.t b/ld/testsuite/ld-scripts/sizeof.t
new file mode 100644
index 00000000000..6244a37b7ac
--- /dev/null
+++ b/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/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp
new file mode 100644
index 00000000000..f69db5793cc
--- /dev/null
+++ b/ld/testsuite/ld-scripts/weak.exp
@@ -0,0 +1,57 @@
+# Test weak symbols.
+# By Ian Lance Taylor, Cygnus Solutions.
+
+set testname "weak symbols"
+
+# This test only works for ELF targets. It ought to work for some
+# a.out targets, but it doesn't.
+
+if { ![istarget *-*-sysv4*] \
+ && ![istarget *-*-unixware*] \
+ && ![istarget *-*-elf*] \
+ && ![istarget *-*-eabi*] \
+ && ![istarget *-*-linux*] \
+ && ![istarget *-*-irix5*] \
+ && ![istarget *-*-irix6*] \
+ && ![istarget *-*-solaris2*] } then {
+ return
+}
+
+if { [istarget *-*-linuxaout*] \
+ || [istarget *-*-linuxoldld*] } {
+ return
+}
+
+if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
+ || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
+ # It's OK if .weak doesn't work on this target.
+ unresolved $testname
+ return
+}
+
+set weak_regexp_big \
+".*Contents of section .text:.*1000 00001008 0000200c 12121212 34343434.*Contents of section .data:.*2000 00001008 0000200c 56565656 78787878.*"
+
+set weak_regexp_little \
+".*Contents of section .text:.*1000 08100000 0c200000 12121212 34343434.*Contents of section .data:.*2000 08100000 0c200000 56565656 78787878.*"
+
+if {! [ld_simple_link $ld tmpdir/weak "-T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
+ fail $testname
+} else {
+ if {[which $objdump] == 0} then {
+ unresolved $testname
+ return
+ }
+
+ verbose -log "$objdump -s tmpdir/weak"
+ catch "exec $objdump -s tmpdir/weak" exec_output
+ set exec_output [prune_warnings $exec_output]
+ verbose -log $exec_output
+
+ if {[regexp $weak_regexp_big $exec_output] \
+ || [regexp $weak_regexp_little $exec_output] } then {
+ pass $testname
+ } else {
+ fail $testname
+ }
+}
diff --git a/ld/testsuite/ld-scripts/weak.t b/ld/testsuite/ld-scripts/weak.t
new file mode 100644
index 00000000000..6cd013e11f7
--- /dev/null
+++ b/ld/testsuite/ld-scripts/weak.t
@@ -0,0 +1,12 @@
+SECTIONS
+{
+ .text 0x1000 : {
+ tmpdir/weak1.o(.data)
+ }
+ .data 0x2000 : {
+ tmpdir/weak2.o(.data)
+ }
+ /DISCARD/ : {
+ *(*)
+ }
+}
diff --git a/ld/testsuite/ld-scripts/weak1.s b/ld/testsuite/ld-scripts/weak1.s
new file mode 100644
index 00000000000..046fbe1fa46
--- /dev/null
+++ b/ld/testsuite/ld-scripts/weak1.s
@@ -0,0 +1,11 @@
+.data
+ .global foo1
+ .global sym1
+ .weak sym2
+foo1:
+ .long sym1
+ .long sym2
+sym1:
+ .long 0x12121212
+sym2:
+ .long 0x34343434
diff --git a/ld/testsuite/ld-scripts/weak2.s b/ld/testsuite/ld-scripts/weak2.s
new file mode 100644
index 00000000000..04edff5e541
--- /dev/null
+++ b/ld/testsuite/ld-scripts/weak2.s
@@ -0,0 +1,11 @@
+.data
+ .global foo2
+ .weak sym1
+ .global sym2
+foo2:
+ .long sym1
+ .long sym2
+sym1:
+ .long 0x56565656
+sym2:
+ .long 0x78787878
diff --git a/ld/testsuite/ld-selective/1.c b/ld/testsuite/ld-selective/1.c
new file mode 100644
index 00000000000..12023677027
--- /dev/null
+++ b/ld/testsuite/ld-selective/1.c
@@ -0,0 +1,12 @@
+/* _start should be the only thing left after GC. */
+
+void _start() __asm__("_start");
+void _start()
+{
+}
+
+void dropme1()
+{
+}
+
+int dropme2[102] = { 0 };
diff --git a/ld/testsuite/ld-selective/2.c b/ld/testsuite/ld-selective/2.c
new file mode 100644
index 00000000000..729588760c3
--- /dev/null
+++ b/ld/testsuite/ld-selective/2.c
@@ -0,0 +1,19 @@
+/* Normally we should loose foo and keep _start and _init.
+ With -u foo, we should keep that as well. */
+
+void _start() __asm__("_start");
+void _start()
+{
+}
+
+void __attribute__((section(".init")))
+_init()
+{
+}
+
+int foo() __asm__("foo");
+int foo()
+{
+ static int x = 1;
+ return x++;
+}
diff --git a/ld/testsuite/ld-selective/3.cc b/ld/testsuite/ld-selective/3.cc
new file mode 100644
index 00000000000..852bc5d0454
--- /dev/null
+++ b/ld/testsuite/ld-selective/3.cc
@@ -0,0 +1,33 @@
+struct A
+{
+ virtual void foo();
+ virtual void bar();
+};
+
+void A::foo() { } // keep
+void A::bar() { } // loose
+
+struct B : public A
+{
+ virtual void foo();
+};
+
+void B::foo() { } // keep
+
+void _start() __asm__("_start"); // keep
+
+A a; // keep
+B b;
+A *getme() { return &a; } // keep
+
+void _start()
+{
+ getme()->foo();
+}
+
+// In addition, keep A's virtual table.
+
+// We'll wind up keeping `b' and thus B's virtual table because
+// `a' and `b' are both referenced from the constructor function.
+
+extern "C" void __main() { }
diff --git a/ld/testsuite/ld-selective/4.cc b/ld/testsuite/ld-selective/4.cc
new file mode 100644
index 00000000000..9df26ac872c
--- /dev/null
+++ b/ld/testsuite/ld-selective/4.cc
@@ -0,0 +1,28 @@
+struct A
+{
+ virtual void foo();
+ virtual void bar();
+};
+
+void A::foo() { } // loose
+void A::bar() { } // keep
+
+struct B : public A
+{
+ virtual void foo();
+};
+
+void B::foo() { } // loose
+
+void _start() __asm__("_start"); // keep
+
+A a; // keep
+B b;
+A *getme() { return &a; } // keep
+
+void _start()
+{
+ getme()->bar();
+}
+
+extern "C" void __main() { }
diff --git a/ld/testsuite/ld-selective/5.cc b/ld/testsuite/ld-selective/5.cc
new file mode 100644
index 00000000000..5179d918481
--- /dev/null
+++ b/ld/testsuite/ld-selective/5.cc
@@ -0,0 +1,32 @@
+// This test currently fails because the C++ front end emits `A' as
+// the base class called rather than `B' as it ought. At least it
+// is erroring on the safe side...
+
+struct A
+{
+ virtual void foo();
+ virtual void bar();
+};
+
+void A::foo() { } // loose
+void A::bar() { } // loose
+
+struct B : public A
+{
+ virtual void foo();
+};
+
+void B::foo() { } // keep
+
+void _start() __asm__("_start"); // keep
+
+A a;
+B b; // keep
+B *getme() { return &b; } // keep
+
+void _start()
+{
+ getme()->foo();
+}
+
+extern "C" void __main() { }
diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
new file mode 100644
index 00000000000..e6a9d97fa69
--- /dev/null
+++ b/ld/testsuite/ld-selective/selective.exp
@@ -0,0 +1,208 @@
+# Expect script for LD selective linking tests
+# Copyright (C) 1998, 1999 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 Catherine Moore (clm@cygnus.com)
+# Make sure that constructors are handled correctly.
+
+
+# COFF based ports do not support selective linking
+if {[istarget "*-*-coff" "*-*-pe"]} {
+ return
+}
+
+set test1 "selective1"
+set test2 "selective2"
+set test3 "selective3"
+set test4 "selective4"
+set test5 "selective5"
+set test6 "selective6"
+
+set cflags "-w -O2 -ffunction-sections -fdata-sections"
+set cxxflags "-fvtable-gc -fno-exceptions -fno-rtti"
+set ldflags "--gc-sections -Bstatic"
+
+if { [which $CXX] == 0 } {
+ untested $test1
+ untested $test2
+ untested $test3
+ untested $test4
+ untested $test5
+ untested $test6
+ return
+}
+
+if { ![ld_compile "$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} {
+ unresolved $test1
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/1.x "$ldflags tmpdir/1.o"] {
+ fail $test1
+} else {
+ if ![ld_nm $nm tmpdir/1.x] {
+ unresolved $test1
+ } else {
+ if {[info exists nm_output(dropme1)]} {
+ send_log "dropme1 == $nm_output(dropme1)\n"
+ verbose "dropme1 == $nm_output(dropme1)"
+ fail $test1
+ } else {
+ if {[info exists nm_output(dropme2)]} {
+ send_log "dropme2 == $nm_output(dropme2)\n"
+ verbose "dropme2 == $nm_output(dropme2)"
+ fail $test1
+ } else {
+ pass $test1
+ }
+ }
+ }
+ }
+
+if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
+ unresolved $test2
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/2.x "$ldflags tmpdir/2.o"] {
+ fail $test2
+} else {
+ if ![ld_nm $nm tmpdir/2.x] {
+ unresolved $test2
+ } else {
+ if {[info exists nm_output(foo)] } {
+ send_log "foo == $nm_output(foo)\n"
+ verbose "foo== $nm_output(foo)"
+ fail $test2
+ } else {
+ pass $test2
+ }
+ }
+ }
+
+if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
+ unresolved $test3
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/2.x "$ldflags -u foo tmpdir/2.o"] {
+ fail $test3
+} else {
+ if ![ld_nm $nm tmpdir/2.x] {
+ unresolved $test3
+ } else {
+ if {![info exists nm_output(foo)] } {
+ send_log "bad output from nm\n"
+ verbose "bad output from nm"
+ fail $test3
+ } else {
+ if {$nm_output(foo) == 0} {
+ send_log "foo == $nm_output(foo)\n"
+ verbose "foo== $nm_output(foo)"
+ fail $test3
+ } else {
+ pass $test3
+ }
+ }
+ }
+}
+
+setup_xfail "v850*-*-elf"
+
+if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/3.cc tmpdir/3.o]} {
+ unresolved $test4
+ return
+}
+
+setup_xfail "v850*-*-elf"
+
+if ![ld_simple_link $ld tmpdir/3.x "$ldflags tmpdir/3.o"] {
+ fail $test4
+} else {
+ if ![ld_nm $nm tmpdir/3.x] {
+ unresolved $test4
+ } else {
+ if {[info exists nm_output(foo__1B)]} {
+ send_log "foo__1B == $nm_output(foo__1B)\n"
+ verbose "foo__1B == $nm_output(foo__1B)"
+ fail $test4
+ } else {
+ if {[ info exists nm_output(bar__1A)]} {
+ send_log "bar__1A== $nm_output(_bar__1A)\n"
+ verbose "bar__1A == $nm_output(_bar__1A)"
+ fail $test4
+ } else {
+ pass $test4
+ }
+ }
+ }
+}
+
+if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/4.cc tmpdir/4.o]} {
+ unresolved $test5
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/4.x "$ldflags tmpdir/4.o"] {
+ fail $test5
+} else {
+ if ![ld_nm $nm tmpdir/4.x] {
+ unresolved $test5
+ } else {
+ if {[info exists nm_output(foo__1B)]} {
+ send_log "foo__1B == $nm_output(foo__1B)\n"
+ verbose "foo__1B == $nm_output(foo__1B)"
+ fail $test5
+ } else {
+ if {[info exists nm_output(foo__1A)]} {
+ send_log "foo__1A== $nm_output(foo__1A)\n"
+ verbose "foo__1A == $nm_output(foo__1A)"
+ fail $test5
+ } else {
+ pass $test5
+ }
+ }
+ }
+}
+
+setup_xfail "v850*-*-elf"
+
+if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/5.cc tmpdir/5.o]} {
+ unresolved $test6
+ return
+}
+
+if ![ld_simple_link $ld tmpdir/5.x "$ldflags tmpdir/5.o"] {
+ fail $test6
+} else {
+ if ![ld_nm $nm tmpdir/5.x] {
+ unresolved $test6
+ } else {
+ if {[info exists nm_output(foo__1B)] } {
+ send_log "foo__1B == $nm_output(foo__1B)\n"
+ verbose "foo__1B == $nm_output(foo__1B)"
+ fail $test6
+ } else {
+ if { [info exists nm_output(foo__1A)]} {
+ send_log "foo__1A== $nm_output(foo__1A)\n"
+ verbose "foo__1A == $nm_output(foo__1A)"
+ fail $test6
+ } else {
+ pass $test6
+ }
+ }
+ }
+}
diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp
new file mode 100644
index 00000000000..c646d269a89
--- /dev/null
+++ b/ld/testsuite/ld-sh/sh.exp
@@ -0,0 +1,143 @@
+# Expect script for ld-sh tests
+# Copyright (C) 1995, 1996, 1997 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 "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
+ verbose "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 {
+ send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
+ verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
+ 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_warnings $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 "-O -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/ld/testsuite/ld-sh/sh1.s b/ld/testsuite/ld-sh/sh1.s
new file mode 100644
index 00000000000..d18e4390dcc
--- /dev/null
+++ b/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 4
diff --git a/ld/testsuite/ld-sh/sh2.c b/ld/testsuite/ld-sh/sh2.c
new file mode 100644
index 00000000000..527fe88ce5d
--- /dev/null
+++ b/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/ld/testsuite/ld-sh/start.s b/ld/testsuite/ld-sh/start.s
new file mode 100644
index 00000000000..2af4c799f33
--- /dev/null
+++ b/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/ld/testsuite/ld-shared/elf-offset.ld b/ld/testsuite/ld-shared/elf-offset.ld
new file mode 100644
index 00000000000..dfe429309a7
--- /dev/null
+++ b/ld/testsuite/ld-shared/elf-offset.ld
@@ -0,0 +1,168 @@
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = 0x100000;
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.text :
+ {
+ *(.rel.text)
+ *(.rel.text.*)
+ *(.rel.gnu.linkonce.t*)
+ }
+ .rela.text :
+ {
+ *(.rela.text)
+ *(.rela.text.*)
+ *(.rela.gnu.linkonce.t*)
+ }
+ .rel.data :
+ {
+ *(.rel.data)
+ *(.rel.data.*)
+ *(.rel.gnu.linkonce.d*)
+ }
+ .rela.data :
+ {
+ *(.rela.data)
+ *(.rela.data.*)
+ *(.rela.gnu.linkonce.d*)
+ }
+ .rel.rodata :
+ {
+ *(.rel.rodata)
+ *(.rel.rodata.*)
+ *(.rel.gnu.linkonce.r*)
+ }
+ .rela.rodata :
+ {
+ *(.rela.rodata)
+ *(.rela.rodata.*)
+ *(.rela.gnu.linkonce.r*)
+ }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.init : { *(.rel.init) }
+ .rela.init : { *(.rela.init) }
+ .rel.fini : { *(.rel.fini) }
+ .rela.fini : { *(.rela.fini) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { KEEP (*(.init)) }
+ .plt : { *(.plt) }
+ .text :
+ {
+ *(.text)
+ *(.text.*)
+ *(.stub)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.gnu.linkonce.t*)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .fini : { KEEP (*(.fini)) } =0x9090
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r*)
+ }
+ .rodata1 : { *(.rodata1) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = ALIGN(0x1000) + (. & (0x1000 - 1));
+ .data :
+ {
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d*)
+ SORT(CONSTRUCTORS)
+ }
+ .data1 : { *(.data1) }
+ .ctors :
+ {
+ /* gcc uses crtbegin.o to find the start of the constructors, so
+ we make sure it is first. Because this is a wildcard, it
+ doesn't matter if the user does not actually link against
+ crtbegin.o; the linker won't look for a file to match a
+ wildcard. The wildcard also means that it doesn't matter which
+ directory crtbegin.o is in. */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ }
+ .dtors :
+ {
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ }
+ .got : { *(.got.plt) *(.got) }
+ .dynamic : { *(.dynamic) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) *(.sdata.*) }
+ _edata = .;
+ PROVIDE (edata = .);
+ __bss_start = .;
+ .sbss : { *(.sbss) *(.scommon) }
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ /* Align here to ensure that the .bss section occupies space up to
+ _end. Align after .bss to ensure correct alignment even if the
+ .bss section disappears because there are no input sections. */
+ . = ALIGN(32 / 8);
+ }
+ . = ALIGN(32 / 8);
+ _end = . ;
+ PROVIDE (end = .);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /* These must appear regardless of . */
+}
diff --git a/ld/testsuite/ld-shared/main.c b/ld/testsuite/ld-shared/main.c
new file mode 100644
index 00000000000..4fcfdaa1271
--- /dev/null
+++ b/ld/testsuite/ld-shared/main.c
@@ -0,0 +1,81 @@
+/* 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;
+}
+
+/* This function overrides a function in the shared library. */
+
+int
+shlib_overriddencall2 ()
+{
+ return 8;
+}
+
+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_shlibcall2 () == %d\n", shlib_shlibcall2 ());
+ 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/ld/testsuite/ld-shared/sh1.c b/ld/testsuite/ld-shared/sh1.c
new file mode 100644
index 00000000000..e31e06a2594
--- /dev/null
+++ b/ld/testsuite/ld-shared/sh1.c
@@ -0,0 +1,166 @@
+/* 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 ();
+}
+
+#ifndef XCOFF_TEST
+/* This function calls a function defined in this object in the shared
+ library. The main program will override the called function. */
+
+extern int shlib_overiddencall2 ();
+
+int
+shlib_shlibcall2 ()
+{
+ return shlib_overriddencall2 ();
+}
+
+int
+shlib_overriddencall2 ()
+{
+ return 7;
+}
+#endif
+
+/* 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/ld/testsuite/ld-shared/sh2.c b/ld/testsuite/ld-shared/sh2.c
new file mode 100644
index 00000000000..013a4e0994f
--- /dev/null
+++ b/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/ld/testsuite/ld-shared/shared.dat b/ld/testsuite/ld-shared/shared.dat
new file mode 100644
index 00000000000..40ee37ff533
--- /dev/null
+++ b/ld/testsuite/ld-shared/shared.dat
@@ -0,0 +1,16 @@
+mainvar == 1
+overriddenvar == 2
+shlibvar1 == 3
+shlib_mainvar () == 1
+shlib_overriddenvar () == 2
+shlib_shlibvar1 () == 3
+shlib_shlibvar2 () == 4
+shlib_shlibcall () == 5
+shlib_shlibcall2 () == 8
+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/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
new file mode 100644
index 00000000000..8939c3d1928
--- /dev/null
+++ b/ld/testsuite/ld-shared/shared.exp
@@ -0,0 +1,264 @@
+# Expect script for ld-shared tests
+# Copyright (C) 1994, 1995, 1996, 1997, 1998 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 i386-*-linux*] \
+ && ![istarget i486-*-linux*] \
+ && ![istarget i586-*-linux*] \
+ && ![istarget m68k-*-linux*] \
+ && ![istarget mips*-*-irix5*] \
+ && ![istarget powerpc-*-elf*] \
+ && ![istarget powerpc-*-linux*] \
+ && ![istarget powerpc-*-sysv4*] \
+ && ![istarget sparc*-*-elf] \
+ && ![istarget sparc*-*-solaris2*] \
+ && ![istarget sparc*-*-sunos4*] \
+ && ![istarget rs6000*-*-aix*] \
+ && ![istarget powerpc*-*-aix*] } {
+ return
+}
+
+if { [istarget i386-*-linuxaout*] \
+ || [istarget i486-*-linuxaout*] \
+ || [istarget i586-*-linuxaout*] \
+ || [istarget i386-*-linuxoldld*] \
+ || [istarget i486-*-linuxoldld*] \
+ || [istarget i586-*-linuxoldld*] \
+ || [istarget m68k-*-linuxaout*] } {
+ 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 args } {
+ global ld
+ global srcdir
+ global subdir
+ global exec_output
+ global host_triplet
+ global tmpdir
+
+ if [llength $args] { set shldflags [lindex $args 0] } else { set shldflags "" }
+
+ # 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 $shldflags $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_warnings $exec_output]
+
+ if {![string match "" $exec_output]} then {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ fail "$testname"
+ return
+ }
+
+ pass "$testname"
+}
+
+if [istarget mips*-*-*] {
+ set picflag ""
+} else {
+ # 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 non PIC shared libraries don't permit some cases of
+ # overriding.
+ setup_xfail "*-*-sunos4*"
+ shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared
+
+ # Test ELF shared library relocations with a non-zero load
+ # address for the library. Near as I can tell, the R_*_RELATIVE
+ # relocations for various targets are broken in the case where
+ # the load address is not zero (which is the default).
+ setup_xfail "*-*-sunos4*"
+ shared_test shnp "shared (non PIC, load offset)" \
+ mainnp.o sh1np.o sh2np.o shared \
+ "-T $srcdir/$subdir/elf-offset.ld"
+ } }
+
+ # 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 non PIC shared libraries don't permit some cases of
+ # overriding.
+ 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/ld/testsuite/ld-shared/sun4.dat b/ld/testsuite/ld-shared/sun4.dat
new file mode 100644
index 00000000000..be0d87d0ea2
--- /dev/null
+++ b/ld/testsuite/ld-shared/sun4.dat
@@ -0,0 +1,16 @@
+mainvar == 1
+overriddenvar == 2
+shlibvar1 == 3
+shlib_mainvar () == 1
+shlib_overriddenvar () == 2
+shlib_shlibvar1 () == 3
+shlib_shlibvar2 () == 4
+shlib_shlibcall () == 5
+shlib_shlibcall2 () == 8
+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/ld/testsuite/ld-shared/xcoff.dat b/ld/testsuite/ld-shared/xcoff.dat
new file mode 100644
index 00000000000..a409d96a1ec
--- /dev/null
+++ b/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/ld/testsuite/ld-srec/sr1.c b/ld/testsuite/ld-srec/sr1.c
new file mode 100644
index 00000000000..d7de977412d
--- /dev/null
+++ b/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;
+}
+
+void
+__main ()
+{
+}
diff --git a/ld/testsuite/ld-srec/sr2.c b/ld/testsuite/ld-srec/sr2.c
new file mode 100644
index 00000000000..5736cfa468d
--- /dev/null
+++ b/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/ld/testsuite/ld-srec/sr3.cc b/ld/testsuite/ld-srec/sr3.cc
new file mode 100644
index 00000000000..8717c26f34b
--- /dev/null
+++ b/ld/testsuite/ld-srec/sr3.cc
@@ -0,0 +1,113 @@
+// This file is compiled and linked into the S-record format.
+
+#define FOO_MSG_LEN 80
+
+class Foo {
+ static int foos;
+ int i;
+ static const int 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;
+}
+
+void
+terminate(void)
+{
+ /* This recursive call prevents a compiler warning that the noreturn
+ function terminate actually does return. */
+ terminate ();
+}
+
+extern "C" {
+void
+__main ()
+{
+}
+
+void
+__builtin_delete ()
+{
+}
+
+void
+__builtin_new ()
+{
+}
+
+void
+__throw ()
+{
+}
+
+void
+__terminate ()
+{
+}
+
+void *__eh_pc;
+
+void ***
+__get_dynamic_handler_chain ()
+{
+ return 0;
+}
+
+void *
+__get_eh_context ()
+{
+ return 0;
+}
+
+}
+
+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/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
new file mode 100644
index 00000000000..63a70ab7bcf
--- /dev/null
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -0,0 +1,374 @@
+# 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
+
+ set flags ""
+
+ # 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 flags "$flags -Ttext 0x1000"
+ }
+
+ # The a29k compiled code calls V_SPILL and V_FILL. Since we don't
+ # need to run this code, but we don't have definitions for those
+ # functions, we just define them out.
+ if [istarget a29k*-*-*] {
+ set flags "$flags --defsym V_SPILL=0 --defsym V_FILL=0"
+ }
+
+ # ARM targets call __gccmain
+ if [istarget arm-*-*] {
+ set flags "$flags --defsym ___gccmain=0"
+ }
+
+ if [istarget strongarm-*-*] {
+ set flags "$flags --defsym __gccmain=0"
+ }
+
+ # Thumb targets call __gccmain
+ if [istarget thumb-*-*] {
+ set flags "$flags --defsym ___gccmain=0"
+ }
+
+ # PowerPC EABI code calls __eabi.
+ if [istarget powerpc*-*-eabi*] {
+ set flags "$flags --defsym __eabi=0"
+ }
+
+ # mn10200 code calls __truncsipsi2_d0_d2.
+ if {[istarget mn10200*-*-*]} then {
+ set flags "$flags --defsym __truncsipsi2_d0_d2=0"
+ }
+
+ # V850 targets need libgcc.a
+ if [istarget v850*-*-elf] {
+ set objs "$objs -L ../gcc -lgcc"
+ }
+
+ if { ![ld_simple_link $ld tmpdir/sr1 "$flags $objs"] \
+ || ![ld_simple_link $ld tmpdir/sr2.sr "$flags -oformat srec $objs"] } {
+ setup_xfail "hppa*-*-*elf*"
+ 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_warnings $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
+}
+
+# The i386-aout target is confused: the linker does not put the
+# sections where objdump finds them. I don't know which is wrong.
+setup_xfail "i*86-*-aout*"
+
+# These tests fail on the native MIPS ELF targets because the GP value
+# in the .reginfo section is not updated when the S-record version is
+# written out. The mips-elf target itself does not use a .reginfo section.
+setup_xfail "mips*-*-irix5*" "mips*-*-irix6*"
+
+# The S-record linker doesn't do the magic TOC handling that XCOFF
+# linkers do.
+setup_xfail "*-*-aix*" "*-*-xcoff*"
+
+# The S-record linker doesn't build ARM/Thumb stubs.
+setup_xfail "arm-*-coff"
+setup_xfail "strongarm-*-*"
+setup_xfail "arm-*-pe*"
+# setup_xfail "arm-*elf*"
+setup_xfail "thumb-*-coff*"
+setup_xfail "thumb-*-pe*"
+setup_xfail "thumb-*-elf*"
+
+# The S-record linker doesn't build special EABI sections.
+setup_xfail "powerpc*-*-eabi*"
+
+# The S-record linker doesn't include the .{zda} sections.
+setup_xfail "v850*-*-elf"
+
+# The S-record linker doesn't handle Alpha Elf relaxation.
+setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*"
+setup_xfail "alpha*-*-netbsd*"
+
+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
+}
+
+# See above.
+setup_xfail "i*86-*-aout*"
+setup_xfail "mips*-*-irix5*" "mips*-*-irix6*"
+setup_xfail "*-*-aix*" "*-*-xcoff*"
+setup_xfail "arm-*-*"
+setup_xfail "strongarm-*-*"
+setup_xfail "thumb-*-*"
+setup_xfail "powerpc*-*-eabi*"
+setup_xfail "v850*-*-elf"
+setup_xfail "alpha*-*-elf*" "alpha*-*-linux-gnu*" "alpha*-*-gnu*"
+setup_xfail "alpha*-*-netbsd*"
+
+run_srec_test $test2 "tmpdir/sr3.o"
diff --git a/ld/testsuite/ld-undefined/undefined.c b/ld/testsuite/ld-undefined/undefined.c
new file mode 100644
index 00000000000..ef2aec6d6e5
--- /dev/null
+++ b/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/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-undefined/undefined.exp
new file mode 100644
index 00000000000..29b3bddc41d
--- /dev/null
+++ b/ld/testsuite/ld-undefined/undefined.exp
@@ -0,0 +1,126 @@
+# Test that the linker reports undefined symbol errors correctly.
+# By Ian Lance Taylor, Cygnus Support
+#
+# Copyright (C) 1995, 1996, 1997 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 } {
+ verbose "Could not find C compiler!" 1
+ untested $testund
+ untested $testfn
+ untested $testline
+ return
+}
+
+if ![ld_compile "$CC -g" $srcdir/$subdir/undefined.c tmpdir/undefined.o] {
+ verbose "Unable to compile test file!" 1
+ 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*"
+#setup_xfail "thumb*-*-pe*"
+
+# Just doesn't work for PA ELF. No clue why.
+setup_xfail "hppa*-*-*elf*"
+
+set mf "tmpdir/undefined.o: In function `function':"
+checkund $mf $testfn
+
+# 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*"
+#setup_xfail "thumb*-*-pe*"
+
+# Just doesn't work for PA ELF. No clue why.
+setup_xfail "hppa*-*-*elf*"
+
+set ml "undefined.c:9: undefined reference to `this_function_is_not_defined'"
+# With targets that use elf/dwarf2, such as the arm-elf and thumb-elf
+# toolchains, the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called
+# in order to locate the file name/line number where the undefined
+# reference occurs. Unfortunately this tries to use the dwarf2 debug
+# information held in the .debug_info section. This section contains a series
+# of comp_unit structures, each of which has a low/high address range
+# representing the span of memory locations covered by that structure. The
+# structures also index into other structures held in the .debug_line section
+# and together they can translate memory locations back into file/function/line
+# number addresses in the source code. Since the information about the memory
+# region covered by a comp_unit is only determined at link time, the low/high
+# addresses in the .debug_info section and the line addresses in the .debug_line
+# section are computed by generating relocs against known symbols in the object
+# code.
+#
+# When the undefined reference is detected, the relocs in the dwarf2
+# debug sections have not yet been resolved, so the low/high addresses and the
+# line number address are all set at zero. Thus when _bfd_elf_find_nearest_line()
+# calls _bfd_dwarf2_find_nearest_line() no comp_unit can be found which
+# actually covers the address where the reference occured, and so
+# _bfd_elf_find_nearest_line() fails.
+#
+# The upshot of all of this, is that the error message reported by the
+# linker, instead of having a source file name & line number as in:
+#
+# undefined.c:9: undefined reference to `this_function_is_not_defined'
+#
+# has an object file & section address instead:
+#
+# undefined.0(.text+0xc): undefined reference to `this_function_is_not_defined'
+#
+# hence the xfails below.
+
+setup_xfail arm-*-elf
+setup_xfail strongarm-*-elf
+setup_xfail thumb-*-elf
+
+checkund $ml $testline
diff --git a/ld/testsuite/ld-versados/t1-1.ro b/ld/testsuite/ld-versados/t1-1.ro
new file mode 100644
index 00000000000..1d70d8091de
--- /dev/null
+++ b/ld/testsuite/ld-versados/t1-1.ro
Binary files differ
diff --git a/ld/testsuite/ld-versados/t1-2.ro b/ld/testsuite/ld-versados/t1-2.ro
new file mode 100644
index 00000000000..8d4dc591084
--- /dev/null
+++ b/ld/testsuite/ld-versados/t1-2.ro
Binary files differ
diff --git a/ld/testsuite/ld-versados/t1.ld b/ld/testsuite/ld-versados/t1.ld
new file mode 100644
index 00000000000..1a5c4e3aac0
--- /dev/null
+++ b/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/ld/testsuite/ld-versados/t1.ook b/ld/testsuite/ld-versados/t1.ook
new file mode 100644
index 00000000000..3984b94ee5e
--- /dev/null
+++ b/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/ld/testsuite/ld-versados/t2-1.ro b/ld/testsuite/ld-versados/t2-1.ro
new file mode 100644
index 00000000000..633a7cc8856
--- /dev/null
+++ b/ld/testsuite/ld-versados/t2-1.ro
Binary files differ
diff --git a/ld/testsuite/ld-versados/t2-2.ro b/ld/testsuite/ld-versados/t2-2.ro
new file mode 100644
index 00000000000..704a79d947f
--- /dev/null
+++ b/ld/testsuite/ld-versados/t2-2.ro
Binary files differ
diff --git a/ld/testsuite/ld-versados/t2-3.ro b/ld/testsuite/ld-versados/t2-3.ro
new file mode 100644
index 00000000000..d95934218d2
--- /dev/null
+++ b/ld/testsuite/ld-versados/t2-3.ro
Binary files differ
diff --git a/ld/testsuite/ld-versados/t2.ld b/ld/testsuite/ld-versados/t2.ld
new file mode 100644
index 00000000000..5e1e413d160
--- /dev/null
+++ b/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/ld/testsuite/ld-versados/t2.ook b/ld/testsuite/ld-versados/t2.ook
new file mode 100644
index 00000000000..03f24a5f8f8
--- /dev/null
+++ b/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/ld/testsuite/ld-versados/versados.exp b/ld/testsuite/ld-versados/versados.exp
new file mode 100644
index 00000000000..2d2c0663bed
--- /dev/null
+++ b/ld/testsuite/ld-versados/versados.exp
@@ -0,0 +1,99 @@
+# Expect script for ld-versados tests
+# Copyright (C) 1995, 1996, 1997 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/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
new file mode 100644
index 00000000000..24a41310901
--- /dev/null
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -0,0 +1,327 @@
+#
+# 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_warnings $tmp]
+ regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" $tmp version cyg number
+ if [info exists number] then {
+ clone_output "$ld $number\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
+ }
+
+ verbose -log "$ld $HOSTING_EMU -o $target -r $objects"
+
+ catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ verbose -log "$exec_output"
+ return 0
+ }
+}
+
+
+#
+# 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
+ }
+
+ verbose -log "$ld $HOSTING_EMU -o $target $objs $libs"
+
+ catch "exec $ld $HOSTING_EMU -o $target $objs $libs" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ verbose -log "$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
+ }
+
+ verbose -log "$ld -o $target $objects"
+
+ catch "exec $ld -o $target $objects" exec_output
+ set exec_output [prune_warnings $exec_output]
+
+ # We don't care if we get a warning about a non-existent start
+ # symbol, since the default linker script might use ENTRY.
+ regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ verbose -log "$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
+ global gcc_gas_flag
+
+ 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
+
+ set flags "-I$srcdir/$subdir $CFLAGS"
+
+ # If we are compiling with gcc, we want to add gcc_gas_flag to
+ # flags. Rather than determine this in some complex way, we guess
+ # based on the name of the compiler.
+ if {[string match "*gcc*" $cc] || [string match "*++*" $cc]} then {
+ set flags "$gcc_gas_flag $flags"
+ }
+
+ verbose -log "$cc $flags -c $source -o $object"
+
+ catch "exec $cc $flags -c $source -o $object" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ if {![file exists $object]} then {
+ regexp ".*/(\[^/\]*)$" $source all dobj
+ regsub "\\.c" $dobj ".o" realobj
+ verbose "looking for $realobj"
+ if {[file exists $realobj]} then {
+ verbose -log "mv $realobj $object"
+ catch "exec mv $realobj $object" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if {![string match "" $exec_output]} then {
+ verbose -log "$exec_output"
+ perror "could not move $realobj to $object"
+ return 0
+ }
+ } else {
+ perror "$object not found after compilation"
+ return 0
+ }
+ }
+ return 1
+ } else {
+ verbose -log "$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 "" }
+
+ verbose -log "$as $ASFLAGS -o $object $source"
+
+ catch "exec $as $ASFLAGS -o $object $source" exec_output
+ set exec_output [prune_warnings $exec_output]
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ verbose -log "$exec_output"
+ perror "$source: assembly failed"
+ return 0
+ }
+}
+
+#
+# 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 "" }
+
+ verbose -log "$nm $NMFLAGS $object >tmpdir/nm.out"
+
+ catch "exec $nm $NMFLAGS $object >tmpdir/nm.out" exec_output
+ set exec_output [prune_warnings $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] {
+ set name [string trimleft $name "_"]
+ verbose "Setting nm_output($name) to 0x$value" 2
+ set nm_output($name) 0x$value
+ }
+ }
+ close $file
+ return 1
+ } else {
+ verbose -log "$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 -log "\t$file_1: $i: $line_a\n"
+ verbose -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_warnings]] {
+ #
+ # prune_warnings -- delete various system verbosities from TEXT
+ #
+ # An example is:
+ # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9
+ #
+ # Sites with particular verbose os's may wish to override this in site.exp.
+ #
+ proc prune_warnings { 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
+ }
+}