public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Run more ld tests when not native
@ 2017-01-02 13:35 Alan Modra
  2017-01-02 16:05 ` Christophe Lyon
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Alan Modra @ 2017-01-02 13:35 UTC (permalink / raw)
  To: binutils

Many of the ld tests are not run for cross builds, in some cases
because the test needs to run a newly linked executable, and in others
simply because it was easier to write the test for native only.  Even
when a test needs to run, it's good to compile and link to exercise
the linker.  So that's what this patch does.  I've also rid us of
the old ld_link procedure with all the HOSTING_CRT0 etc. setup.  It's
much simpler to just link with $CC.

This does mean that a cross build with cross-compiler installed but
no cross C-library will give lots of failures.  If that turns out to
be too annoying, I guess we can write a tcl procedure to detect it and
not run all the extra tests.

	* Makefile.am (bootstrap): Delete rule.
	(ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
	(HOSTING_CRT0, HOSTING_SCRT0): Don't define.
	(HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
	* configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
	(HOSTING_LIBS, HOSTING_SLIBS): Likewise.
	* configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/config/default.exp (get_link_files): Delete.
	(HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
	define.
	(ld_simple_link): Delete.
	* testsuite/lib/ld-lib.exp (default_ld_link): Delete
	(default_ld_simple_link): Rename to default_ld_link.
	(ld_simple_link_defsyms): Rename to ld_link_defsyms.
	(run_ld_link_tests): Use ld_link, not ld_simple_link.
	(run_cc_link_tests): Likewise.
	(run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
	Don't run exe when not native, and return unsupported.
	* testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
	Link ld1 etc. using $CC.
	* testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
	* testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
	* testsuite/ld-cygwin/exe-export.exp: Likewise.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/eh-group.exp: Likewise.
	* testsuite/ld-elf/exclude.exp: Likewise.
	* testsuite/ld-elf/frame.exp: Likewise.
	* testsuite/ld-elf/sec-to-seg.exp: Likewise.
	* testsuite/ld-elf/tls_common.exp: Likewise.
	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
	* testsuite/ld-fastcall/fastcall.exp: Likewise.
	* testsuite/ld-gc/gc.exp: Likewise.
	* testsuite/ld-ifunc/binutils.exp: Likewise.
	* testsuite/ld-mep/mep.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
	* testsuite/ld-mn10300/mn10300.exp: Likewise.
	* testsuite/ld-nios2/nios2.exp: Likewise.
	* testsuite/ld-pe/pe-compile.exp: Likewise.
	* testsuite/ld-pe/pe-run.exp: Likewise.
	* testsuite/ld-pe/pe-run2.exp: Likewise.
	* testsuite/ld-plugin/plugin.exp: Likewise.
	* testsuite/ld-scripts/align.exp: Likewise.
	* testsuite/ld-scripts/alignof.exp: Likewise.
	* testsuite/ld-scripts/assert.exp: Likewise.
	* testsuite/ld-scripts/defined.exp: Likewise.
	* testsuite/ld-scripts/extern.exp: Likewise.
	* testsuite/ld-scripts/log2.exp: Likewise.
	* testsuite/ld-scripts/map-address.exp: Likewise.
	* testsuite/ld-scripts/phdrs.exp: Likewise.
	* testsuite/ld-scripts/phdrs2.exp: Likewise.
	* testsuite/ld-scripts/script.exp: Likewise.
	* testsuite/ld-scripts/section-flags.exp: Likewise.
	* testsuite/ld-scripts/sizeof.exp: Likewise.
	* testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
	* testsuite/ld-scripts/weak.exp: Likewise.
	* testsuite/ld-selective/selective.exp: Likewise.
	* testsuite/ld-sh/sh.exp: Likewise.
	* testsuite/ld-sh/sh64/relax.exp: Likewise.
	* testsuite/ld-sh/sh64/relfail.exp: Likewise.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/ld-tic6x/tic6x.exp: Likewise.
	* testsuite/ld-undefined/weak-undef.exp: Likewise.
	* testsuite/ld-versados/versados.exp: Likewise.
	* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
	* testsuite/ld-xtensa/coalesce.exp: Likewise.
	* testsuite/ld-xtensa/diff_overflow.exp: Likewise.
	* testsuite/ld-xtensa/lcall.exp: Likewise.
	* testsuite/ld-elf/audit.exp: Run non-native too.
	* testsuite/ld-elf/compress.exp: Likewise.  Replace ld options with
	gcc -Wl, options.
	* testsuite/ld-elf/dwarf.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Add -Wl,--no-as-needed to some tests.
	* testsuite/ld-elf/elf.exp: Run non-native too.  Formatting.
	* testsuite/ld-elf/indirect.exp: Run non-native too.  Add
	-Wl,--no-as-needed to most tests.
	* testsuite/ld-elf/shared.exp: Run non-native too.  Use braces
	to simplify quoting.  Set run_tests using [list] rather than
	brace assignment to expand $extralibs.  Add -Wl,--no-as-needed
	to many test.  Prefix ld options with -Wl,.
	(mix_pic_and_non_pic): Don't run exe if not native.
	* testsuite/ld-elf/wrap.exp: Run non-native too.  Add
	-Wl,--no-as-needed and prefix ld options with -Wl,.
	* testsuite/ld-elfvers/vers.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	(visibility_test): Don't run exe if not native.
	* testsuite/ld-elfweak/elfweak.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.
	(build_exec): Don't run exe if not native.
	* testsuite/ld-ifunc/ifunc.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
	to some tests and prefix ld options with -Wl,.  Expect GNU
	for hppa-linux even when no ifuncs.  Delete cleanup.
	* testsuite/ld-pie/pie.exp: Run non-native too.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.  Use ld_link,
	not ld_simple_link.
	(shared_test): Don't run exe if not native.
	* testsuite/ld-size/size.exp: Run non-native too.  Add
	-Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
	* testsuite/ld-unique/unique.exp: Run non-native too.  Use ld_link,
	not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
	to some tests and prefix ld options with -Wl,.  Expect GNU
	for hppa-linux even when no unique syms.  Delete cleanup.
	* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
	tests and prefix ld options with -Wl,.
	* testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
	Add -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 21e0aeb..3a3e34d 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -88,13 +88,6 @@ TEXI2POD = perl $(BASEDIR)/etc/texi2pod.pl $(AM_MAKEINFOFLAGS)
 POD2MAN = pod2man --center="GNU Development Tools" \
 	--release="binutils-$(VERSION)" --section=1
 
-#stuff for self hosting (can be overridden in config file).
-HOSTING_CRT0 = @HOSTING_CRT0@
-HOSTING_SCRT0 = @HOSTING_SCRT0@
-HOSTING_LIBS = @HOSTING_LIBS@
-HOSTING_SLIBS = @HOSTING_SLIBS@
-HOSTING_EMU = -m $(EMUL)
-
 # Setup the testing framework, if you have one
 EXPECT = expect
 RUNTEST = runtest
@@ -2118,60 +2111,6 @@ check-DEJAGNU: site.exp
 	else echo "WARNING: could not find \`runtest'" 1>&2; :;\
 	fi
 
-# Rules for testing by relinking ld itself.
-# A similar test is in the testsuite.  This target is for ease of use
-# when porting ld.
-
-ld-partial.@OBJEXT@: ld-new$(EXEEXT)
-	./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld-partial.@OBJEXT@ -r $(OFILES)
-ld1$(EXEEXT): ld-partial.@OBJEXT@
-	./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld1$(EXEEXT) $(HOSTING_CRT0) ld-partial.@OBJEXT@ $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
-
-ld1-full$(EXEEXT): ld-new
-	./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld1-full$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
-
-ld2$(EXEEXT): ld1$(EXEEXT)
-	./ld1$(EXEEXT) $(HOSTING_EMU) -o ld2$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
-
-ld3$(EXEEXT): ld2$(EXEEXT)
-	./ld2$(EXEEXT) $(HOSTING_EMU) -o ld3$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
-
-bootstrap: ld3$(EXEEXT)
-	cmp ld2$(EXEEXT) ld3$(EXEEXT)
-
-.PHONY: bootstrap
-
-# A test program for C++ constructors and destructors.
-# This test is now in the testsuite.
-#
-#cdtest: cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ ld.new
-#	./ld.new $(HOSTING_EMU) -o cdtest $(HOSTING_CRT0) \
-#	  cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ $(HOSTING_LIBS)
-#
-#cdtest.out: cdtest
-#	./cdtest > cdtest.tmp
-#	mv cdtest.tmp cdtest.out
-#
-#cdtest-ur.@OBJEXT@: cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ ld.new
-#	./ld.new $(HOSTING_EMU) -o cdtest-ur.@OBJEXT@ -Ur cdtest-main.@OBJEXT@ \
-#	  cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@
-#
-#cdtest-ur: cdtest-ur.@OBJEXT@
-#	./ld.new $(HOSTING_EMU) -o cdtest-ur $(HOSTING_CRT0) cdtest-ur.@OBJEXT@ \
-#	  $(HOSTING_LIBS)
-#
-#cdtest-ur.out: cdtest-ur
-#	./cdtest-ur > cdtest-ur.tmp
-#	mv cdtest-ur.tmp cdtest-ur.out
-#
-#check-cdtest: cdtest.out cdtest-ur.out $(srcdir)/cdtest.exp
-#	diff $(srcdir)/cdtest.exp cdtest.out
-#	diff $(srcdir)/cdtest.exp cdtest-ur.out
-#
-#.PHONY: check-cdtest
-
-# END OF CHECK TARGETS
-
 #
 # Build a dummy plugin using libtool.
 #
diff --git a/ld/configure.ac b/ld/configure.ac
index 36a9f50..fe8eff6 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -206,10 +206,6 @@ ACX_PROG_CMP_IGNORE_INITIAL
 . ${srcdir}/configure.host
 
 AC_SUBST(HDEFINES)
-AC_SUBST(HOSTING_CRT0)
-AC_SUBST(HOSTING_SCRT0)
-AC_SUBST(HOSTING_LIBS)
-AC_SUBST(HOSTING_SLIBS)
 AC_SUBST(NATIVE_LIB_DIRS)
 
 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
diff --git a/ld/configure.host b/ld/configure.host
index 7632793..331ec0e 100644
--- a/ld/configure.host
+++ b/ld/configure.host
@@ -22,237 +22,10 @@
 
 # This file sets the following shell variables:
 #  HDEFINES		host specific compiler flags
-#  HOSTING_CRT0		crt0.o file used for bootstrapping
-#  HOSTING_LIBS		libraries used for bootstrapping
 
 HDEFINES=
-HOSTING_CRT0=/lib/crt0.o
-HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ]; then libgcc=../gcc/libgcc.a; else libgcc=\`${CC} -print-libgcc-file-name\`; fi; if [ -f ../gcc/libgcc_eh.a ]; then libgcc="$$libgcc ../gcc/libgcc_eh.a"; else libgcc_eh=\`${CC} -print-file-name=libgcc_eh.a\`; if [ x"$$libgcc_eh" != xlibgcc_eh.a ]; then libgcc="$$libgcc $$libgcc_eh"; fi; fi; if [ -f ../gcc/libunwind.a ]; then libgcc="$$libgcc ../gcc/libunwind.a"; else libunwind=\`${CC} -print-file-name=libunwind.a\`; if [ x"$$libunwind" != xlibunwind.a ]; then libgcc="$$libgcc $$libunwind"; fi; fi; echo --start-group $$libgcc -lc --end-group`'
-
-#
-#	Generic configurations:
-#
 
 case "${host}" in
-
-*-*-dragonfly*)
-  HOSTING_CRT0='-dynamic-linker `[ -f \`${CC} --print-prog-name=ld-elf.so.2\` ] || echo /usr/libexec/``${CC} --print-prog-name=ld-elf.so.2` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `${CC} --print-file-name=crtbegin.o`'
-  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
-  ;;
-
-*-*-freebsd* | *-*-kfreebsd*-gnu)
-  HOSTING_CRT0='-dynamic-linker `[ -f \`${CC} --print-prog-name=ld-elf.so.1\` ] || echo /usr/libexec/``${CC} --print-prog-name=ld-elf.so.1` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `${CC} --print-file-name=crtbegin.o`'
-  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
-  ;;
-
-*-*-linux*aout* | *-*-linux*oldld)
-  HOSTING_CRT0=/usr/lib/crt0.o
-  ;;
-
-*-*-linux*libc1*)
-  HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else ${CC} --print-file-name=crtend.o; fi` /usr/lib/crtn.o'
-  ;;
-
-*-*-linux*)
-  HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[ 	][ 	]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
-  HOSTING_SCRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[ 	][ 	]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=Scrt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbeginS.o ]; then echo ../gcc/crtbeginS.o; else ${CC} --print-file-name=crtbeginS.o; fi`'
-  HOSTING_SLIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtendS.o ]; then echo ../gcc/crtendS.o; else ${CC} --print-file-name=crtendS.o; fi` `${CC} --print-file-name=crtn.o`'
-  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
-  ;;
-
-*-*-gnu*)
-  # When creating static executables, we ought to use crt0.o instead of crt1.o,
-  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
-  # but the testing infrastructure is not prepared for that.  This is not
-  # relevant for most tests, and the few remaining ones have been XFAILed.
-  HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[ 	][ 	]*\(.*/ld[^ ]*\.so[^ 	]*\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
-  ;;
-
-*-*-netbsd*)
-  # Different versions of NetBSD with the ELF object format use different
-  # sets of start/end files.
-  HOSTING_CRT0='-dynamic-linker /usr/libexec/ld.elf_so /usr/lib/crt0.o'
-  if [ -f `${CC} --print-file-name=crti.o` ]; then
-    # Support for GCC's crtstuff present.
-    HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crti.o`"
-    if [ -f ../gcc/crtbegin.o ]; then
-      HOSTING_CRT0="$HOSTING_CRT0 ../gcc/crtbegin.o"
-    else
-      HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crtbegin.o`"
-    fi
-  else
-    # Support for GCC's crtstuff not present.
-    HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crtbegin.o`"
-  fi
-  if [ -f `${CC} --print-file-name=crtn.o` ]; then
-    # Support for GCC's crtstuff present.
-    if [ -f ../gcc/crtbegin.o ]; then
-      HOSTING_LIBS="$HOSTING_LIBS ../gcc/crtend.o"
-    else
-      HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtend.o`"
-    fi
-    HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtn.o`"
-  else
-    # Support for GCC's crtstuff not present.
-    HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtend.o`"
-  fi
-  ;;
-
-*-*-openbsd*)
-  HOSTING_CRT0="-dynamic-linker /usr/libexec/ld.so /usr/lib/crt0.o"
-  HOSTING_CRT0="$HOSTING_CRT0 /usr/lib/crtbegin.o"
-  HOSTING_LIBS="$HOSTING_LIBS /usr/lib/crtend.o"
-  ;;
-
+     m88*-*-dgux*)
+	HDEFINES=-D__using_DGUX ;;
 esac
-
-#
-# Now more specific configurations
-#
-
-case "${host}" in
-
-*-*-linux*aout* | *-*-linux*oldld | *-*-linux*libc1*)
-  # No further tweaking needed
-  ;;
-
-arm*-*-linux-*)
-  HOSTING_CRT0='-p '"$HOSTING_CRT0"
-  ;;
-
-hppa*64*-*-hpux11*)
-  HOSTING_CRT0=/usr/ccs/lib/pa20_64/crt0.o
-  # Even if CC is not gcc, the tests use gcc.
-  HOSTING_LIBS='--start-group `if [ -f ../gcc/libgcc.a ]; then echo ../gcc/libgcc.a; else if test "$GCC" = yes; then ${CC} --print-libgcc-file-name; else gcc --print-libgcc-file-name; fi fi` -lc --end-group /usr/lib/pa20_64/milli.a'
-  ;;
-
-i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[12] | i[3-7]86-*-freebsd[12]\.* | i[3-7]86-*-freebsd*aout*)
-  HOSTING_CRT0=/usr/lib/crt0.o
-  ;;
-
-i[3-7]86-*-sysv4*)
-  HOSTING_CRT0='/usr/ccs/lib/crt1.o /usr/ccs/lib/crti.o /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` /usr/ccs/lib/crtn.o'
-  ;;
-
-i[3-7]86-sequent-ptx* | i[3-7]86-sequent-sysv*)
-  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi`'
-  ;;
-
-i[3-7]86-*-sysv*)
-  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; fi` /lib/crtn.o'
-  ;;
-
-i[3-7]86-*-solaris*)
-  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
-  ;;
-
-i[3-7]86-*-sco* | i[3-7]86-*-isc*)
-  # In some configurations gcc does not use crtbegin.o and crtend.o.
-  # In that case gcc -print-file-name=crtbegin.o will simply print
-  # crtbegin.o.  We create dummy crtbegin.o and crtend.o files to
-  # handle this.
-  echo "int dummy_crtbegin () { return 0; }" > crtbegin.c
-  ${CC} -c crtbegin.c -o crtbegin.o
-  rm -f crtbegin.c
-  echo "int dummy_crteng () { return 0; }" > crtend.c
-  ${CC} -c crtend.c -o crtend.o
-  rm -f crtend.c
-  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` /lib/crtn.o'
-  ;;
-
-i[3-7]86-pc-interix*)
-  HOSTING_CRT0='$$INTERIX_ROOT/usr/lib/crt0.o'
-  HOSTING_LIBS='-L $$X/local_bin -L $$INTERIX_ROOT/usr/lib '"$HOSTING_LIBS"' -lcpsx -lc -lcpsx $$INTERIX_ROOT/usr/lib/psxdll.a $$INTERIX_ROOT/usr/lib/psxdll2.a'
-  ;;
-
-i[3-7]86-*-cygwin* | x86_64-*-cygwin*)
-  HOSTING_LIBS="$HOSTING_LIBS"' -lcygwin -L/usr/lib/w32api -luser32 -lkernel32 -ladvapi32 -lshell32 `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else ${CC} -print-libgcc-file-name; fi`'
-  ;;
-
-i[3-7]86-*-mingw*)
-  #We only support msvcrt.dll, crtid == 2.
-  HOSTING_CRT0='/mingw/lib/crt2.o'
-  HOSTING_LIBS='-L/mingw/lib -lmingw32 -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lmoldname -lmingwex -lmsvcrt `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else ${CC} -print-libgcc-file-name; fi`'
-  ;;
-
-mips*-sgi-irix4* | mips*-sgi-irix5*)
-  HOSTING_CRT0=/usr/lib/crt1.o
-  HOSTING_LIBS="$HOSTING_LIBS"' /usr/lib/crtn.o'
-  ;;
-
-mips*-sgi-irix6*)
-  HOSTING_CRT0='/usr/lib32/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o ; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS='-L/usr/lib32 '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o ; else ${CC} -print-file-name=crtend.o; fi` /usr/lib32/crtn.o -init __do_global_ctors -fini __do_global_dtors'
-  ;;
-
-m68*-motorola-sysv)
-  HOSTING_CRT0='`if [ -f ../gcc/crt0.o ]; then echo ../gcc/crt0.o; elif [ -f \`${CC} -print-file-name=\`crt0.o ]; then echo \`${CC} -print-file-name=\`crt0.o; else echo /lib/crt0.o; fi`'
-  HOSTING_LIBS=`sed -e 's,-lc,-lc881,' <<EOF
-$HOSTING_LIBS
-EOF`
-  ;;
-
-m68*-sun-*)
-  HOSTING_CRT0='/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o'
-  ;;
-
-m88*-*-dgux*)
-  HDEFINES=-D__using_DGUX
-  HOSTING_CRT0='/lib/crt0.o -X'
-  HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a
-  ;;
-
-m88*-motorola-sysv3)
-  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi`'
-  ;;
-
-sparc-*-solaris2*)
-  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
-  ;;
-
-sparc64-*-solaris2* | sparcv9-*-solaris2*)
-  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/sparcv9/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
-  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
-  ;;
-
-*-*-dragonfly*)
-  ;;
-
-*-*-freebsd* | *-*-kfreebsd*-gnu)
-  ;;
-
-*-*-linux* | *-*-gnu*)
-  ;;
-
-*-*-netbsd*)
-  ;;
-
-*-*-openbsd*)
-  ;;
-
-alpha*-*-*)
-  HOSTING_CRT0=/usr/ccs/lib/crt0.o
-  ;;
-
-esac
-
-# Provide default HOSTING_SCRT0.  Each host should define a proper one
-# if needed.
-if test -z "$HOSTING_SCRT0"; then
-  HOSTING_SCRT0="$HOSTING_CRT0"
-fi
-
-# Provide default HOSTING_SLIBS.  Each host should define a proper one
-# if needed.
-if test -z "$HOSTING_SLIBS"; then
-  HOSTING_SLIBS="$HOSTING_LIBS"
-fi
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 33cc19d..899943c 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -114,26 +114,6 @@ if { [istarget rx-*-*] } {
 # 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] {
-	#configure.host returns variables that can be substituted into
-	#makefile rules, with embedded shell variable expansions.
-	#make wants $$shell_var, we want $shell_var ...
-	set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' <<EOF\n\$$varname\nEOF"
-	set status [catch "exec sh -c [list $cmd]" result]
-	if $status { error "Error getting native link files: $result" }
-	set cmd "CC='$CC' && eval echo \"$result\""
-	set status [catch "exec sh -c [list $cmd]" result]
-	if $status { error "Error getting native link files: $result" }
-	set $varname $result
-	send_log "$varname = $result\n"
-    }
-}
-
 proc get_target_emul {} {
     global target_triplet
     global srcdir
@@ -142,13 +122,6 @@ proc get_target_emul {} {
     return $result
 }
 
-if [isnative] {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
-	get_link_files $x
-    }
-} else {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
-}
 if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
 
 #
@@ -190,14 +163,6 @@ proc 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
 #
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 726b3fe..9a68ebe 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -48,13 +48,25 @@ if [check_plugin_api_available] {
 # 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.
-set test_flags {"" "strip" "--static" "--traditional-format"
-		"--no-keep-memory" "--relax"}
+set test_flags {"" "strip" "--static" "-Wl,--traditional-format"
+		"-Wl,--no-keep-memory" "-Wl,--relax"}
 if { [istarget "powerpc-*-*"] } {
-    lappend test_flags "--ppc476-workaround"
+    lappend test_flags "-Wl,--ppc476-workaround"
+}
+
+set gcc_B_opt_save $gcc_B_opt
+
+foreach ldexe {ld1 ld2 ld3} {
+    if {![file isdirectory tmpdir/gcc$ldexe]} then {
+	catch "exec mkdir tmpdir/gcc$ldexe" status
+	catch "exec ln -s ../$ldexe tmpdir/gcc$ldexe/ld" status
+	catch "exec ln -s ld tmpdir/gcc$ldexe/collect-ld" status
+	catch "exec ln -s ../../../gas/as-new tmpdir/gcc$ldexe/as" status
+    }
 }
 
 foreach flags $test_flags {
+    set gcc_B_opt $gcc_B_opt_save
     set do_strip "no"
     if {"$flags" == "strip"} { 
 	set testname "bootstrap with $flags"
@@ -67,8 +79,8 @@ foreach flags $test_flags {
     }}
 
     # --static is meaningless and --relax is incompatible with -r.
-    set partial_flags "$flags"
-    if { "$flags" == "--static" || "$flags" == "--relax" } {
+    regsub -- "-Wl," $flags "" partial_flags
+    if { "$partial_flags" == "--static" || "$partial_flags" == "--relax" } {
 	set partial_flags ""
     }
 
@@ -140,7 +152,7 @@ foreach flags $test_flags {
 	setup_xfail "mips*-*-irix5*"
     }
 
-    if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
+    if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
 	fail $testname
 	continue
     }
@@ -155,36 +167,27 @@ foreach flags $test_flags {
 	}
     }
 
-    if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
+    regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
+    if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
 	fail $testname
 	continue
     }
 
-    if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
+    regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
+    if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
 	fail $testname
 	continue
     }
 
-    if {"$flags" == "--static"} {
-	if { [istarget ia64-*-elf*]
-	     || [istarget ia64-*-linux*] } {
-	    # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
-	    # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
-	    # So we rebuild tmpdir/ld2 with tmpdir/ld3.
-	    if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
-		fail $testname
-		continue
-	    }
-	}
-    } else {
-	if { [istarget mips*-*-linux*] } {
-	    # On Linux/mips, tmpdir/ld2 != tmpdir/ld3 is normal since
-	    # they are generated by different linkers, tmpdir/ld1 and
-	    # tmpdir/ld2. So we rebuild tmpdir/ld2 with tmpdir/ld3.
-	    if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
-		fail $testname
-		continue
-	    }
+    if { "$flags" == "--static" && { [istarget ia64-*-elf*] || [istarget ia64-*-linux*] }
+	 || [istarget mips*-*-linux*] } {
+	# On ia64 and mips, tmpdir/ld2 != tmpdir/ld3 is normal since they are
+	# generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
+	# So we rebuild tmpdir/ld2 with tmpdir/ld3.
+	regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
+	if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
+	    fail $testname
+	    continue
 	}
     }
 
@@ -222,5 +225,6 @@ foreach flags $test_flags {
     }
 }
 
+set gcc_B_opt $gcc_B_opt_save
 catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
 catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status
diff --git a/ld/testsuite/ld-cdtest/cdtest.exp b/ld/testsuite/ld-cdtest/cdtest.exp
index 31eb957..7920de5 100644
--- a/ld/testsuite/ld-cdtest/cdtest.exp
+++ b/ld/testsuite/ld-cdtest/cdtest.exp
@@ -48,7 +48,7 @@ if {   ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.
 
 set expected_output "$srcdir/$subdir/cdtest.dat"
 
-if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
+if ![ld_link $CC 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"
@@ -95,7 +95,7 @@ if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/c
 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] {
+    if ![ld_link $CC tmpdir/cdtest tmpdir/cdtest.o] {
 	fail $test2
     } else {
 	send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
diff --git a/ld/testsuite/ld-checks/checks.exp b/ld/testsuite/ld-checks/checks.exp
index 9775b34..b1c8454 100644
--- a/ld/testsuite/ld-checks/checks.exp
+++ b/ld/testsuite/ld-checks/checks.exp
@@ -43,7 +43,7 @@ proc section_check {} {
 	return
     }
 
-    if ![ld_simple_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
+    if ![ld_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
 	fail $test
     } else {
 	pass $test
@@ -55,7 +55,7 @@ proc section_check {} {
     # script is used.
     set ldflags "--check-sections -T $srcdir/$subdir/script -e foo"
 
-    # Perform the equivalent of invoking ld_simple_link
+    # Perform the equivalent of invoking ld_link
     # except that we need to massage the output further.
 
     set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"]
diff --git a/ld/testsuite/ld-cygwin/exe-export.exp b/ld/testsuite/ld-cygwin/exe-export.exp
index 4643bac..f3bf275 100644
--- a/ld/testsuite/ld-cygwin/exe-export.exp
+++ b/ld/testsuite/ld-cygwin/exe-export.exp
@@ -63,7 +63,7 @@ proc run_dlltool { lib_file def_file } {
 }
 
 # ld_special_link
-#       A copy of ld_simple_link (from ld-lib.exp) with extra
+#       A copy of ld_link (from ld-lib.exp) with extra
 #       code to strip warnings about creating libraries.
 #
 proc ld_special_link { ld target objects } {
diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
index b278ec1..aad5339 100644
--- a/ld/testsuite/ld-elf/audit.exp
+++ b/ld/testsuite/ld-elf/audit.exp
@@ -25,11 +25,6 @@ if ![is_elf_format] {
     return
 }
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 2a41bdf..61e6031 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -61,7 +61,7 @@ proc binutils_test { prog_name ld_options test {test_name ""} {readelf_options "
 	return
     }
 
-    if { ![ld_simple_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } {
+    if { ![ld_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } {
 	if { [string match "*not supported*" $link_output]
 	     || [string match "*unrecognized option*" $link_output]
 	     || [string match "*-z relro ignored*" $link_output] } {
diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
index a5c154f..b2b6ca1 100644
--- a/ld/testsuite/ld-elf/compress.exp
+++ b/ld/testsuite/ld-elf/compress.exp
@@ -25,11 +25,6 @@ if ![is_elf_format] {
     return
 }
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
@@ -92,22 +87,22 @@ set run_tests {
      "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o" ""
      {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
     {"Run zlibnormal with libzlibfoo.so with zlib compressed debug sections"
-     "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o --compress-debug-sections=zlib" ""
+     "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
      {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
     {"Run zlibnormal with libfoozlib.so with zlib compressed debug sections"
-     "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib" ""
+     "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
      {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
     {"Run gnunormal with libgnufoo.so with zlib-gnu compressed debug sections"
-     "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
+     "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
      {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
     {"Run gnunormal with libfoozlib.so with zlib-gnu compressed debug sections"
-     "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
+     "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
      {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
     {"Run gabinormal with libgabifoo.so with zlib-gabi compressed debug sections"
-     "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
+     "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
      {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
     {"Run gabinormal with libfoozlib.so with zlib-gabi compressed debug sections"
-     "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
+     "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
      {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
 }
 
diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp
index 86b4896..572c704 100644
--- a/ld/testsuite/ld-elf/dwarf.exp
+++ b/ld/testsuite/ld-elf/dwarf.exp
@@ -29,11 +29,6 @@ if ![is_elf_format] {
     return
 }
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
@@ -52,7 +47,7 @@ set build_tests {
 
 set run_tests {
     {"Run with libdwarf1.so first"
-     "tmpdir/libdwarf1.so" ""
+     "-Wl,--no-as-needed tmpdir/libdwarf1.so" ""
      {dwarf1main.c} "dwarf1a" "dwarf1.out"
      "-g -feliminate-dwarf2-dups"}
     {"Run with libdwarf1.so last"
@@ -73,7 +68,7 @@ proc strip_test {} {
     set test_name "Strip -s $test"
     set prog $strip
 
-    if ![ld_simple_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
+    if ![ld_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
 	unresolved "$test_name"
 	return
     }
diff --git a/ld/testsuite/ld-elf/eh-group.exp b/ld/testsuite/ld-elf/eh-group.exp
index 17dd2f9..59f6092 100644
--- a/ld/testsuite/ld-elf/eh-group.exp
+++ b/ld/testsuite/ld-elf/eh-group.exp
@@ -65,7 +65,7 @@ set build_tests_ld [list			\
 run_ld_link_tests $build_tests_ld
 
 set testname "Link eh-group.o to eh-group"
-if [ld_simple_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
+if [ld_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
     pass $testname
 } else {
     fail $testname
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index e8b2d64..a5244e4 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -221,11 +221,6 @@ if { [istarget *-*-*linux*]
 
 set LDFLAGS $old_ldflags
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 if [check_gc_sections_available] {
     run_cc_link_tests {
 	{"PR ld/13195" "-Wl,--gc-sections" ""
@@ -234,23 +229,36 @@ if [check_gc_sections_available] {
 }
 
 set array_tests {
-    {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"}
-    {"init array" "" "" {init.c} "init" "init.out"}
-    {"fini array" "" "" {fini.c} "fini" "fini.out"}
-    {"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
+    {"preinit array" "" ""
+	{preinit.c} "preinit" "preinit.out"}
+    {"init array" "" ""
+	{init.c} "init" "init.out"}
+    {"fini array" "" ""
+	{fini.c} "fini" "fini.out"}
+    {"init array mixed" "" ""
+	{init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
 }
 set array_tests_pie {
-    {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" }
-    {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"}
-    {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"}
-    {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
-    {"PIE PR ld/14525" "-pie" "" {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
+    {"PIE preinit array" "-pie" ""
+	{preinit.c} "preinit" "preinit.out" "-fPIE"}
+    {"PIE init array" "-pie" ""
+	{init.c} "init" "init.out" "-fPIE"}
+    {"PIE fini array" "-pie" ""
+	{fini.c} "fini" "fini.out" "-fPIE"}
+    {"PIE init array mixed" "-pie" ""
+	{init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
+    {"PIE PR ld/14525" "-pie" ""
+	{pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
 }
 set array_tests_static {
-    {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"}
-    {"static init array" "-static" "" {init.c} "init" "init.out"}
-    {"static fini array" "-static" "" {fini.c} "fini" "fini.out"}
-    {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
+    {"static preinit array" "-static" ""
+	{preinit.c} "preinit" "preinit.out"}
+    {"static init array" "-static" ""
+	{init.c} "init" "init.out"}
+    {"static fini array" "-static" ""
+	{fini.c} "fini" "fini.out"}
+    {"static init array mixed" "-static" ""
+	{init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
 }
 
 # NetBSD ELF systems do not currently support the .*_array sections.
diff --git a/ld/testsuite/ld-elf/exclude.exp b/ld/testsuite/ld-elf/exclude.exp
index 438fd02..9b6dd2f 100644
--- a/ld/testsuite/ld-elf/exclude.exp
+++ b/ld/testsuite/ld-elf/exclude.exp
@@ -70,7 +70,7 @@ if {![string match "" $catch_output]} {
 
 # Test that the symbol is normally exported.
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
+if { [ld_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
     pass $test1
 } else {
     if [string match "*shared not supported*" $link_output] {
@@ -92,7 +92,7 @@ if ![ld_nm $nm "-D" tmpdir/exclude.so] {
 
 # Test --exclude-libs libexclude
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
     pass $test3
 } else {
     fail $test3
@@ -109,7 +109,7 @@ if ![ld_nm $nm "-D" tmpdir/exclude.so] {
 
 # Test alternate spellings of --exclude-libs
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
      && [ld_nm $nm "-D" tmpdir/exclude.so]
      && ! [info exists nm_output(exclude_common)]
      && ! [info exists nm_output(exclude_sym)] } {
@@ -118,7 +118,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared
     fail $test5
 }
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
      && [ld_nm $nm "-D" tmpdir/exclude.so]
      && ! [info exists nm_output(exclude_common)]
      && ! [info exists nm_output(exclude_sym)] } {
@@ -127,7 +127,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/e
     fail $test6
 }
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
      && [ld_nm $nm "-D" tmpdir/exclude.so]
      && ! [info exists nm_output(exclude_common)]
      && ! [info exists nm_output(exclude_sym)] } {
@@ -136,7 +136,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --sh
     fail $test7
 }
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
      && [ld_nm $nm "-D" tmpdir/exclude.so]
      && ! [info exists nm_output(exclude_common)]
      && ! [info exists nm_output(exclude_sym)] } {
@@ -145,7 +145,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --sh
     fail $test8
 }
 
-if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
+if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
      && [ld_nm $nm "-D" tmpdir/exclude.so]
      && [info exists nm_output(exclude_common)]
      && [info exists nm_output(exclude_sym)] } {
diff --git a/ld/testsuite/ld-elf/frame.exp b/ld/testsuite/ld-elf/frame.exp
index 3363568..0ddd77e 100644
--- a/ld/testsuite/ld-elf/frame.exp
+++ b/ld/testsuite/ld-elf/frame.exp
@@ -64,7 +64,7 @@ if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/tbss.s tmpdir/tbss.o ]
     return
 }
 
-if { [ld_simple_link $ld tmpdir/frame.so "--shared tmpdir/frame.o tmpdir/tbss.o"] } {
+if { [ld_link $ld tmpdir/frame.so "--shared tmpdir/frame.o tmpdir/tbss.o"] } {
     pass "$test1"
 } else {
     if [string match "*shared not supported*" $link_output] {
@@ -79,7 +79,7 @@ if ![ld_assemble_flags $as $as_opt $srcdir/$subdir/table.s tmpdir/table.o ] {
     return
 }
 
-if { [ld_simple_link $ld tmpdir/table.so "--shared tmpdir/table.o tmpdir/tbss.o"] } {
+if { [ld_link $ld tmpdir/table.so "--shared tmpdir/table.o tmpdir/tbss.o"] } {
     pass "$test2"
 } else {
     if [string match "*shared not supported*" $link_output] {
diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp
index a650505..5c5382c 100644
--- a/ld/testsuite/ld-elf/indirect.exp
+++ b/ld/testsuite/ld-elf/indirect.exp
@@ -126,59 +126,54 @@ set testname "Indirect symbol 2"
 set cmd "$ld -shared  -o tmpdir/indirect2.so tmpdir/indirect2.o"
 check_link_message "$cmd" [list $string2 $string] "$testname"
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 set run_tests {
     {"Run with libindirect3c.so 1"
-     "tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
+     "-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
      {dummy.c} "indirect3a" "indirect3.out"}
     {"Run with libindirect3c.so 2"
-     "tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
+     "-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
      {dummy.c} "indirect3b" "indirect3.out"}
     {"Run with libindirect3c.so 3"
-     "tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
+     "-Wl,--no-as-needed tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
      {dummy.c} "indirect3c" "indirect3.out"}
     {"Run with libindirect3c.so 4"
-     "tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
+     "-Wl,--no-as-needed tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
      {dummy.c} "indirect3d" "indirect3.out"}
     {"Run with libindirect4c.so 1"
-     "tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
+     "-Wl,--no-as-needed tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
      {dummy.c} "indirect4a" "indirect4.out"}
     {"Run with libindirect4c.so 2"
-     "tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
+     "-Wl,--no-as-needed tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
      {dummy.c} "indirect4b" "indirect4.out"}
     {"Run with libindirect4c.so 3"
-     "tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
+     "-Wl,--no-as-needed tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
      {dummy.c} "indirect4c" "indirect4.out"}
     {"Run with libindirect4c.so 4"
-     "tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
+     "-Wl,--no-as-needed tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
      {dummy.c} "indirect4d" "indirect4.out"}
     {"Run with libpr18720c.so 1"
-     "tmpdir/pr18720a.o tmpdir/pr18720b.o tmpdir/libpr18720c.so" ""
+     "-Wl,--no-as-needed tmpdir/pr18720a.o tmpdir/pr18720b.o tmpdir/libpr18720c.so" ""
      {check-ptr-eq.c} "pr18720a" "pr18720.out"}
     {"Run with libpr18720c.so 2"
-     "tmpdir/pr18720a.o tmpdir/libpr18720c.so tmpdir/pr18720b.o" ""
+     "-Wl,--no-as-needed tmpdir/pr18720a.o tmpdir/libpr18720c.so tmpdir/pr18720b.o" ""
      {check-ptr-eq.c} "pr18720b" "pr18720.out"}
     {"Run with libpr18720c.so 3"
-     "tmpdir/pr18720b.o tmpdir/libpr18720c.so tmpdir/pr18720a.o" ""
+     "-Wl,--no-as-needed tmpdir/pr18720b.o tmpdir/libpr18720c.so tmpdir/pr18720a.o" ""
      {check-ptr-eq.c} "pr18720c" "pr18720.out"}
     {"Run with libpr18720c.so 4"
-     "tmpdir/libpr18720c.so tmpdir/pr18720b.o tmpdir/pr18720a.o" ""
+     "-Wl,--no-as-needed tmpdir/libpr18720c.so tmpdir/pr18720b.o tmpdir/pr18720a.o" ""
      {check-ptr-eq.c} "pr18720d" "pr18720.out"}
     {"Run with libpr18720c.so 5"
-     "tmpdir/libpr18720c.so tmpdir/pr18720b1.o tmpdir/pr18720a.o" ""
+     "-Wl,--no-as-needed tmpdir/libpr18720c.so tmpdir/pr18720b1.o tmpdir/pr18720a.o" ""
      {check-ptr-eq.c} "pr18720d" "pr18720.out"}
     {"Run with libpr19553b.so"
-     "tmpdir/libpr19553b.so tmpdir/libpr19553d.so -rpath-link ." ""
+     "-Wl,--no-as-needed tmpdir/libpr19553b.so tmpdir/libpr19553d.so -Wl,-rpath-link,." ""
      {pr19553a.c} "pr19553b" "pr19553b.out"}
     {"Run with libpr19553c.so"
-     "tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" ""
+     "-Wl,--no-as-needed tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" ""
      {pr19553a.c} "pr19553c" "pr19553c.out"}
     {"Run with libpr19553d.so"
-     "tmpdir/libpr19553d.so tmpdir/libpr19553b.so -rpath-link ." ""
+     "-Wl,--no-as-needed tmpdir/libpr19553d.so tmpdir/libpr19553b.so -Wl,-rpath-link,." ""
      {pr19553a.c} "pr19553d" "pr19553d.out"}
 }
 
diff --git a/ld/testsuite/ld-elf/sec-to-seg.exp b/ld/testsuite/ld-elf/sec-to-seg.exp
index 05da6ef..5d86a32 100644
--- a/ld/testsuite/ld-elf/sec-to-seg.exp
+++ b/ld/testsuite/ld-elf/sec-to-seg.exp
@@ -40,7 +40,7 @@ proc sec_to_seg_test { testname scriptname same_seg } {
     global exec_output
     global READELF
     
-    if {! [ld_simple_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then {
+    if {! [ld_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then {
 	fail $testname
 	return 0
     }
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 3cdac45..52baadd 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -21,13 +21,6 @@
 
 # Exclude non-ELF targets.
 
-# The following tests require running the executable generated by ld,
-# or enough of a build environment to create a fully linked executable.
-# This is not commonly available when testing a cross-built linker.
-if ![isnative] {
-    return
-}
-
 if ![is_elf_format] {
     return
 }
@@ -38,6 +31,7 @@ if { [which $CC] == 0 } {
 }
 
 # Add -ldl to extralibs if needed
+set extralibs ""
 if { ![istarget *-*-freebsd*]} {
     set extralibs "-ldl"
 }
@@ -55,7 +49,7 @@ set build_tests {
   {"Build warn libbar.so"
    "-shared" "-fPIC"
    {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd}} "libbarw.so"
-    "C" "^.*\\\): warning: function foo is deprecated$"}
+   "c" {^.*\): warning: function foo is deprecated$} }
   {"Build hidden libbar.so"
    "-shared" "-fPIC"
    {begin.c endhidden.c} {} "libbarh.so"}
@@ -283,156 +277,156 @@ set build_tests {
 
 run_cc_link_tests $build_tests
 
-set run_tests {
-    {"Run normal with libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
-     {main.c} "normal" "normal.out"}
-    {"Run protected with libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
-     {main.c} "protected" "normal.out"}
-    {"Run hidden with libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
-     {main.c} "hidden" "hidden.out"}
-    {"Run normal with versioned libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
-     {main.c} "normalv" "normal.out"}
-    {"Run warn with versioned libfoo.so"
-     "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
-     {main.c} "warn" "warn.out"
-     "" "" "^.*\\\): warning: function foo is deprecated$"}
-    {"Run protected with versioned libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
-     {main.c} "protected" "normal.out"}
-    {"Run hidden with versioned libfoo.so"
-     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
-     {main.c} "hiddenv" "hidden.out"}
-    {"Run normal libbar.so with libfoo.so"
-     "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
-     {main.c} "normal" "normal.out"}
-    {"Run protected libbar.so with libfoo.so"
-     "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
-     {main.c} "protected" "normal.out"}
-    {"Run hidden libbar.so with libfoo.so"
-     "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
-     {main.c} "hidden" "hidden.out"}
-    {"Run normal libbar.so with versioned libfoo.so"
-     "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
-     {main.c} "normal" "normal.out"}
-    {"Run protected libbar.so with versioned libfoo.so"
-     "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
-     {main.c} "protected" "normal.out"}
-    {"Run hidden libbar.so with versioned libfoo.so"
-     "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
-     {main.c} "hidden" "hidden.out"}
-    {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so"
-     "--dynamic-list=dl1.list $extralibs" ""
-     {dl1main.c} "dl1a" "dl1.out"}
-    {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so"
-     "--dynamic-list-data $extralibs" ""
-     {dl1main.c} "dl1b" "dl1.out"}
-    {"Run with libdl2a.so"
-     "tmpdir/libdl2a.so" ""
-     {dl2main.c} "dl2a" "dl2a.out"}
-    {"Run with libdl2b.so"
-     "tmpdir/libdl2b.so" ""
-     {dl2main.c} "dl2b" "dl2b.out"}
-    {"Run with libdl2c.so"
-     "tmpdir/libdl2c.so" ""
-     {dl2main.c} "dl2c" "dl2b.out"}
-    {"Run with libdl4a.so"
-     "tmpdir/libdl4a.so" ""
-     {dl4main.c} "dl4a" "dl4a.out"}
-    {"Run with libdl4b.so"
-     "tmpdir/libdl4b.so" ""
-     {dl4main.c} "dl4b" "dl4a.out"}
-    {"Run with libdl4c.so"
-     "tmpdir/libdl4c.so" ""
-     {dl4main.c} "dl4c" "dl4b.out"}
-    {"Run with libdl4d.so"
-     "tmpdir/libdl4d.so" ""
-     {dl4main.c} "dl4d" "dl4b.out"}
-    {"Run with libdl4e.so"
-     "tmpdir/libdl4e.so" ""
-     {dl4main.c} "dl4e" "dl4a.out"}
-    {"Run with libdl4f.so"
-     "tmpdir/libdl4f.so" ""
-     {dl4main.c} "dl4f" "dl4a.out"}
-    {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so"
-     "--dynamic-list-data $extralibs" ""
-     {dl6amain.c} "dl6a1" "dl6a.out"}
-    {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so"
-     "-Bsymbolic-functions $extralibs" ""
-     {dl6amain.c} "dl6a2" "dl6b.out"}
-    {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so"
-     "-Bsymbolic $extralibs" ""
-     {dl6amain.c} "dl6a3" "dl6b.out"}
-    {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so"
-     "-Bsymbolic --dynamic-list-data $extralibs" ""
-     {dl6amain.c} "dl6a4" "dl6a.out"}
-    {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so"
-     "-Bsymbolic-functions --dynamic-list-cpp-new $extralibs" ""
-     {dl6amain.c} "dl6a5" "dl6b.out"}
-    {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so"
-     "--dynamic-list-cpp-new -Bsymbolic-functions $extralibs" ""
-     {dl6amain.c} "dl6a6" "dl6b.out"}
-    {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so"
-     "--dynamic-list-data -Bsymbolic $extralibs" ""
-     {dl6amain.c} "dl6a7" "dl6a.out"}
-    {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so"
-     "--dynamic-list-data $extralibs" ""
-     {dl6bmain.c} "dl6b1" "dl6a.out"}
-    {"Run dl6b2 with dlopen on libdl6b.so"
-     "$extralibs" ""
-     {dl6bmain.c} "dl6b2" "dl6b.out"}
-    {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so"
-     "--dynamic-list-data $extralibs" ""
-     {dl6cmain.c} "dl6c1" "dl6b.out"}
-    {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so"
-     "--dynamic-list-data $extralibs" ""
-     {dl6dmain.c} "dl6d1" "dl6b.out"}
-    {"Run with libdata1.so"
-     "tmpdir/libdata1.so" ""
-     {dynbss1.c} "dynbss1" "pass.out"}
-    {"Run with libdata2.so"
-     "tmpdir/libdata2.so" ""
-     {weakdef1.c} "weakdef1" "pass.out"}
-    {"Run with libfunc1.so comm1.o"
-     "tmpdir/libfunc1.so tmpdir/comm1.o" ""
-     {dummy.c} "comm1" "pass.out"}
-    {"Run with comm1.o libfunc1.so"
-     "tmpdir/comm1.o tmpdir/libfunc1.so" ""
-     {dummy.c} "comm1" "pass.out"}
-    {"Run with pr11138-2.c libpr11138-1.so"
-     "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" ""
-     {dummy.c} "pr11138a" "pr11138.out"}
-    {"Run with libpr11138-1.so pr11138-2.c"
-     "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" ""
-     {dummy.c} "pr11138b" "pr11138.out"}
-    {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
-     "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
-     {dummy.c} "pr13250" "pass.out"}
-    {"Run with pr14323-1.c pr14323-2.so"
-     "tmpdir/libpr14323-2.so" ""
-     {pr14323-1.c} "pr14323" "pass.out"}
-    {"Run with pr14862-1.c libpr14862.so"
-     "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
-     {dummy.c} "pr14862" "pr14862.out"}
-    {"Link with --add-needed"
-     "tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" ""
-     {dummy.c} "needed1a" "needed1.out"}
-    {"Link with --copy-dt-needed-entries"
-     "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" ""
-     {dummy.c} "needed1b" "needed1.out"}
-    {"Run relmain"
-     "--no-as-needed -rpath=tmpdir -Ltmpdir -lrel" ""
-     {relmain.c} "relmain" "relmain.out"}
-    {"Run pr2404"
-     "tmpdir/pr2404b.o tmpdir/libpr2404a.so" ""
-     {dummy.c} "pr2404" "pr2404.out"}
-    {"Run pr18458"
-     "tmpdir/libpr18458a.so tmpdir/libpr18458b.so -z now" ""
-     {pr18458c.c} "pr18458" "pass.out"}
-}
+set run_tests [list \
+    [list "Run normal with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run normal with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
+     {main.c} "normalv" "normal.out" ] \
+    [list "Run warn with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
+     {main.c} "warn" "warn.out" \
+     "" "c" {^.*\): warning: function foo is deprecated$} ] \
+    [list "Run protected with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
+     {main.c} "hiddenv" "hidden.out" ] \
+    [list "Run normal libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run normal libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
+     {dl1main.c} "dl1a" "dl1.out" ] \
+    [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl1main.c} "dl1b" "dl1.out" ] \
+    [list "Run with libdl2a.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
+     {dl2main.c} "dl2a" "dl2a.out" ] \
+    [list "Run with libdl2b.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
+     {dl2main.c} "dl2b" "dl2b.out" ] \
+    [list "Run with libdl2c.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
+     {dl2main.c} "dl2c" "dl2b.out" ] \
+    [list "Run with libdl4a.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
+     {dl4main.c} "dl4a" "dl4a.out" ] \
+    [list "Run with libdl4b.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
+     {dl4main.c} "dl4b" "dl4a.out" ] \
+    [list "Run with libdl4c.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
+     {dl4main.c} "dl4c" "dl4b.out" ] \
+    [list "Run with libdl4d.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
+     {dl4main.c} "dl4d" "dl4b.out" ] \
+    [list "Run with libdl4e.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
+     {dl4main.c} "dl4e" "dl4a.out" ] \
+    [list "Run with libdl4f.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
+     {dl4main.c} "dl4f" "dl4a.out" ] \
+    [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a1" "dl6a.out" ] \
+    [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a2" "dl6b.out" ] \
+    [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a3" "dl6b.out" ] \
+    [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a4" "dl6a.out" ] \
+    [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
+     {dl6amain.c} "dl6a5" "dl6b.out" ] \
+    [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a6" "dl6b.out" ] \
+    [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a7" "dl6a.out" ] \
+    [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6bmain.c} "dl6b1" "dl6a.out" ] \
+    [list "Run dl6b2 with dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed $extralibs" "" \
+     {dl6bmain.c} "dl6b2" "dl6b.out" ] \
+    [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6cmain.c} "dl6c1" "dl6b.out" ] \
+    [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6dmain.c} "dl6d1" "dl6b.out" ] \
+    [list "Run with libdata1.so" \
+     "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
+     {dynbss1.c} "dynbss1" "pass.out" ] \
+    [list "Run with libdata2.so" \
+     "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
+     {weakdef1.c} "weakdef1" "pass.out" ] \
+    [list "Run with libfunc1.so comm1.o" \
+     "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
+     {dummy.c} "comm1" "pass.out" ] \
+    [list "Run with comm1.o libfunc1.so" \
+     "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
+     {dummy.c} "comm1" "pass.out" ] \
+    [list "Run with pr11138-2.c libpr11138-1.so" \
+     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
+     {dummy.c} "pr11138a" "pr11138.out" ] \
+    [list "Run with libpr11138-1.so pr11138-2.c" \
+     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
+     {dummy.c} "pr11138b" "pr11138.out" ] \
+    [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
+     "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \
+     {dummy.c} "pr13250" "pass.out" ] \
+    [list "Run with pr14323-1.c pr14323-2.so" \
+     "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
+     {pr14323-1.c} "pr14323" "pass.out" ] \
+    [list "Run with pr14862-1.c libpr14862.so" \
+     "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
+     {dummy.c} "pr14862" "pr14862.out" ] \
+    [list "Link with --add-needed" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
+     {dummy.c} "needed1a" "needed1.out" ] \
+    [list "Link with --copy-dt-needed-entries" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
+     {dummy.c} "needed1b" "needed1.out" ] \
+    [list "Run relmain" \
+     "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
+     {relmain.c} "relmain" "relmain.out" ] \
+    [list "Run pr2404" \
+     "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
+     {dummy.c} "pr2404" "pr2404.out" ] \
+    [list "Run pr18458" \
+     "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
+     {pr18458c.c} "pr18458" "pass.out" ] \
+]
 
 # NetBSD ELF systems do not currently support the .*_array sections.
 run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
@@ -502,10 +496,10 @@ set run_cxx_tests {
      "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
      {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
     {"Run with libnew1a.so"
-     "tmpdir/libnew1a.so" ""
+     "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
      {dl5.cc} "dl5a" "dl5.out" "" "c++"}
     {"Run with libnew1b.so"
-     "tmpdir/libnew1b.so" ""
+     "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
      {dl5.cc} "dl5b" "dl5.out" "" "c++"}
 }
 
@@ -543,7 +537,7 @@ if { [istarget *-*-linux*]
     run_ld_link_exec_tests [list \
 	[list \
 	    "Run pr2404 with PIE" \
-	    "-pie tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
 	    "" \
 	    { dummy.c } \
 	    "pr2404pie" \
@@ -597,7 +591,7 @@ if { [istarget *-*-linux*]
 	] \
 	[list \
 	    "Run pr19579" \
-	    "-pie -z text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
+	    "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
 	    "" \
 	    {dummy.c} \
 	    "pr19579" \
@@ -641,7 +635,7 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
     run_ld_link_exec_tests [list \
 	[list \
 	    "Run $exe fun defined" \
-	    "$ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so -rpath tmpdir" \
+	    "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
 	    "" \
 	    { pr19719a.c pr19719c.c } \
 	    $exe \
@@ -657,6 +651,11 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
 	setup_xfail $targ
     }
 
+    if ![isnative] {
+	unsupported "Run $exe fun undefined"
+	return
+    }
+
     set exec_output [run_host_cmd "tmpdir/$exe" ""]
     if {![string match "PASS" $exec_output]} {
 	fail "Run $exe fun undefined"
diff --git a/ld/testsuite/ld-elf/tls_common.exp b/ld/testsuite/ld-elf/tls_common.exp
index 7ebe016..b900312 100644
--- a/ld/testsuite/ld-elf/tls_common.exp
+++ b/ld/testsuite/ld-elf/tls_common.exp
@@ -47,13 +47,13 @@ if { ![ld_assemble $as "--elf-stt-common=no $srcdir/$subdir/tls_common.s" tmpdir
     return
 }
 
-if { ![ld_simple_link $ld tmpdir/tls_common1a.o "-r tmpdir/tls_commona.o"]
-     || ![ld_simple_link $ld tmpdir/tls_common1b.o "-r tmpdir/tls_commona.o"] } {
+if { ![ld_link $ld tmpdir/tls_common1a.o "-r tmpdir/tls_commona.o"]
+     || ![ld_link $ld tmpdir/tls_common1b.o "-r tmpdir/tls_commona.o"] } {
     fail "tls_common"
     return
 }
 
-if { ![ld_simple_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
+if { ![ld_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
     if { [string match "*not supported*" $link_output]
 	 || [string match "*unrecognized option*" $link_output] } {
 	unsupported "$ld_options is not supported by this target"
@@ -65,7 +65,7 @@ if { ![ld_simple_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
     return
 }
 
-if { ![ld_simple_link $ld tmpdir/tls_commonb "tmpdir/tls_common1b.o"] } {
+if { ![ld_link $ld tmpdir/tls_commonb "tmpdir/tls_common1b.o"] } {
     if { [string match "*not supported*" $link_output]
 	 || [string match "*unrecognized option*" $link_output] } {
 	unsupported "$ld_options is not supported by this target"
diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp
index be88ef6..4bf8faa 100644
--- a/ld/testsuite/ld-elf/wrap.exp
+++ b/ld/testsuite/ld-elf/wrap.exp
@@ -25,11 +25,6 @@ if ![is_elf_format] {
     return
 }
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
@@ -46,10 +41,10 @@ set build_tests {
 
 set run_tests {
     {"Run with libwrap1a.so and libwrap1b.so"
-     "--wrap par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" ""
+     "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" ""
      {wrap1.c} "wrap1" "wrap1.out"}
     {"Run with libwrap1b.so and libwrap1a.so"
-     "--wrap par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" ""
+     "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" ""
      {wrap1.c} "wrap1" "wrap1.out"}
 }
 
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
index 860ce98..da33768 100644
--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
+++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
@@ -58,7 +58,7 @@ proc test_sort_common {} {
 	return 0
     }
 
-    if { ![ld_simple_link $ld tmpdir/sort-common.dx "--sort-common=descending tmpdir/sort-common.o"] } {
+    if { ![ld_link $ld tmpdir/sort-common.dx "--sort-common=descending tmpdir/sort-common.o"] } {
 	fail "$test"
 	return 0
     }
@@ -82,7 +82,7 @@ proc test_sort_common {} {
   
     verbose "Check to see that --sort-common=ascending sorts in ascending alignment"
 
-    if { ![ld_simple_link $ld tmpdir/sort-common.ax "--sort-common=ascending tmpdir/sort-common.o"] } {
+    if { ![ld_link $ld tmpdir/sort-common.ax "--sort-common=ascending tmpdir/sort-common.o"] } {
 	fail "$test"
 	return 0
     }
@@ -146,7 +146,7 @@ proc stt_common_test { options testname } {
 
     set options "$options tmpdir/common1c.o"
 
-    if { ! [ld_simple_link $ld tmpdir/common.exe $options] } {
+    if { ! [ld_link $ld tmpdir/common.exe $options] } {
       unresolved $testname
       return 0
     }
@@ -191,7 +191,7 @@ if [istarget sh64*-*-*] {
     }
 }
 
-if { [ld_simple_link $ld tmpdir/common1.o $options] } {
+if { [ld_link $ld tmpdir/common1.o $options] } {
     unresolved $test1w1
     return
 }
@@ -228,7 +228,7 @@ if [istarget sh64*-*-*] {
     }
 }
 
-if { [ld_simple_link $ld tmpdir/common1.o $options] } {
+if { [ld_link $ld tmpdir/common1.o $options] } {
     unresolved $test1w2
     return
 }
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index 90f204f..bd35ae2 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -22,8 +22,10 @@
 
 #
 
-# This test can only be run if ld generates native executables.
-if ![isnative] then {return}
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
 
 # This test can only be run on a couple of ELF platforms.
 # Square bracket expressions seem to confuse istarget.
@@ -544,7 +546,7 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
 	set script_arg "$script $srcdir/$subdir/$mapfile"
     }
 
-    if {![ld_simple_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg $ldargs"]}     {
+    if {![ld_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg $ldargs"]}     {
 	fail "$test"
 	return
     }
@@ -635,7 +637,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
 	set script_arg "-Wl,$script $srcdir/$subdir/$mapfile"
     }
 
-    if {![ld_simple_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]}     {
+    if {![ld_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]}     {
 	pass "$test"
 	return
     }
@@ -733,7 +735,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
 	set solibname_lib $tmpdir/$solibname
     }
 
-    if {![ld_simple_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]}     {
+    if {![ld_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]}     {
 	fail "$test"
 	return
     }
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index 5331ad5..9d590c7 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -24,6 +24,11 @@
 
 # Make sure that ld can generate ELF shared libraries with visibility.
 
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
+
 # This test can only be run on a couple of ELF platforms.
 # Square bracket expressions seem to confuse istarget.
 if { ![istarget hppa*64*-*-hpux*] \
@@ -56,9 +61,6 @@ foreach t $test_list {
     run_dump_test [file rootname $t]
 }
 
-# The remaining tests can only be run if ld generates native executables.
-if ![isnative] then {return}
-
 set tmpdir tmpdir
 set SHCFLAG ""
 set shared_needs_pic "no"
@@ -121,7 +123,7 @@ if { [istarget *-*-linux*]
      || [istarget *-*-nacl*]
      || [istarget *-*-gnu*] } {
     if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
-      if [ld_simple_link $CC $tmpdir/main "$tmpdir/main.o"] {
+      if [ld_link $CC $tmpdir/main "$tmpdir/main.o"] {
 	catch "exec $tmpdir/main" support_protected
       }
     }
@@ -145,7 +147,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 	set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
     }
-    if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
+    if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
 	if { [ string match $visibility "hidden_undef" ]
 	     && [regexp "undefined reference to \`\.?visibility\'" $link_output]
 	     && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@@ -168,7 +170,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 	set rpath /lib:$tmpdir
     }
-    if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
+    if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
 	if { [ string match $visibility "hidden" ]
 	     && [regexp "undefined reference to \`\.?visibility\'" $link_output]
 	     && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@@ -191,6 +193,11 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
 	fail "$testname"
     }
 
+    if ![isnative] {
+	unsupported "$testname"
+	return
+    }
+
     # Run the resulting program
     send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
     verbose "$tmpdir/$progname >$tmpdir/$progname.out"
@@ -502,7 +509,7 @@ visibility_run normal
 if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
     unresolved "common hidden symbol"
 } else {
-    if ![ld_simple_link $ld tmpdir/common "tmpdir/common.o"] {
+    if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
 	fail "common hidden symbol"
     } else {
 	pass "common hidden symbol"
@@ -515,15 +522,15 @@ if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
    if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
 	unresolved "weak hidden symbol"
     } else {
-	if ![ld_simple_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
+	if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
 	    fail "weak hidden symbol"
 	} else {
-	    if ![ld_simple_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
+	    if ![ld_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
 		fail "weak hidden symbol DSO last"
 	    } else {
 		pass "weak hidden symbol DSO last"
 	    }
-	    if ![ld_simple_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
+	    if ![ld_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
 		fail "weak hidden symbol DSO first"
 	    } else {
 		pass "weak hidden symbol DSO first"
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index 88df180..e62291e 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -22,8 +22,10 @@
 #	     Eric Youngdale (eric@andante.jic.com)
 #
 
-# This test can only be run if ld generates native executables.
-if ![isnative] then {return}
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
 
 # This test can only be run on a couple of ELF platforms.
 # Square bracket expressions seem to confuse istarget.
@@ -290,7 +292,7 @@ proc build_lib {test libname objs dynsymexp} {
       set files "$files $tmpdir/$obj"
     }
 
-    if {![ld_simple_link $CC $tmpdir/$libname.so "$shared $files"]} {
+    if {![ld_link $CC $tmpdir/$libname.so "$shared $files"]} {
 	fail $test
 	return
     }
@@ -316,7 +318,7 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
       set files "$files $tmpdir/$obj"
     }
 
-    if {![ld_simple_link $CC $tmpdir/$execname "$flags $files"]} {
+    if {![ld_link $CC $tmpdir/$execname "$flags $files"]} {
 	fail "$test"
 	return
     }
@@ -335,6 +337,10 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
 	}
     }
 
+    if ![isnative] {
+	unsupported $test
+	return
+    }
     # Run the resulting program
     send_log "$tmpdir/$execname >$tmpdir/$execname.out\n"
     verbose "$tmpdir/$execname >$tmpdir/$execname.out"
@@ -402,7 +408,7 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c $tmpdir/main.o] {
     return
 }
 
-if {![ld_simple_link $CC $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
+if {![ld_link $CC $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
     fail "ELF weak"
     return
 }
@@ -437,17 +443,17 @@ if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]
     return
 }
 
-if {![ld_simple_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} {
+if {![ld_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} {
     fail "ELF weak"
     return
 }
 
-if {![ld_simple_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} {
+if {![ld_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} {
     fail "ELF weak"
     return
 }
 
-if {![ld_simple_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} {
+if {![ld_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} {
     fail "ELF weak"
     return
 }
diff --git a/ld/testsuite/ld-fastcall/fastcall.exp b/ld/testsuite/ld-fastcall/fastcall.exp
index d6184fa4..261a668 100644
--- a/ld/testsuite/ld-fastcall/fastcall.exp
+++ b/ld/testsuite/ld-fastcall/fastcall.exp
@@ -45,7 +45,7 @@ if ![ld_assemble $as $srcdir/$subdir/import.s tmpdir/import.o] {
     return
 }
 
-if ![ld_simple_link $ld tmpdir/extern.x "$ldflags tmpdir/export.o tmpdir/import.o"] {
+if ![ld_link $ld tmpdir/extern.x "$ldflags tmpdir/export.o tmpdir/import.o"] {
     fail $testname
 } else {
     pass $testname
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 0e7b8c0..ba4f70b 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -54,7 +54,7 @@ proc test_gc { testname filename linker ldflags} {
 
     set outfile "tmpdir/$filename"
     set options "-L$srcdir/$subdir"
-    append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile
+    append options " " $ldflags " " [ld_link_defsyms] " " $objfile
 
     # SH64 targets needs an extra ld option for this test.
     if [istarget sh64*-*-*] {
@@ -65,7 +65,7 @@ proc test_gc { testname filename linker ldflags} {
 	}
     }
 
-    if ![ld_simple_link $linker $outfile $options] {
+    if ![ld_link $linker $outfile $options] {
 	fail $testname
 	return
     }
@@ -112,7 +112,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
 	set gasopt "-mpic -mpid=near"
     }
     if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
-	|| ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
+	|| ![ld_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
 	fail libpersonality
     } else {
 	run_dump_test "personality"
@@ -125,7 +125,7 @@ if { [is_remote host] || [which $CC] != 0 } {
 	 || [istarget "*-*-nacl*"]
 	 || [istarget "*-*-gnu*"] } {
 	ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
-	ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
+	ld_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
  	ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
 	run_dump_test "pr11218"
     }
diff --git a/ld/testsuite/ld-ifunc/binutils.exp b/ld/testsuite/ld-ifunc/binutils.exp
index 0567c20..a02b71f 100644
--- a/ld/testsuite/ld-ifunc/binutils.exp
+++ b/ld/testsuite/ld-ifunc/binutils.exp
@@ -54,7 +54,7 @@ proc binutils_test { prog_name ld_options test } {
 	return
     }
 
-    if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
+    if { ![ld_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
 	if { [string match "*not supported*" $link_output]
 	     || [string match "*unrecognized option*" $link_output] } {
 	    unsupported "$ld_options is not supported by this target"
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index 0b488d0..d7519b5 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -41,15 +41,6 @@ if {!(([istarget "i?86-*-*"]
     return
 }
 
-# We need a native system.  FIXME: Strictly speaking this
-# is not true, we just need to know how to create a fully
-# linked executable, including the C and Z libraries, using
-# the linker that is under test.
-if ![isnative] {
-    verbose "IFUNC tests not run - not a native toolchain"
-    return
-}
-
 # We need a working compiler.  (Strictly speaking this is
 # not true, we could use target specific assembler files).
 if { [which $CC] == 0 } {
@@ -200,7 +191,7 @@ if { $fails != 0 } {
     return
 }
 
-if ![ld_simple_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
+if ![ld_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
     fail "Could not create a shared library containing an IFUNC symbol"
     set fails [expr $fails + 1]
 }
@@ -213,27 +204,27 @@ if { $fails != 0 } {
     return
 }
 
-if ![default_ld_link $ld "tmpdir/dynamic_prog" "-Ltmpdir tmpdir/shared_prog.o -Bdynamic -lshared_ifunc -rpath ./tmpdir"] {
+if ![ld_link $CC "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] {
     fail "Could not link a dynamic executable"
     set fails [expr $fails + 1]
 }
-if ![default_ld_link $ld "tmpdir/local_prog" "-Ltmpdir tmpdir/static_prog.o -lifunc"] {
+if ![ld_link $CC "tmpdir/local_prog" "-Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] {
     fail "Could not link a dynamic executable using local ifunc"
     set fails [expr $fails + 1]
 }
-if ![default_ld_link $ld "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
+if ![ld_link $CC "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
     fail "Could not link a static executable"
     set fails [expr $fails + 1]
 }
-if ![ld_simple_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
+if ![ld_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
     fail "Could not link a non-ifunc using static executable"
     set fails [expr $fails + 1]
 }
-if ![default_ld_link $ld "tmpdir/test-1" "tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
+if ![ld_link $CC "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
     fail "Could not link test-1"
     set fails [expr $fails + 1]
 }
-if ![ld_simple_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
+if ![ld_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
     fail "Could not link libtest-2.so"
     set fails [expr $fails + 1]
 }
@@ -251,6 +242,11 @@ if { $fails == 0 } {
 # ifunc should have an OSABI field of GNU.  The linked non-ifunc using
 # executable should have an OSABI field of NONE (aka System V).
 
+case $target_triplet in {
+    { hppa*-*-linux* } { set expected_none {UNIX - GNU} }
+    default { set expected_none {UNIX - System V} }
+}
+
 if {! [check_osabi tmpdir/libshared_ifunc.so {UNIX - GNU}]} {
     fail "Shared libraries containing ifunc does not have an OS/ABI field of GNU"
     set fails [expr $fails + 1]
@@ -263,12 +259,12 @@ if {! [check_osabi tmpdir/static_prog {UNIX - GNU}]} {
     fail "Static ifunc-using executable does not have an OS/ABI field of GNU"
     set fails [expr $fails + 1]
 }
-if {! [check_osabi tmpdir/dynamic_prog {UNIX - System V}]} {
-    fail "Dynamic ifunc-using executable does not have an OS/ABI field of System V"
+if {! [check_osabi tmpdir/dynamic_prog $expected_none]} {
+    fail "Dynamic ifunc-using executable does not have an OS/ABI field of $expected_none"
     set fails [expr $fails + 1]
 }
-if {! [check_osabi tmpdir/static_nonifunc_prog {UNIX - System V}]} {
-    fail "Static non-ifunc-using executable does not have an OS/ABI field of System V"
+if {! [check_osabi tmpdir/static_nonifunc_prog $expected_none]} {
+    fail "Static non-ifunc-using executable does not have an OS/ABI field of $expected_none"
     set fails [expr $fails + 1]
 }
 
@@ -335,21 +331,6 @@ if { $fails == 0 } {
   pass "Checking ifunc binaries"
 }
 
-# Clean up, unless we are being verbose, in which case we leave the files available.
-if { $verbose < 1 } {
-    remote_file host delete "tmpdir/shared_prog.o"
-    remote_file host delete "tmpdir/static_prog.o"
-    remote_file host delete "tmpdir/shared_ifunc.o"
-    remote_file host delete "tmpdir/static_ifunc.o"
-    remote_file host delete "tmpdir/static_noifunc.o"
-    remote_file host delete "tmpdir/libshared_ifunc.so"
-    remote_file host delete "tmpdir/libifunc.a"
-    remote_file host delete "tmpdir/dynamic_prog"
-    remote_file host delete "tmpdir/local_prog"
-    remote_file host delete "tmpdir/static_prog"
-    remote_file host delete "tmpdir/static_nonifunc_prog"
-}
-
 run_cc_link_tests [list \
     [list \
 	"Build libpr16467a.so" \
@@ -433,7 +414,7 @@ run_cc_link_tests [list \
 run_ld_link_exec_tests [list \
     [list \
 	"Run pr16467" \
-	"tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
+	"-Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
 	"" \
 	{ dummy.c } \
 	"pr16467" \
@@ -442,7 +423,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run ifunc-main" \
-	"tmpdir/libifunc-lib.so" \
+	"-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
 	"" \
 	{ ifunc-main.c } \
 	"ifunc-main" \
@@ -450,7 +431,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run ifunc-main with -fpic" \
-	"tmpdir/libifunc-lib.so" \
+	"-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
 	"" \
 	{ ifunc-main.c } \
 	"ifunc-main" \
@@ -510,7 +491,7 @@ run_cc_link_tests [list \
 run_ld_link_exec_tests [list \
     [list \
 	"Run pr18808" \
-	"tmpdir/pr18808a.o tmpdir/libpr18808.so" \
+	"-Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808.so" \
 	"" \
 	{ dummy.c } \
 	"pr18808" \
@@ -518,7 +499,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run pr18841 with libpr18841b.so" \
-	"tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
+	"-Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
 	"" \
 	{ dummy.c } \
 	"pr18841b" \
@@ -526,7 +507,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run pr18841 with libpr18841c.so" \
-	"--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
+	"-Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
 	"" \
 	{ dummy.c } \
 	"pr18841c" \
diff --git a/ld/testsuite/ld-mep/mep.exp b/ld/testsuite/ld-mep/mep.exp
index 4b8e3a9..d6df072 100644
--- a/ld/testsuite/ld-mep/mep.exp
+++ b/ld/testsuite/ld-mep/mep.exp
@@ -31,7 +31,7 @@ set testbsrweak "MeP bsr to undefined weak function"
 
 if ![ld_assemble $as "$srcdir/$subdir/mep1.s" tmpdir/mep1.o] {
     unresolved $testbsrweak
-} else { if ![ld_simple_link $ld tmpdir/mep1 "-T$srcdir/$subdir/mep1.ld tmpdir/mep1.o"] {
+} else { if ![ld_link $ld tmpdir/mep1 "-T$srcdir/$subdir/mep1.ld tmpdir/mep1.o"] {
     fail $testbsrweak
 } else {
     pass $testbsrweak
diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
index 80f218f..dd84c9c 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
@@ -67,7 +67,7 @@ proc good_combination {arglist flags} {
 
     if {$objs == ""} {
 	unresolved $testname
-    } elseif {![ld_simple_link "$ld $ldemul" $finalobj "-r $objs"]} {
+    } elseif {![ld_link "$ld $ldemul" $finalobj "-r $objs"]} {
 	fail $testname
     } else {
 	catch "exec $READELF --headers $finalobj" output
@@ -106,7 +106,7 @@ proc bad_combination {arglist message} {
 
     if {$objs == ""} {
 	unresolved $testname
-    } elseif {[ld_simple_link "$ld $ldemul" $finalobj "-r $objs"]
+    } elseif {[ld_link "$ld $ldemul" $finalobj "-r $objs"]
 	      || [string first $message $link_output] < 0} {
 	fail $testname
     } else {
diff --git a/ld/testsuite/ld-mn10300/mn10300.exp b/ld/testsuite/ld-mn10300/mn10300.exp
index 98c77cd..503dd77 100644
--- a/ld/testsuite/ld-mn10300/mn10300.exp
+++ b/ld/testsuite/ld-mn10300/mn10300.exp
@@ -147,12 +147,12 @@ proc i126256-test { } {
     	return
     }
     
-    if { ![ld_simple_link $ld $tmpdir/i126256-1.so "-shared $tmpdir/i126256-1.o -e 0"]} {
+    if { ![ld_link $ld $tmpdir/i126256-1.so "-shared $tmpdir/i126256-1.o -e 0"]} {
         unresolved $testname
     	return
     }
 
-    if { ![ld_simple_link $ld $tmpdir/i126256-2.so "--relax -shared $tmpdir/i126256-2.o $tmpdir/i126256-1.so -e 0"]} {
+    if { ![ld_link $ld $tmpdir/i126256-2.so "--relax -shared $tmpdir/i126256-2.o $tmpdir/i126256-1.so -e 0"]} {
         fail $testname
     	return
     }
diff --git a/ld/testsuite/ld-nios2/nios2.exp b/ld/testsuite/ld-nios2/nios2.exp
index b8ffd49..b712e9e 100644
--- a/ld/testsuite/ld-nios2/nios2.exp
+++ b/ld/testsuite/ld-nios2/nios2.exp
@@ -22,7 +22,7 @@ if ![ld_assemble $as "-march=r2 $srcdir/$subdir/${test}b.s" tmpdir/${test}b.o] {
     return
 }
 
-if { ![ld_simple_link $ld tmpdir/$test "tmpdir/${test}a.o tmpdir/${test}b.o"] } {
+if { ![ld_link $ld tmpdir/$test "tmpdir/${test}a.o tmpdir/${test}b.o"] } {
     if [string match "*architecture * is incompatible*" $link_output] {
 	pass "$test_name"
     } {
diff --git a/ld/testsuite/ld-pe/pe-compile.exp b/ld/testsuite/ld-pe/pe-compile.exp
index 67a63e2..f29e5cf 100644
--- a/ld/testsuite/ld-pe/pe-compile.exp
+++ b/ld/testsuite/ld-pe/pe-compile.exp
@@ -52,7 +52,7 @@ proc run_basefile_test { testname } {
     global subdir
     global verbose
 
-    if ![ld_simple_link "$LD -e start \
+    if ![ld_link "$LD -e start \
 	    --base-file=tmpdir/$testname.base \
 	    --export-all-symbols" tmpdir/$testname.dll \
 	    "tmpdir/basefile1.o"] {
@@ -92,7 +92,7 @@ proc run_ver_script_test { testname } {
     global subdir
     global verbose
 
-    if ![ld_simple_link "$CC -shared \
+    if ![ld_link "$CC -shared \
 	    -Wl,--version-script,$srcdir/$subdir/$testname.ver \
 	    -Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
 	    "tmpdir/vers-script-dll.o"] {
diff --git a/ld/testsuite/ld-pe/pe-run.exp b/ld/testsuite/ld-pe/pe-run.exp
index 3fda17c..9fa6848 100644
--- a/ld/testsuite/ld-pe/pe-run.exp
+++ b/ld/testsuite/ld-pe/pe-run.exp
@@ -71,9 +71,9 @@ proc test_direct_link_dll {} {
     # Compile the dll.
     if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
 	fail "compiling shared lib"
-    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
+    } elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
 	fail "linking shared lib (.dll)"
-    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
+    } elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
 	fail "linking shared lib (.sl)"
     } else {
 	# Compile and link the client program.
@@ -82,7 +82,7 @@ proc test_direct_link_dll {} {
 	} else {
 	    # Check linking directly to direct_dll.dll.
 	    set msg "linking client (.dll)"
-	    if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
+	    if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
 	      "$tmpdir/direct_client.o $tmpdir/direct_dll.dll" ] {
 		pass $msg
 	    } else {
@@ -91,7 +91,7 @@ proc test_direct_link_dll {} {
 
 	    # Check linking directly to direct_dll.sl.
 	    set msg "linking client (.sl)"
-	    if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
+	    if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
 	      "$tmpdir/direct_client.o $tmpdir/direct_dll.sl" ] {
 		pass $msg
 	    } else {
@@ -102,7 +102,7 @@ proc test_direct_link_dll {} {
 	    # Create symbolic link.
 	    catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch
 	    set msg "linking client (symlink -> .dll)"
-	    if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
+	    if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
 	      "$tmpdir/direct_client.o $tmpdir/libdirect_dll.dll.a" ] {
 	        pass $msg
 	    } else {
@@ -113,7 +113,7 @@ proc test_direct_link_dll {} {
 	    # Create symbolic link.
 	    catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch
 	    set msg "linking client (symlink -> .sl)"
-	    if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
+	    if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
 	      "$tmpdir/direct_client.o $tmpdir/libdirect_sl.dll.a" ] {
 		pass $msg
 	    } else {
diff --git a/ld/testsuite/ld-pe/pe-run2.exp b/ld/testsuite/ld-pe/pe-run2.exp
index 9e0a60b..5c8c48f 100644
--- a/ld/testsuite/ld-pe/pe-run2.exp
+++ b/ld/testsuite/ld-pe/pe-run2.exp
@@ -73,9 +73,9 @@ proc test_direct2_link_dll {} {
     # Compile the dll.
     if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
 	fail "compiling shared lib fastcall/stdcall"
-    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
+    } elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
 	fail "linking shared lib (.dll) fastcall/stdcall"
-    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
+    } elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
 	fail "linking shared lib (.sl) fastcall/stdcall"
     } else {
 	# Compile and link the client program.
@@ -84,7 +84,7 @@ proc test_direct2_link_dll {} {
 	} else {
 	    # Check linking directly to direct2_dll.dll.
 	    set msg "linking client (.dll) fastcall/stdcall"
-	    if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
+	    if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
 	      "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
 		pass $msg
 	    } else {
@@ -93,7 +93,7 @@ proc test_direct2_link_dll {} {
 
 	    # Check linking directly to direct2_dll.sl.
 	    set msg "linking client (.sl) fastcall/stdcall"
-	    if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
+	    if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
 	      "$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] {
 		pass $msg
 	    } else {
@@ -104,7 +104,7 @@ proc test_direct2_link_dll {} {
 	    # Create symbolic link.
 	    catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
 	    set msg "linking client (symlink -> .dll) fastcall/stdcall"
-	    if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
+	    if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
 	      "$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] {
 	        pass $msg
 	    } else {
@@ -115,7 +115,7 @@ proc test_direct2_link_dll {} {
 	    # Create symbolic link.
 	    catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
 	    set msg "linking client (symlink -> .sl) fastcall/stdcall"
-	    if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
+	    if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
 	      "$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] {
 		pass $msg
 	    } else {
diff --git a/ld/testsuite/ld-pie/pie.exp b/ld/testsuite/ld-pie/pie.exp
index aaac450..e9d1162 100644
--- a/ld/testsuite/ld-pie/pie.exp
+++ b/ld/testsuite/ld-pie/pie.exp
@@ -19,9 +19,6 @@
 # MA 02110-1301, USA.
 #
 
-# This test can only be run if ld generates native executables.
-if ![isnative] then {return}
-
 if { ![istarget *-*-linux*]
      && ![istarget *-*-nacl*]
      && ![istarget *-*-gnu*] } {
@@ -37,8 +34,10 @@ if { ![string match "" $exec_output] } {
 }
 
 set array_tests {
-    {"weak undefined" "-pie" "" {weakundef.c} "weakundef" "weakundef.out" "-fPIC"}
-    {"weak undefined data" "-pie" "" {weakundef-data.c} "weakundef-data" "weakundef.out" "-fPIC"}
+    {"weak undefined" "-pie" ""
+	{weakundef.c} "weakundef" "weakundef.out" "-fPIC"}
+    {"weak undefined data" "-pie" ""
+	{weakundef-data.c} "weakundef-data" "weakundef.out" "-fPIC"}
 }
 
 run_ld_link_exec_tests $array_tests
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index d1ef17e..bfc1b1cfd 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -476,11 +476,6 @@ run_ld_link_tests [list \
    {dummy.s} {} "pr19317-r.o"] \
 ]
 
-# The following tests require running the executable generated by ld.
-if ![isnative] {
-    return
-}
-
 run_ld_link_exec_tests $lto_run_tests
 
 if { [is_elf_format] } {
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index 1323a09..ba32818 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -124,7 +124,7 @@ set testsrcfiles "tmpdir/main.o $srcdir/$subdir/func.c tmpdir/text.o"
 set testsrcfiles_notext "tmpdir/main.o $srcdir/$subdir/func.c"
 # Rather than having libs we just define dummy values for anything
 # we may need to link a target exe; we aren't going to run it anyway.
-set libs "[ld_simple_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
+set libs "[ld_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
 if { $dotsym } {
     append libs " --defsym .printf=.main --defsym .puts=.main"
 }
diff --git a/ld/testsuite/ld-scripts/align.exp b/ld/testsuite/ld-scripts/align.exp
index 302efa2..297aa13 100644
--- a/ld/testsuite/ld-scripts/align.exp
+++ b/ld/testsuite/ld-scripts/align.exp
@@ -38,7 +38,7 @@ if [istarget "x86_64-*-mingw*"] then {
   set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
-if ![ld_simple_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
+if ![ld_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
     fail $testname
 } else {
     pass $testname
diff --git a/ld/testsuite/ld-scripts/alignof.exp b/ld/testsuite/ld-scripts/alignof.exp
index e5d1ea9..91f05e1 100644
--- a/ld/testsuite/ld-scripts/alignof.exp
+++ b/ld/testsuite/ld-scripts/alignof.exp
@@ -32,7 +32,7 @@ if ![ld_assemble $as $srcdir/$subdir/alignof.s tmpdir/alignof.o] {
     return
 }
 
-if ![ld_simple_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] {
+if ![ld_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] {
     fail $testname
     return
 }
diff --git a/ld/testsuite/ld-scripts/assert.exp b/ld/testsuite/ld-scripts/assert.exp
index c0d9e84..1ea0b02 100644
--- a/ld/testsuite/ld-scripts/assert.exp
+++ b/ld/testsuite/ld-scripts/assert.exp
@@ -26,7 +26,7 @@ if ![ld_assemble $as $srcdir/$subdir/assert.s tmpdir/assert.o] {
     return
 }
 
-if ![ld_simple_link $ld tmpdir/assert "-T $srcdir/$subdir/assert.t tmpdir/assert.o"] {
+if ![ld_link $ld tmpdir/assert "-T $srcdir/$subdir/assert.t tmpdir/assert.o"] {
     fail $testname
 } else {
     pass $testname
diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
index 79c4e45..215e7b6 100644
--- a/ld/testsuite/ld-scripts/defined.exp
+++ b/ld/testsuite/ld-scripts/defined.exp
@@ -33,7 +33,7 @@ if [istarget "x86_64-*-mingw*"] then {
   set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
-if ![ld_simple_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] {
+if ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] {
     fail $testname
 } else {
     if ![ld_nm $nm "" tmpdir/def] {
diff --git a/ld/testsuite/ld-scripts/extern.exp b/ld/testsuite/ld-scripts/extern.exp
index f6048c4..b8d2b2d 100644
--- a/ld/testsuite/ld-scripts/extern.exp
+++ b/ld/testsuite/ld-scripts/extern.exp
@@ -26,7 +26,7 @@ if ![ld_assemble $as $srcdir/$subdir/extern.s tmpdir/extern.o] {
     return
 }
 
-if ![ld_simple_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] {
+if ![ld_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] {
     fail $testname
 }
 
diff --git a/ld/testsuite/ld-scripts/log2.exp b/ld/testsuite/ld-scripts/log2.exp
index 9654a4d..48b2688 100644
--- a/ld/testsuite/ld-scripts/log2.exp
+++ b/ld/testsuite/ld-scripts/log2.exp
@@ -26,7 +26,7 @@ if {![ld_assemble $as $srcdir/$subdir/log2.s tmpdir/log2.o]} {
 	return
 }
 
-if {![ld_simple_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} {
+if {![ld_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} {
 	fail $testname
 } else {
 	pass $testname
diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp
index 72df317..7a5cccb 100644
--- a/ld/testsuite/ld-scripts/map-address.exp
+++ b/ld/testsuite/ld-scripts/map-address.exp
@@ -26,7 +26,7 @@ if {![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/map-address.o]} {
     return
 }
 
-if {![ld_simple_link $ld tmpdir/map-address \
+if {![ld_link $ld tmpdir/map-address \
 	 "-T $srcdir/$subdir/map-address.t \
 	  tmpdir/map-address.o \
 	  -Map tmpdir/map-address.map"]} {
diff --git a/ld/testsuite/ld-scripts/phdrs.exp b/ld/testsuite/ld-scripts/phdrs.exp
index 4c268bc..5d9f6d4 100644
--- a/ld/testsuite/ld-scripts/phdrs.exp
+++ b/ld/testsuite/ld-scripts/phdrs.exp
@@ -48,7 +48,7 @@ if [is_elf64 tmpdir/phdrs.o] {
 }
 
 set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
-if ![ld_simple_link $ld tmpdir/phdrs $ldopt] {
+if ![ld_link $ld tmpdir/phdrs $ldopt] {
     fail $testname
 } else {
     if {![is_remote host] && [which $objdump] == 0} {
diff --git a/ld/testsuite/ld-scripts/phdrs2.exp b/ld/testsuite/ld-scripts/phdrs2.exp
index 5ab8b89..625b07a 100644
--- a/ld/testsuite/ld-scripts/phdrs2.exp
+++ b/ld/testsuite/ld-scripts/phdrs2.exp
@@ -55,7 +55,7 @@ set phdrs_regexp \
     ".*Program Header:.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]*.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800004 *paddr *0x00*800004.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags rw.*"
 
 set ldopt "$ldopt -T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o"
-if ![ld_simple_link $ld tmpdir/phdrs2 $ldopt] {
+if ![ld_link $ld tmpdir/phdrs2 $ldopt] {
     fail $testname
 } else {
     if {![is_remote host] && [which $objdump] == 0} {
diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp
index 7a04480..bb2c7b6 100644
--- a/ld/testsuite/ld-scripts/script.exp
+++ b/ld/testsuite/ld-scripts/script.exp
@@ -192,7 +192,7 @@ if {[istarget "*-*-pe*"] \
   set flags "--image-base 0"
 }
 
-if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
+if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
     fail $testname
 } else {
     check_script
@@ -200,7 +200,7 @@ if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir
 
 set testname "MRI script"
 
-if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
+if ![ld_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
     fail $testname
 } else {
     check_script
@@ -208,14 +208,14 @@ if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
 
 set testname "MEMORY"
 
-if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
+if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
     fail $testname
 } else {
     check_script
 }
 
 set testname "MEMORY with symbols"
-if ![ld_simple_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
+if ![ld_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
     fail $testname
     untested "extract symbols"
 } else {
diff --git a/ld/testsuite/ld-scripts/section-flags.exp b/ld/testsuite/ld-scripts/section-flags.exp
index 417db4a..550ae79 100644
--- a/ld/testsuite/ld-scripts/section-flags.exp
+++ b/ld/testsuite/ld-scripts/section-flags.exp
@@ -33,7 +33,7 @@ foreach test {"section-flags-1" "section-flags-2"} {
     if ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o] {
 	unresolved $test
     } else {
-	if ![ld_simple_link $ldcmd tmpdir/$test \
+	if ![ld_link $ldcmd tmpdir/$test \
 		"-T $srcdir/$subdir/$test.t tmpdir/$test.o"] {
 	    fail $test
 	} else {
diff --git a/ld/testsuite/ld-scripts/sizeof.exp b/ld/testsuite/ld-scripts/sizeof.exp
index f9dc9ee..5324ea4 100644
--- a/ld/testsuite/ld-scripts/sizeof.exp
+++ b/ld/testsuite/ld-scripts/sizeof.exp
@@ -27,7 +27,7 @@ if ![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/sizeof.o] {
     return
 }
 
-if ![ld_simple_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] {
+if ![ld_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] {
     fail $testname
     return
 }
diff --git a/ld/testsuite/ld-scripts/sysroot-prefix.exp b/ld/testsuite/ld-scripts/sysroot-prefix.exp
index 2f41bd4..2bb67e4 100644
--- a/ld/testsuite/ld-scripts/sysroot-prefix.exp
+++ b/ld/testsuite/ld-scripts/sysroot-prefix.exp
@@ -141,7 +141,7 @@ proc single_sysroot_prefix_test { type xtestname finalscript ldopt errstr } {
     close $ofd
     verbose -log "script: $finalscript"
 
-    set res [ld_simple_link $ld tmpdir/output "$ldopt tmpdir/main.o -Ltmpdir -lsysroottest"]
+    set res [ld_link $ld tmpdir/output "$ldopt tmpdir/main.o -Ltmpdir -lsysroottest"]
     set ld_output "$exec_output"
     set expect_success [expr [string length $errstr] == 0]
 
diff --git a/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp
index 04b19aa..1affef6 100644
--- a/ld/testsuite/ld-scripts/weak.exp
+++ b/ld/testsuite/ld-scripts/weak.exp
@@ -55,7 +55,7 @@ set weak_regexp_big \
 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 "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
+if {! [ld_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
     fail $testname
 } else {
     if {![is_remote host] && [which $objdump] == 0} then {
diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
index ac456e4..8d58c16 100644
--- a/ld/testsuite/ld-selective/selective.exp
+++ b/ld/testsuite/ld-selective/selective.exp
@@ -151,7 +151,7 @@ foreach testitem $seltests {
 	set objfile "$objfile --defsym _.d2=0"
     }
 
-    if ![ld_simple_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
+    if ![ld_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
 	fail $testname
 	continue
     }
diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp
index ce9dad4..f87911b 100644
--- a/ld/testsuite/ld-sh/sh.exp
+++ b/ld/testsuite/ld-sh/sh.exp
@@ -37,7 +37,7 @@ 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"] {
+} else { if ![ld_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
     fail $testsimple
 } else {
     if ![ld_nm $nm "" tmpdir/sh1] {
@@ -73,7 +73,7 @@ if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
 } else {
     set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
 }
-if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
+if ![ld_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
     fail $testsrec
 } else {
     # The file name is embedded in the S-records, so create both
@@ -114,7 +114,7 @@ set testadjsw8 "SH switch8 adjustment after relax"
 if ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] {
     unresolved $testadjsw8
 } else {
-    if ![ld_simple_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
+    if ![ld_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
 	fail $testadjsw8
     } else {
 	send_log "exec $objdump -s tmpdir/adjsw8\n"
@@ -156,7 +156,7 @@ if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
     return
 }
 
-if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
+if ![ld_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
     fail $testlink
     unresolved $testjsr
     unresolved $testrun
diff --git a/ld/testsuite/ld-sh/sh64/relax.exp b/ld/testsuite/ld-sh/sh64/relax.exp
index c862c5e..fbde450 100644
--- a/ld/testsuite/ld-sh/sh64/relax.exp
+++ b/ld/testsuite/ld-sh/sh64/relax.exp
@@ -114,7 +114,7 @@ proc run_sh64relaxtest {sh64relaxtests} {
 	# disabled.  Hence the lax checking here.
 	
 	file delete $binfile
-	set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
+	set result [ld_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
 	if ![file exists $binfile] {
 	    
 	    if {$expect_relaxed == -1} {
diff --git a/ld/testsuite/ld-sh/sh64/relfail.exp b/ld/testsuite/ld-sh/sh64/relfail.exp
index fdfce76..427e8d3 100644
--- a/ld/testsuite/ld-sh/sh64/relfail.exp
+++ b/ld/testsuite/ld-sh/sh64/relfail.exp
@@ -180,7 +180,7 @@ proc run_sh64relfailtests {sh64relfailtests} {
 	
 	file delete $binfile
 	set objects "tmpdir/relfail-$testindex.o $baseobj"
-	set result [ld_simple_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
+	set result [ld_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
 	
 	set exists [file exists $binfile]
 	if {$exists && $expect_fail == ""} {
diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
index 748a93b..93181dc 100644
--- a/ld/testsuite/ld-shared/shared.exp
+++ b/ld/testsuite/ld-shared/shared.exp
@@ -25,8 +25,10 @@
 # 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}
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
 
 # This test can only be run on a couple of ELF platforms.
 # Square bracket expressions seem to confuse istarget.
@@ -137,7 +139,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 	set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
     }
-    if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
+    if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
         fail "$testname"
     	return
     }
@@ -150,11 +152,16 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 	set rpath /lib:$tmpdir
     }
-    if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
+    if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
     	fail "$testname"
     	return
     }
 
+    if ![isnative] {
+	unsupported $testname
+	return
+    }
+
     # Run the resulting program
     send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
     verbose "$tmpdir/$progname >$tmpdir/$progname.out"
diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp
index 53ae96b..d4c3b8f 100644
--- a/ld/testsuite/ld-size/size.exp
+++ b/ld/testsuite/ld-size/size.exp
@@ -49,12 +49,6 @@ foreach t $test_list {
     run_dump_test [file rootname $t]
 }
 
-# We need a native system.
-if ![isnative] {
-    verbose "Native size relocation tests not run - not a native toolchain"
-    return
-}
-
 # We need a working compiler.
 if { [which $CC] == 0 } {
     verbose "Native size relocation tests not run - no compiler available"
@@ -179,7 +173,7 @@ if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/size-7.out" ] } then {
 run_ld_link_exec_tests [list \
     [list \
 	"Run size-1" \
-	"tmpdir/libsize-1.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-1.so" \
 	"" \
 	{size-1.c} \
 	"size-1" \
@@ -187,7 +181,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-2" \
-	"tmpdir/libsize-2.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-2.so" \
 	"" \
 	{size-2.c} \
 	"size-2" \
@@ -203,7 +197,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-3b" \
-	"tmpdir/libsize-3a.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-3a.so" \
 	"" \
 	{size-3.c} \
 	"size-3b" \
@@ -219,7 +213,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-3d (1)" \
-	"tmpdir/libsize-3b.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-3b.so" \
 	"" \
 	{size-3.c} \
 	"size-3d1" \
@@ -235,7 +229,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
     {"Run size-3e"
-     "tmpdir/libsize-3c.so" ""
+     "-Wl,--no-as-needed tmpdir/libsize-3c.so" ""
      {size-3.c} "size-3e" "size-3.out"}
     ] \
     [list \
@@ -276,7 +270,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-6" \
-	"tmpdir/libsize-6b.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-6b.so" \
 	"" \
 	{size-6a.c} \
 	"size-6" \
@@ -285,7 +279,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-8" \
-	"tmpdir/libsize-8.so --hash-styl=gnu" \
+	"-Wl,--no-as-needed,--hash-styl=gnu tmpdir/libsize-8.so" \
 	"" \
 	{size-8a.c} \
 	"size-8" \
@@ -294,7 +288,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-9" \
-	"tmpdir/libsize-9.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-9.so" \
 	"" \
 	{size-9a.c} \
 	"size-9" \
@@ -302,7 +296,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"Run size-10" \
-	"tmpdir/libsize-10.so" \
+	"-Wl,--no-as-needed tmpdir/libsize-10.so" \
 	"" \
 	{size-10a.c} \
 	"size-10" \
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index eb68d83..2720043 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -230,7 +230,7 @@ proc run_srec_test { test objs } {
     # Tell the ELF linker to not do anything clever with .eh_frame,
     # not to put anything in small data, and define various symbols.
     set flags "--traditional-format -G 0 "
-    append flags [ld_simple_link_defsyms]
+    append flags [ld_link_defsyms]
 
     # 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
@@ -305,8 +305,8 @@ proc run_srec_test { test objs } {
 	set flags "$flags -no-relax"
     }
 
-    if { ![ld_simple_link $ld tmpdir/sr1 "$flags $objs"] \
-	 || ![ld_simple_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
+    if { ![ld_link $ld tmpdir/sr1 "$flags $objs"] \
+	 || ![ld_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
 	fail $test
 	return
     }
diff --git a/ld/testsuite/ld-tic6x/tic6x.exp b/ld/testsuite/ld-tic6x/tic6x.exp
index 3129b02..c1b0608 100644
--- a/ld/testsuite/ld-tic6x/tic6x.exp
+++ b/ld/testsuite/ld-tic6x/tic6x.exp
@@ -148,12 +148,12 @@ if { ![ld_assemble_flags $as "-mpic -mpid=near" $srcdir/$subdir/shlib-1.s tmpdir
      || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-1.s tmpdir/shlib-1b.o]
      || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-2.s tmpdir/shlib-2b.o]
      || ![ld_assemble_flags $as -mbig-endian $srcdir/$subdir/shlib-app-1.s tmpdir/shlib-app-1b.o]
-     || ![ld_simple_link $ld tmpdir/libtest.so "-shared tmpdir/shlib-1.o tmpdir/shlib-2.o"]
-     || ![ld_simple_link $ld tmpdir/libtestb.so "-shared -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
-     || ![ld_simple_link $ld tmpdir/shlib.o "-r tmpdir/shlib-1.o tmpdir/shlib-2.o"]
-     || ![ld_simple_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
-     || ![ld_simple_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"]
-     || ![ld_simple_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } {
+     || ![ld_link $ld tmpdir/libtest.so "-shared tmpdir/shlib-1.o tmpdir/shlib-2.o"]
+     || ![ld_link $ld tmpdir/libtestb.so "-shared -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
+     || ![ld_link $ld tmpdir/shlib.o "-r tmpdir/shlib-1.o tmpdir/shlib-2.o"]
+     || ![ld_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
+     || ![ld_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"]
+     || ![ld_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } {
     unresolved "TIC6X OSABI tests"
     return
 }
diff --git a/ld/testsuite/ld-undefined/weak-undef.exp b/ld/testsuite/ld-undefined/weak-undef.exp
index 9109a22..eb28c2c 100644
--- a/ld/testsuite/ld-undefined/weak-undef.exp
+++ b/ld/testsuite/ld-undefined/weak-undef.exp
@@ -29,7 +29,7 @@ if { ![is_elf_format] && ![is_pecoff_format] } then {
 	    tmpdir/weak-undef.o]} then {
     # It's OK if .weak doesn't work on this target.
     unresolved $testname
-} elseif {![ld_simple_link $ld tmpdir/weak-undef \
+} elseif {![ld_link $ld tmpdir/weak-undef \
 		"tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"]} then {
     # Weak symbols are broken for non-i386 PE targets.
     if {! [istarget i?86-*-*]} {
@@ -71,7 +71,7 @@ if { $asflags == "" || ![is_elf_format] || ![check_shared_lib_support]} then {
 } elseif {![ld_assemble $as "$asflags $srcdir/$subdir/weak-fundef.s" \
 		tmpdir/weak-fundef.o]} then {
     fail $testname
-} elseif {![ld_simple_link $ld tmpdir/weak-fundef.so \
+} elseif {![ld_link $ld tmpdir/weak-fundef.so \
 	    "--shared tmpdir/weak-fundef.o"]} then {
     fail $testname
 } elseif {![is_remote host] && [which $nm] == 0} then {
@@ -92,7 +92,7 @@ if { $asflags == "" || ![is_elf_format] || ![check_shared_lib_support]} then {
     # When linking a dynamic executable, weak undefined symbols become dynamic.
     set testname "weak undefined function symbols in dynamic exe"
 
-    if {![ld_simple_link $ld tmpdir/weak-fundef \
+    if {![ld_link $ld tmpdir/weak-fundef \
 	  "--no-as-needed tmpdir/weak-fundef.o tmpdir/weak-fundef.so"]} then {
 	fail $testname
     } else {
diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index 3a4ce22..668ac95 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -37,15 +37,6 @@ if { ![supports_gnu_unique] } {
 
 run_dump_test "unique"
 
-# We need a native system.  FIXME: Strictly speaking this
-# is not true, we just need to know how to create a fully
-# linked executable, including the C and Z libraries, using
-# the linker that is under test.
-if ![isnative] {
-    verbose "UNIQUE compiled tests not run - not a native toolchain"
-    return
-}
-
 # We need a working compiler.  (Strictly speaking this is
 # not true, we could use target specific assembler files).
 if { [which $CC] == 0 } {
@@ -124,25 +115,25 @@ if ![ld_compile "$CC -c -fPIC" "$srcdir/$subdir/unique_shared.s" "tmpdir/unique_
 }
 
 # Create executable containing unique symbol.
-if ![default_ld_link $ld "tmpdir/unique_prog" "tmpdir/unique.o"] {
+if ![ld_link $CC "tmpdir/unique_prog" "tmpdir/unique.o"] {
     fail "Could not link a unique executable"
     set fails [expr $fails + 1]
 }
 
 # Create shared library containing unique symbol.
-if ![ld_simple_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"] {
+if ![ld_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"] {
     fail "Could not create a shared library containing an unique symbol"
     set fails [expr $fails + 1]
 }
 
 # Create executable NOT containing unique symbol linked against library.
-if ![default_ld_link $ld "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Bdynamic -lunique_shared -rpath ./tmpdir"] {
+if ![ld_link $CC "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] {
     fail "Could not link a dynamic executable"
     set fails [expr $fails + 1]
 }
 
 # Create shared library containing unique symbol with reference.
-if ![ld_simple_link $ld "tmpdir/libunique_shared_ref.so" "-shared tmpdir/unique_shared.o tmpdir/unique_empty.o"] {
+if ![ld_link $ld "tmpdir/libunique_shared_ref.so" "-shared tmpdir/unique_shared.o tmpdir/unique_empty.o"] {
     fail "Could not create a shared library containing an unique symbol with reference"
     set fails [expr $fails + 1]
 }
@@ -182,8 +173,12 @@ if { $fails == 0 } {
 }
 
 # Check the empty object file.
-if {! [check_osabi tmpdir/unique_empty.o {UNIX - System V}]} {
-    fail "Object NOT containing unique does not have an OS/ABI field of System V"
+case $target_triplet in {
+    { hppa*-*-linux* } { set expected_none {UNIX - GNU} }
+    default { set expected_none {UNIX - System V} }
+}
+if {! [check_osabi tmpdir/unique_empty.o $expected_none]} {
+    fail "Object NOT containing unique does not have an OS/ABI field of $expected_none"
     set fails [expr $fails + 1]
 }
 
@@ -238,8 +233,8 @@ if { $fails == 0 } {
 }
 
 # Check the empty executable linked against unique shared library.
-if {! [check_osabi tmpdir/unique_shared_prog {UNIX - System V}]} {
-    fail "Executable NOT containing unique does not have an OS/ABI field of System V"
+if {! [check_osabi tmpdir/unique_shared_prog $expected_none]} {
+    fail "Executable NOT containing unique does not have an OS/ABI field of $expected_none"
     set fails [expr $fails + 1]
 }
 
@@ -251,14 +246,3 @@ if {[contains_unique_symbol tmpdir/unique_shared_prog] == 1} {
 if { $fails == 0 } {
   pass "Checking shared empty executable"
 }
-
-# Clean up, unless we are being verbose, in which case we leave the files available.
-if { $verbose < 1 } {
-    remote_file host delete "tmpdir/unique_empty.o"
-    remote_file host delete "tmpdir/unique.o"
-    remote_file host delete "tmpdir/unique_shared.o"
-    remote_file host delete "tmpdir/libunique_shared.so"
-    remote_file host delete "tmpdir/libunique_shared_ref.so"
-    remote_file host delete "tmpdir/unique_prog"
-    remote_file host delete "tmpdir/unique_shared_prog"
-}
diff --git a/ld/testsuite/ld-versados/versados.exp b/ld/testsuite/ld-versados/versados.exp
index 9584b0c..55612e3 100644
--- a/ld/testsuite/ld-versados/versados.exp
+++ b/ld/testsuite/ld-versados/versados.exp
@@ -75,7 +75,7 @@ proc inspect { whichone } {
     return 1
 }
 
-if ![ld_simple_link $ld tmpdir/t1.out \
+if ![ld_link $ld tmpdir/t1.out \
 	" -T $srcdir/$subdir/t1.ld $srcdir/$subdir/t1-1.ro  $srcdir/$subdir/t1-2.ro"] {
     fail $testname
     return
@@ -87,7 +87,7 @@ if ![ld_simple_link $ld tmpdir/t1.out \
 }
 
 
-if ![ld_simple_link $ld  tmpdir/t2.out \
+if ![ld_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
diff --git a/ld/testsuite/ld-x86-64/dwarfreloc.exp b/ld/testsuite/ld-x86-64/dwarfreloc.exp
index c96ffd0..7e2486b 100644
--- a/ld/testsuite/ld-x86-64/dwarfreloc.exp
+++ b/ld/testsuite/ld-x86-64/dwarfreloc.exp
@@ -58,14 +58,14 @@ set build_tests_ld {
 run_ld_link_tests $build_tests_ld
 
 set testname "Link dwarfreloc1xa.o and dwarfreloc2xa.o to dwarfreloca.o"
-if [ld_simple_link $ld "tmpdir/dwarfreloca.o" "-r tmpdir/dwarfreloc1xa.o tmpdir/dwarfreloc2xa.o"] {
+if [ld_link $ld "tmpdir/dwarfreloca.o" "-r tmpdir/dwarfreloc1xa.o tmpdir/dwarfreloc2xa.o"] {
     pass $testname
 } else {
     fail $testname
 }
 
 set testname "Link dwarfreloc1xb.o and dwarfreloc2xb.o to dwarfrelocb.o"
-if [ld_simple_link $ld "tmpdir/dwarfrelocb.o" "-r tmpdir/dwarfreloc1xb.o tmpdir/dwarfreloc2xb.o"] {
+if [ld_link $ld "tmpdir/dwarfrelocb.o" "-r tmpdir/dwarfreloc1xb.o tmpdir/dwarfreloc2xb.o"] {
     pass $testname
 } else {
     fail $testname
diff --git a/ld/testsuite/ld-x86-64/tls.exp b/ld/testsuite/ld-x86-64/tls.exp
index 2eddc31..7061320 100644
--- a/ld/testsuite/ld-x86-64/tls.exp
+++ b/ld/testsuite/ld-x86-64/tls.exp
@@ -97,8 +97,8 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"TLS GD/LD -> IE transition without PLT" \
-	"tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
-	 tmpdir/libtls-1a.so -R tmpdir" \
+	"-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
+	 tmpdir/tls-gd1.o tmpdir/tls-ld1.o tmpdir/libtls-1a.so" \
 	"" \
 	{ dummy.s } \
 	"tls-1d" \
@@ -106,8 +106,8 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"TLS without PLT (1)" \
-	"tmpdir/tls-main1.o \
-	 tmpdir/libtls-1a.so tmpdir/libtls-1b.so -R tmpdir" \
+	"-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
+	 tmpdir/libtls-1a.so tmpdir/libtls-1b.so" \
 	"" \
 	{ dummy.s } \
 	"tls-1e" \
@@ -115,8 +115,8 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
 	"TLS without PLT (2)" \
-	"tmpdir/tls-main1.o tmpdir/tls-def1.o \
-	 tmpdir/libtls-1b.so -R tmpdir" \
+	"-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
+	 tmpdir/tls-def1.o tmpdir/libtls-1b.so" \
 	"" \
 	{ dummy.s } \
 	"tls-1f" \
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index ac63a1d..26d739e 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -247,7 +247,7 @@ global ld
 
 set test_name "Mixed x86_64 and i386 input test 1"
 set test mixed1
-if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
+if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
     if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
 	pass "$test_name"
     } {
@@ -257,7 +257,7 @@ if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}
 
 set test_name "Mixed x86_64 and i386 input test 2"
 set test mixed2
-if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
+if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
     if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
 	pass "$test_name"
     } {
@@ -538,7 +538,7 @@ proc undefined_weak {cflags ldflags} {
     }
 
     if { [ regexp "\-fPIE" $cflags]
-	 && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } {
+	 && ![ regexp "nodynamic-undefined-weak" $ldflags] } {
 	set weak_symbol "Weak defined"
     } else {
 	set weak_symbol "Weak undefined"
@@ -568,7 +568,7 @@ proc undefined_weak {cflags ldflags} {
     run_ld_link_exec_tests [list \
 	[list \
 	    "Run pr19704" \
-	    "$ldflags tmpdir/libpr19704.so -R tmpdir" \
+	    "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
 	    "" \
 	    { pr19704a.c } \
 	    "pr19704" \
@@ -833,8 +833,8 @@ if { [isnative] && [which $CC] != 0 } {
     run_ld_link_exec_tests [list \
 	[list \
 	    "Run plt-main" \
-	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
-	     tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
+	     tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
 	    "" \
 	    { plt-main5.c } \
 	    "plt-main" \
@@ -842,8 +842,8 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run plt-main with PIE" \
-	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
-	     tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
+	    "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
+	     tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
 	    "" \
 	    { plt-main5.c } \
 	    "plt-main-pie" \
@@ -852,7 +852,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run copyreloc-main with PIE without -fPIE" \
-	    "--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
 	    "" \
 	    { dummy.s } \
 	    "copyreloc-main" \
@@ -860,7 +860,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run pr17689 with PIE without -fPIE" \
-	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
 	    "" \
 	    { dummy.s } \
 	    "pr17689" \
@@ -868,7 +868,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run pr17689 with PIE -z now without -fPIE" \
-	    "--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
+	    "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
 	    "" \
 	    { dummy.s } \
 	    "pr17689now" \
@@ -876,7 +876,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run pr18900" \
-	    "tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
 	    "" \
 	    { dummy.s } \
 	    "pr18900" \
@@ -884,7 +884,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run pr19031" \
-	    "tmpdir/pr19031.so" \
+	    "-Wl,--no-as-needed tmpdir/pr19031.so" \
 	    "" \
 	    { pr19031b.S pr19031c.c } \
 	    "pr19031" \
@@ -892,7 +892,7 @@ if { [isnative] && [which $CC] != 0 } {
 	] \
 	[list \
 	    "Run gotpcrel1" \
-	    "tmpdir/gotpcrel1d.so" \
+	    "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
 	    "" \
 	    { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
 	    "gotpcrel1" \
@@ -930,7 +930,7 @@ if { [isnative] && [which $CC] != 0 } {
 	run_ld_link_exec_tests [list \
 	    [list \
 		"Run pr19784a" \
-		"tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
+		"-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
 		"" \
 		{ dummy.s } \
 		"pr19784a" \
@@ -938,7 +938,7 @@ if { [isnative] && [which $CC] != 0 } {
 	    ] \
 	    [list \
 		"Run pr19784b" \
-		"--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
+		"-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
 		"" \
 		{ dummy.s } \
 		"pr19784b" \
@@ -974,8 +974,9 @@ if { [isnative] && [which $CC] != 0 } {
 	run_ld_link_exec_tests [list \
 	    [list \
 		"Run plt-main with -z bndplt" \
-		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
-		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt" \
+		"-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
 		"" \
 		{ plt-main5.c } \
 		"plt-main-bnd" \
@@ -983,8 +984,9 @@ if { [isnative] && [which $CC] != 0 } {
 	    ] \
 	    [list \
 		"Run plt-main with PIE and -z bndplt" \
-		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
-		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie" \
+		"-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
 		"" \
 		{ plt-main5.c } \
 		"plt-main-pie-bnd" \
@@ -993,7 +995,7 @@ if { [isnative] && [which $CC] != 0 } {
 	    ] \
 	    [list \
 		"Run pr20800" \
-		"-pie -z now" \
+		"-Wl,-z,now -pie" \
 		"" \
 		{ pr20800a.S pr20800b.S } \
 		"pr20800" \
@@ -1005,8 +1007,8 @@ if { [isnative] && [which $CC] != 0 } {
     undefined_weak "" ""
     undefined_weak "-fPIE" ""
     undefined_weak "-fPIE" "-pie"
-    undefined_weak "-fPIE" "-z nodynamic-undefined-weak"
-    undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
+    undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
+    undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
 }
 
 if { ![istarget "x86_64-*-linux*"]} {
diff --git a/ld/testsuite/ld-xtensa/coalesce.exp b/ld/testsuite/ld-xtensa/coalesce.exp
index 425f865..a61624c 100644
--- a/ld/testsuite/ld-xtensa/coalesce.exp
+++ b/ld/testsuite/ld-xtensa/coalesce.exp
@@ -69,7 +69,7 @@ if ![ld_assemble $as $srcdir/$subdir/coalesce2.s tmpdir/coalesce2.o] {
 set object "tmpdir/coalesce"
 set outputfile "$object.txt"
 
-if ![ld_simple_link $ld $object "-T $srcdir/$subdir/coalesce.t tmpdir/coalesce1.o tmpdir/coalesce2.o"] {
+if ![ld_link $ld $object "-T $srcdir/$subdir/coalesce.t tmpdir/coalesce1.o tmpdir/coalesce2.o"] {
     verbose -log "failure in ld"
     fail $testname
     return
diff --git a/ld/testsuite/ld-xtensa/diff_overflow.exp b/ld/testsuite/ld-xtensa/diff_overflow.exp
index 3d857d4..c130ce7 100644
--- a/ld/testsuite/ld-xtensa/diff_overflow.exp
+++ b/ld/testsuite/ld-xtensa/diff_overflow.exp
@@ -36,7 +36,7 @@ if ![ld_assemble $as "--text-section-literals $srcdir/$subdir/diff_overflow2.s"
 
 set object "tmpdir/diff_overflow"
 
-if ![ld_simple_link $ld $object "tmpdir/diff_overflow1.o tmpdir/diff_overflow2.o"] {
+if ![ld_link $ld $object "tmpdir/diff_overflow1.o tmpdir/diff_overflow2.o"] {
     verbose -log "failure in ld"
     fail $testname
     return
diff --git a/ld/testsuite/ld-xtensa/lcall.exp b/ld/testsuite/ld-xtensa/lcall.exp
index 209079f..895406e 100644
--- a/ld/testsuite/ld-xtensa/lcall.exp
+++ b/ld/testsuite/ld-xtensa/lcall.exp
@@ -69,7 +69,7 @@ if ![ld_assemble $as $srcdir/$subdir/lcall2.s tmpdir/lcall2.o] {
 set object "tmpdir/lcall"
 set outputfile "$object.txt"
 
-if ![ld_simple_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] {
+if ![ld_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] {
     verbose -log "failure in ld"
     fail $testname
     return
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index d3bda4d..f8d5ec6 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -199,41 +199,9 @@ proc big_or_little_endian {} {
     return $flags
 }
 
-# Link a program using ld.
+# Link a program using ld
 #
 proc default_ld_link { ld target objects } {
-    global HOSTING_EMU
-    global HOSTING_CRT0
-    global HOSTING_SCRT0
-    global HOSTING_LIBS
-    global HOSTING_SLIBS
-    global LIBS
-    global host_triplet
-    global link_output
-    global exec_output
-
-    if { [ string match "* -pie *" $objects ] } {
-	set objs "$HOSTING_SCRT0 $objects"
-	set libs "$LIBS $HOSTING_SLIBS"
-    } else {
-	set objs "$HOSTING_CRT0 $objects"
-	set libs "$LIBS $HOSTING_LIBS"
-    }
-
-    if [is_endian_output_format $objects] then {
-	set flags [big_or_little_endian]
-    } else {
-	set flags ""
-    }
-
-    remote_file host delete $target
-
-    return [run_host_cmd_yesno "$ld" "$HOSTING_EMU $flags -o $target $objs $libs"]
-}
-
-# Link a program using ld, without including any libraries.
-#
-proc default_ld_simple_link { ld target objects } {
     global host_triplet
     global exec_output
 
@@ -409,7 +377,7 @@ proc default_ld_nm { nm nmflags object } {
 
 # Define various symbols needed when not linking against all
 # target libs.
-proc ld_simple_link_defsyms {} {
+proc ld_link_defsyms {} {
 
     set flags "--defsym __stack_chk_fail=0"
 
@@ -1269,7 +1237,7 @@ proc run_ld_link_tests { ldtests args } {
 	    if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } {
 		set failed 1
 	    }
-	} elseif { ![ld_simple_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
+	} elseif { ![ld_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
 	    set maybe_failed 1
 	    set ld_output "$exec_output"
 	}
@@ -1452,20 +1420,12 @@ proc run_ld_link_exec_tests { ldtests args } {
 	    }
 	}
 
-	# We have to use $CC to build PIE and shared library.
-	if { [ string match "c" $lang ] } {
-	    set link_proc ld_simple_link
-	    set link_cmd $CC
-	} elseif { [ string match "c++" $lang ] } {
-	    set link_proc ld_simple_link
+	if { [ string match "c++" $lang ] } {
+	    set link_proc ld_link
 	    set link_cmd $CXX
-	} elseif { [ string match "-shared" $ld_options ] \
-		   || [ string match "-pie" $ld_options ] } {
-	    set link_proc ld_simple_link
-	    set link_cmd $CC
 	} else {
 	    set link_proc ld_link
-	    set link_cmd $ld
+	    set link_cmd $CC
 	}
 
 	if { $binfile eq "tmpdir/" } {
@@ -1486,7 +1446,7 @@ proc run_ld_link_exec_tests { ldtests args } {
 	    }
 	}
 
-	if { $failed == 0 } {
+	if { $failed == 0 && [isnative] } {
 	    send_log "Running: $binfile > $binfile.out\n"
 	    verbose "Running: $binfile > $binfile.out"
 	    catch "exec $binfile > $binfile.out" exec_output
@@ -1511,6 +1471,8 @@ proc run_ld_link_exec_tests { ldtests args } {
 
 	if { $failed != 0 } {
 	    fail $testname
+	} elseif ![isnative] {
+	    unsupported $testname
 	} else {
 	    set errcnt 0
 	    pass $testname
@@ -1609,7 +1571,7 @@ proc run_cc_link_tests { ldtests } {
 		set failed 1
 	    }
 	} else {
-	    if { ![ld_simple_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
+	    if { ![ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
 		set failed 1
 	    }
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-02 13:35 Run more ld tests when not native Alan Modra
@ 2017-01-02 16:05 ` Christophe Lyon
  2017-01-03  0:29   ` Alan Modra
  2017-01-03 21:16 ` Run more ld tests when not native Dimitar Dimitrov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 22+ messages in thread
From: Christophe Lyon @ 2017-01-02 16:05 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Hi Alan,

On 2 January 2017 at 14:34, Alan Modra <amodra@gmail.com> wrote:
> Many of the ld tests are not run for cross builds, in some cases
> because the test needs to run a newly linked executable, and in others
> simply because it was easier to write the test for native only.  Even
> when a test needs to run, it's good to compile and link to exercise
> the linker.  So that's what this patch does.  I've also rid us of
> the old ld_link procedure with all the HOSTING_CRT0 etc. setup.  It's
> much simpler to just link with $CC.
>
> This does mean that a cross build with cross-compiler installed but
> no cross C-library will give lots of failures.  If that turns out to
> be too annoying, I guess we can write a tcl procedure to detect it and
> not run all the extra tests.
>
>         * Makefile.am (bootstrap): Delete rule.
>         (ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
>         (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
>         (HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
>         * configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
>         (HOSTING_LIBS, HOSTING_SLIBS): Likewise.
>         * configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
>         * Makefile.in: Regenerate.
>         * configure: Regenerate.
>         * testsuite/config/default.exp (get_link_files): Delete.
>         (HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
>         define.
>         (ld_simple_link): Delete.
>         * testsuite/lib/ld-lib.exp (default_ld_link): Delete
>         (default_ld_simple_link): Rename to default_ld_link.
>         (ld_simple_link_defsyms): Rename to ld_link_defsyms.
>         (run_ld_link_tests): Use ld_link, not ld_simple_link.
>         (run_cc_link_tests): Likewise.
>         (run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
>         Don't run exe when not native, and return unsupported.
>         * testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
>         Link ld1 etc. using $CC.
>         * testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
>         * testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
>         * testsuite/ld-cygwin/exe-export.exp: Likewise.
>         * testsuite/ld-elf/binutils.exp: Likewise.
>         * testsuite/ld-elf/eh-group.exp: Likewise.
>         * testsuite/ld-elf/exclude.exp: Likewise.
>         * testsuite/ld-elf/frame.exp: Likewise.
>         * testsuite/ld-elf/sec-to-seg.exp: Likewise.
>         * testsuite/ld-elf/tls_common.exp: Likewise.
>         * testsuite/ld-elfcomm/elfcomm.exp: Likewise.
>         * testsuite/ld-fastcall/fastcall.exp: Likewise.
>         * testsuite/ld-gc/gc.exp: Likewise.
>         * testsuite/ld-ifunc/binutils.exp: Likewise.
>         * testsuite/ld-mep/mep.exp: Likewise.
>         * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
>         * testsuite/ld-mn10300/mn10300.exp: Likewise.
>         * testsuite/ld-nios2/nios2.exp: Likewise.
>         * testsuite/ld-pe/pe-compile.exp: Likewise.
>         * testsuite/ld-pe/pe-run.exp: Likewise.
>         * testsuite/ld-pe/pe-run2.exp: Likewise.
>         * testsuite/ld-plugin/plugin.exp: Likewise.
>         * testsuite/ld-scripts/align.exp: Likewise.
>         * testsuite/ld-scripts/alignof.exp: Likewise.
>         * testsuite/ld-scripts/assert.exp: Likewise.
>         * testsuite/ld-scripts/defined.exp: Likewise.
>         * testsuite/ld-scripts/extern.exp: Likewise.
>         * testsuite/ld-scripts/log2.exp: Likewise.
>         * testsuite/ld-scripts/map-address.exp: Likewise.
>         * testsuite/ld-scripts/phdrs.exp: Likewise.
>         * testsuite/ld-scripts/phdrs2.exp: Likewise.
>         * testsuite/ld-scripts/script.exp: Likewise.
>         * testsuite/ld-scripts/section-flags.exp: Likewise.
>         * testsuite/ld-scripts/sizeof.exp: Likewise.
>         * testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
>         * testsuite/ld-scripts/weak.exp: Likewise.
>         * testsuite/ld-selective/selective.exp: Likewise.
>         * testsuite/ld-sh/sh.exp: Likewise.
>         * testsuite/ld-sh/sh64/relax.exp: Likewise.
>         * testsuite/ld-sh/sh64/relfail.exp: Likewise.
>         * testsuite/ld-srec/srec.exp: Likewise.
>         * testsuite/ld-tic6x/tic6x.exp: Likewise.
>         * testsuite/ld-undefined/weak-undef.exp: Likewise.
>         * testsuite/ld-versados/versados.exp: Likewise.
>         * testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
>         * testsuite/ld-xtensa/coalesce.exp: Likewise.
>         * testsuite/ld-xtensa/diff_overflow.exp: Likewise.
>         * testsuite/ld-xtensa/lcall.exp: Likewise.
>         * testsuite/ld-elf/audit.exp: Run non-native too.
>         * testsuite/ld-elf/compress.exp: Likewise.  Replace ld options with
>         gcc -Wl, options.
>         * testsuite/ld-elf/dwarf.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Add -Wl,--no-as-needed to some tests.
>         * testsuite/ld-elf/elf.exp: Run non-native too.  Formatting.
>         * testsuite/ld-elf/indirect.exp: Run non-native too.  Add
>         -Wl,--no-as-needed to most tests.
>         * testsuite/ld-elf/shared.exp: Run non-native too.  Use braces
>         to simplify quoting.  Set run_tests using [list] rather than
>         brace assignment to expand $extralibs.  Add -Wl,--no-as-needed
>         to many test.  Prefix ld options with -Wl,.
>         (mix_pic_and_non_pic): Don't run exe if not native.
>         * testsuite/ld-elf/wrap.exp: Run non-native too.  Add
>         -Wl,--no-as-needed and prefix ld options with -Wl,.
>         * testsuite/ld-elfvers/vers.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.
>         * testsuite/ld-elfvsb/elfvsb.exp: Likewise.
>         (visibility_test): Don't run exe if not native.
>         * testsuite/ld-elfweak/elfweak.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.
>         (build_exec): Don't run exe if not native.
>         * testsuite/ld-ifunc/ifunc.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
>         to some tests and prefix ld options with -Wl,.  Expect GNU
>         for hppa-linux even when no ifuncs.  Delete cleanup.
>         * testsuite/ld-pie/pie.exp: Run non-native too.
>         * testsuite/ld-plugin/lto.exp: Likewise.
>         * testsuite/ld-shared/shared.exp: Likewise.  Use ld_link,
>         not ld_simple_link.
>         (shared_test): Don't run exe if not native.
>         * testsuite/ld-size/size.exp: Run non-native too.  Add
>         -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
>         * testsuite/ld-unique/unique.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
>         to some tests and prefix ld options with -Wl,.  Expect GNU
>         for hppa-linux even when no unique syms.  Delete cleanup.
>         * testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
>         tests and prefix ld options with -Wl,.
>         * testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
>         Add -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
>
> diff --git a/ld/Makefile.am b/ld/Makefile.am
> index 21e0aeb..3a3e34d 100644
> --- a/ld/Makefile.am
> +++ b/ld/Makefile.am
> @@ -88,13 +88,6 @@ TEXI2POD = perl $(BASEDIR)/etc/texi2pod.pl $(AM_MAKEINFOFLAGS)
>  POD2MAN = pod2man --center="GNU Development Tools" \
>         --release="binutils-$(VERSION)" --section=1
>
> -#stuff for self hosting (can be overridden in config file).
> -HOSTING_CRT0 = @HOSTING_CRT0@
> -HOSTING_SCRT0 = @HOSTING_SCRT0@
> -HOSTING_LIBS = @HOSTING_LIBS@
> -HOSTING_SLIBS = @HOSTING_SLIBS@
> -HOSTING_EMU = -m $(EMUL)
> -
>  # Setup the testing framework, if you have one
>  EXPECT = expect
>  RUNTEST = runtest
> @@ -2118,60 +2111,6 @@ check-DEJAGNU: site.exp
>         else echo "WARNING: could not find \`runtest'" 1>&2; :;\
>         fi
>
> -# Rules for testing by relinking ld itself.
> -# A similar test is in the testsuite.  This target is for ease of use
> -# when porting ld.
> -
> -ld-partial.@OBJEXT@: ld-new$(EXEEXT)
> -       ./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld-partial.@OBJEXT@ -r $(OFILES)
> -ld1$(EXEEXT): ld-partial.@OBJEXT@
> -       ./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld1$(EXEEXT) $(HOSTING_CRT0) ld-partial.@OBJEXT@ $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
> -
> -ld1-full$(EXEEXT): ld-new
> -       ./ld-new$(EXEEXT) $(HOSTING_EMU) -o ld1-full$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
> -
> -ld2$(EXEEXT): ld1$(EXEEXT)
> -       ./ld1$(EXEEXT) $(HOSTING_EMU) -o ld2$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
> -
> -ld3$(EXEEXT): ld2$(EXEEXT)
> -       ./ld2$(EXEEXT) $(HOSTING_EMU) -o ld3$(EXEEXT) $(HOSTING_CRT0) $(OFILES) $(TESTBFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) $(LIBS)
> -
> -bootstrap: ld3$(EXEEXT)
> -       cmp ld2$(EXEEXT) ld3$(EXEEXT)
> -
> -.PHONY: bootstrap
> -
> -# A test program for C++ constructors and destructors.
> -# This test is now in the testsuite.
> -#
> -#cdtest: cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ ld.new
> -#      ./ld.new $(HOSTING_EMU) -o cdtest $(HOSTING_CRT0) \
> -#        cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ $(HOSTING_LIBS)
> -#
> -#cdtest.out: cdtest
> -#      ./cdtest > cdtest.tmp
> -#      mv cdtest.tmp cdtest.out
> -#
> -#cdtest-ur.@OBJEXT@: cdtest-main.@OBJEXT@ cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@ ld.new
> -#      ./ld.new $(HOSTING_EMU) -o cdtest-ur.@OBJEXT@ -Ur cdtest-main.@OBJEXT@ \
> -#        cdtest-bar.@OBJEXT@ cdtest-foo.@OBJEXT@
> -#
> -#cdtest-ur: cdtest-ur.@OBJEXT@
> -#      ./ld.new $(HOSTING_EMU) -o cdtest-ur $(HOSTING_CRT0) cdtest-ur.@OBJEXT@ \
> -#        $(HOSTING_LIBS)
> -#
> -#cdtest-ur.out: cdtest-ur
> -#      ./cdtest-ur > cdtest-ur.tmp
> -#      mv cdtest-ur.tmp cdtest-ur.out
> -#
> -#check-cdtest: cdtest.out cdtest-ur.out $(srcdir)/cdtest.exp
> -#      diff $(srcdir)/cdtest.exp cdtest.out
> -#      diff $(srcdir)/cdtest.exp cdtest-ur.out
> -#
> -#.PHONY: check-cdtest
> -
> -# END OF CHECK TARGETS
> -
>  #
>  # Build a dummy plugin using libtool.
>  #
> diff --git a/ld/configure.ac b/ld/configure.ac
> index 36a9f50..fe8eff6 100644
> --- a/ld/configure.ac
> +++ b/ld/configure.ac
> @@ -206,10 +206,6 @@ ACX_PROG_CMP_IGNORE_INITIAL
>  . ${srcdir}/configure.host
>
>  AC_SUBST(HDEFINES)
> -AC_SUBST(HOSTING_CRT0)
> -AC_SUBST(HOSTING_SCRT0)
> -AC_SUBST(HOSTING_LIBS)
> -AC_SUBST(HOSTING_SLIBS)
>  AC_SUBST(NATIVE_LIB_DIRS)
>
>  AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
> diff --git a/ld/configure.host b/ld/configure.host
> index 7632793..331ec0e 100644
> --- a/ld/configure.host
> +++ b/ld/configure.host
> @@ -22,237 +22,10 @@
>
>  # This file sets the following shell variables:
>  #  HDEFINES            host specific compiler flags
> -#  HOSTING_CRT0                crt0.o file used for bootstrapping
> -#  HOSTING_LIBS                libraries used for bootstrapping
>
>  HDEFINES=
> -HOSTING_CRT0=/lib/crt0.o
> -HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ]; then libgcc=../gcc/libgcc.a; else libgcc=\`${CC} -print-libgcc-file-name\`; fi; if [ -f ../gcc/libgcc_eh.a ]; then libgcc="$$libgcc ../gcc/libgcc_eh.a"; else libgcc_eh=\`${CC} -print-file-name=libgcc_eh.a\`; if [ x"$$libgcc_eh" != xlibgcc_eh.a ]; then libgcc="$$libgcc $$libgcc_eh"; fi; fi; if [ -f ../gcc/libunwind.a ]; then libgcc="$$libgcc ../gcc/libunwind.a"; else libunwind=\`${CC} -print-file-name=libunwind.a\`; if [ x"$$libunwind" != xlibunwind.a ]; then libgcc="$$libgcc $$libunwind"; fi; fi; echo --start-group $$libgcc -lc --end-group`'
> -
> -#
> -#      Generic configurations:
> -#
>
>  case "${host}" in
> -
> -*-*-dragonfly*)
> -  HOSTING_CRT0='-dynamic-linker `[ -f \`${CC} --print-prog-name=ld-elf.so.2\` ] || echo /usr/libexec/``${CC} --print-prog-name=ld-elf.so.2` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `${CC} --print-file-name=crtbegin.o`'
> -  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
> -  ;;
> -
> -*-*-freebsd* | *-*-kfreebsd*-gnu)
> -  HOSTING_CRT0='-dynamic-linker `[ -f \`${CC} --print-prog-name=ld-elf.so.1\` ] || echo /usr/libexec/``${CC} --print-prog-name=ld-elf.so.1` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `${CC} --print-file-name=crtbegin.o`'
> -  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
> -  ;;
> -
> -*-*-linux*aout* | *-*-linux*oldld)
> -  HOSTING_CRT0=/usr/lib/crt0.o
> -  ;;
> -
> -*-*-linux*libc1*)
> -  HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else ${CC} --print-file-name=crtend.o; fi` /usr/lib/crtn.o'
> -  ;;
> -
> -*-*-linux*)
> -  HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[      ][      ]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
> -  HOSTING_SCRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[     ][      ]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=Scrt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbeginS.o ]; then echo ../gcc/crtbeginS.o; else ${CC} --print-file-name=crtbeginS.o; fi`'
> -  HOSTING_SLIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtendS.o ]; then echo ../gcc/crtendS.o; else ${CC} --print-file-name=crtendS.o; fi` `${CC} --print-file-name=crtn.o`'
> -  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
> -  ;;
> -
> -*-*-gnu*)
> -  # When creating static executables, we ought to use crt0.o instead of crt1.o,
> -  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
> -  # but the testing infrastructure is not prepared for that.  This is not
> -  # relevant for most tests, and the few remaining ones have been XFAILed.
> -  HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[      ][      ]*\(.*/ld[^ ]*\.so[^    ]*\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
> -  ;;
> -
> -*-*-netbsd*)
> -  # Different versions of NetBSD with the ELF object format use different
> -  # sets of start/end files.
> -  HOSTING_CRT0='-dynamic-linker /usr/libexec/ld.elf_so /usr/lib/crt0.o'
> -  if [ -f `${CC} --print-file-name=crti.o` ]; then
> -    # Support for GCC's crtstuff present.
> -    HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crti.o`"
> -    if [ -f ../gcc/crtbegin.o ]; then
> -      HOSTING_CRT0="$HOSTING_CRT0 ../gcc/crtbegin.o"
> -    else
> -      HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crtbegin.o`"
> -    fi
> -  else
> -    # Support for GCC's crtstuff not present.
> -    HOSTING_CRT0="$HOSTING_CRT0 `${CC} --print-file-name=crtbegin.o`"
> -  fi
> -  if [ -f `${CC} --print-file-name=crtn.o` ]; then
> -    # Support for GCC's crtstuff present.
> -    if [ -f ../gcc/crtbegin.o ]; then
> -      HOSTING_LIBS="$HOSTING_LIBS ../gcc/crtend.o"
> -    else
> -      HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtend.o`"
> -    fi
> -    HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtn.o`"
> -  else
> -    # Support for GCC's crtstuff not present.
> -    HOSTING_LIBS="$HOSTING_LIBS `${CC} --print-file-name=crtend.o`"
> -  fi
> -  ;;
> -
> -*-*-openbsd*)
> -  HOSTING_CRT0="-dynamic-linker /usr/libexec/ld.so /usr/lib/crt0.o"
> -  HOSTING_CRT0="$HOSTING_CRT0 /usr/lib/crtbegin.o"
> -  HOSTING_LIBS="$HOSTING_LIBS /usr/lib/crtend.o"
> -  ;;
> -
> +     m88*-*-dgux*)
> +       HDEFINES=-D__using_DGUX ;;
>  esac
> -
> -#
> -# Now more specific configurations
> -#
> -
> -case "${host}" in
> -
> -*-*-linux*aout* | *-*-linux*oldld | *-*-linux*libc1*)
> -  # No further tweaking needed
> -  ;;
> -
> -arm*-*-linux-*)
> -  HOSTING_CRT0='-p '"$HOSTING_CRT0"
> -  ;;
> -
> -hppa*64*-*-hpux11*)
> -  HOSTING_CRT0=/usr/ccs/lib/pa20_64/crt0.o
> -  # Even if CC is not gcc, the tests use gcc.
> -  HOSTING_LIBS='--start-group `if [ -f ../gcc/libgcc.a ]; then echo ../gcc/libgcc.a; else if test "$GCC" = yes; then ${CC} --print-libgcc-file-name; else gcc --print-libgcc-file-name; fi fi` -lc --end-group /usr/lib/pa20_64/milli.a'
> -  ;;
> -
> -i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[12] | i[3-7]86-*-freebsd[12]\.* | i[3-7]86-*-freebsd*aout*)
> -  HOSTING_CRT0=/usr/lib/crt0.o
> -  ;;
> -
> -i[3-7]86-*-sysv4*)
> -  HOSTING_CRT0='/usr/ccs/lib/crt1.o /usr/ccs/lib/crti.o /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` /usr/ccs/lib/crtn.o'
> -  ;;
> -
> -i[3-7]86-sequent-ptx* | i[3-7]86-sequent-sysv*)
> -  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi`'
> -  ;;
> -
> -i[3-7]86-*-sysv*)
> -  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; fi` /lib/crtn.o'
> -  ;;
> -
> -i[3-7]86-*-solaris*)
> -  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
> -  ;;
> -
> -i[3-7]86-*-sco* | i[3-7]86-*-isc*)
> -  # In some configurations gcc does not use crtbegin.o and crtend.o.
> -  # In that case gcc -print-file-name=crtbegin.o will simply print
> -  # crtbegin.o.  We create dummy crtbegin.o and crtend.o files to
> -  # handle this.
> -  echo "int dummy_crtbegin () { return 0; }" > crtbegin.c
> -  ${CC} -c crtbegin.c -o crtbegin.o
> -  rm -f crtbegin.c
> -  echo "int dummy_crteng () { return 0; }" > crtend.c
> -  ${CC} -c crtend.c -o crtend.o
> -  rm -f crtend.c
> -  HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` /lib/crtn.o'
> -  ;;
> -
> -i[3-7]86-pc-interix*)
> -  HOSTING_CRT0='$$INTERIX_ROOT/usr/lib/crt0.o'
> -  HOSTING_LIBS='-L $$X/local_bin -L $$INTERIX_ROOT/usr/lib '"$HOSTING_LIBS"' -lcpsx -lc -lcpsx $$INTERIX_ROOT/usr/lib/psxdll.a $$INTERIX_ROOT/usr/lib/psxdll2.a'
> -  ;;
> -
> -i[3-7]86-*-cygwin* | x86_64-*-cygwin*)
> -  HOSTING_LIBS="$HOSTING_LIBS"' -lcygwin -L/usr/lib/w32api -luser32 -lkernel32 -ladvapi32 -lshell32 `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else ${CC} -print-libgcc-file-name; fi`'
> -  ;;
> -
> -i[3-7]86-*-mingw*)
> -  #We only support msvcrt.dll, crtid == 2.
> -  HOSTING_CRT0='/mingw/lib/crt2.o'
> -  HOSTING_LIBS='-L/mingw/lib -lmingw32 -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lmoldname -lmingwex -lmsvcrt `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else ${CC} -print-libgcc-file-name; fi`'
> -  ;;
> -
> -mips*-sgi-irix4* | mips*-sgi-irix5*)
> -  HOSTING_CRT0=/usr/lib/crt1.o
> -  HOSTING_LIBS="$HOSTING_LIBS"' /usr/lib/crtn.o'
> -  ;;
> -
> -mips*-sgi-irix6*)
> -  HOSTING_CRT0='/usr/lib32/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o ; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS='-L/usr/lib32 '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o ; else ${CC} -print-file-name=crtend.o; fi` /usr/lib32/crtn.o -init __do_global_ctors -fini __do_global_dtors'
> -  ;;
> -
> -m68*-motorola-sysv)
> -  HOSTING_CRT0='`if [ -f ../gcc/crt0.o ]; then echo ../gcc/crt0.o; elif [ -f \`${CC} -print-file-name=\`crt0.o ]; then echo \`${CC} -print-file-name=\`crt0.o; else echo /lib/crt0.o; fi`'
> -  HOSTING_LIBS=`sed -e 's,-lc,-lc881,' <<EOF
> -$HOSTING_LIBS
> -EOF`
> -  ;;
> -
> -m68*-sun-*)
> -  HOSTING_CRT0='/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o'
> -  ;;
> -
> -m88*-*-dgux*)
> -  HDEFINES=-D__using_DGUX
> -  HOSTING_CRT0='/lib/crt0.o -X'
> -  HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a
> -  ;;
> -
> -m88*-motorola-sysv3)
> -  HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi`'
> -  ;;
> -
> -sparc-*-solaris2*)
> -  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
> -  ;;
> -
> -sparc64-*-solaris2* | sparcv9-*-solaris2*)
> -  HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else ${CC} -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else ${CC} -print-file-name=crti.o; fi` /usr/ccs/lib/sparcv9/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} -print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS="$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else ${CC} -print-file-name=crtn.o; fi`'
> -  ;;
> -
> -*-*-dragonfly*)
> -  ;;
> -
> -*-*-freebsd* | *-*-kfreebsd*-gnu)
> -  ;;
> -
> -*-*-linux* | *-*-gnu*)
> -  ;;
> -
> -*-*-netbsd*)
> -  ;;
> -
> -*-*-openbsd*)
> -  ;;
> -
> -alpha*-*-*)
> -  HOSTING_CRT0=/usr/ccs/lib/crt0.o
> -  ;;
> -
> -esac
> -
> -# Provide default HOSTING_SCRT0.  Each host should define a proper one
> -# if needed.
> -if test -z "$HOSTING_SCRT0"; then
> -  HOSTING_SCRT0="$HOSTING_CRT0"
> -fi
> -
> -# Provide default HOSTING_SLIBS.  Each host should define a proper one
> -# if needed.
> -if test -z "$HOSTING_SLIBS"; then
> -  HOSTING_SLIBS="$HOSTING_LIBS"
> -fi
> diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
> index 33cc19d..899943c 100644
> --- a/ld/testsuite/config/default.exp
> +++ b/ld/testsuite/config/default.exp
> @@ -114,26 +114,6 @@ if { [istarget rx-*-*] } {
>  # 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] {
> -       #configure.host returns variables that can be substituted into
> -       #makefile rules, with embedded shell variable expansions.
> -       #make wants $$shell_var, we want $shell_var ...
> -       set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' <<EOF\n\$$varname\nEOF"
> -       set status [catch "exec sh -c [list $cmd]" result]
> -       if $status { error "Error getting native link files: $result" }
> -       set cmd "CC='$CC' && eval echo \"$result\""
> -       set status [catch "exec sh -c [list $cmd]" result]
> -       if $status { error "Error getting native link files: $result" }
> -       set $varname $result
> -       send_log "$varname = $result\n"
> -    }
> -}
> -
>  proc get_target_emul {} {
>      global target_triplet
>      global srcdir
> @@ -142,13 +122,6 @@ proc get_target_emul {} {
>      return $result
>  }
>
> -if [isnative] {
> -    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
> -       get_link_files $x
> -    }
> -} else {
> -    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
> -}
>  if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
>
>  #
> @@ -190,14 +163,6 @@ proc 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
>  #
> diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
> index 726b3fe..9a68ebe 100644
> --- a/ld/testsuite/ld-bootstrap/bootstrap.exp
> +++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
> @@ -48,13 +48,25 @@ if [check_plugin_api_available] {
>  # 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.
> -set test_flags {"" "strip" "--static" "--traditional-format"
> -               "--no-keep-memory" "--relax"}
> +set test_flags {"" "strip" "--static" "-Wl,--traditional-format"
> +               "-Wl,--no-keep-memory" "-Wl,--relax"}
>  if { [istarget "powerpc-*-*"] } {
> -    lappend test_flags "--ppc476-workaround"
> +    lappend test_flags "-Wl,--ppc476-workaround"
> +}
> +
> +set gcc_B_opt_save $gcc_B_opt
> +
> +foreach ldexe {ld1 ld2 ld3} {
> +    if {![file isdirectory tmpdir/gcc$ldexe]} then {
> +       catch "exec mkdir tmpdir/gcc$ldexe" status
> +       catch "exec ln -s ../$ldexe tmpdir/gcc$ldexe/ld" status
> +       catch "exec ln -s ld tmpdir/gcc$ldexe/collect-ld" status
> +       catch "exec ln -s ../../../gas/as-new tmpdir/gcc$ldexe/as" status
> +    }
>  }
>
>  foreach flags $test_flags {
> +    set gcc_B_opt $gcc_B_opt_save
>      set do_strip "no"
>      if {"$flags" == "strip"} {
>         set testname "bootstrap with $flags"
> @@ -67,8 +79,8 @@ foreach flags $test_flags {
>      }}
>
>      # --static is meaningless and --relax is incompatible with -r.
> -    set partial_flags "$flags"
> -    if { "$flags" == "--static" || "$flags" == "--relax" } {
> +    regsub -- "-Wl," $flags "" partial_flags
> +    if { "$partial_flags" == "--static" || "$partial_flags" == "--relax" } {
>         set partial_flags ""
>      }
>
> @@ -140,7 +152,7 @@ foreach flags $test_flags {
>         setup_xfail "mips*-*-irix5*"
>      }
>
> -    if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
> +    if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
>         fail $testname
>         continue
>      }
> @@ -155,36 +167,27 @@ foreach flags $test_flags {
>         }
>      }
>
> -    if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
> +    regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
> +    if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
>         fail $testname
>         continue
>      }
>
> -    if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
> +    regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
> +    if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
>         fail $testname
>         continue
>      }
>
> -    if {"$flags" == "--static"} {
> -       if { [istarget ia64-*-elf*]
> -            || [istarget ia64-*-linux*] } {
> -           # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
> -           # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
> -           # So we rebuild tmpdir/ld2 with tmpdir/ld3.
> -           if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
> -               fail $testname
> -               continue
> -           }
> -       }
> -    } else {
> -       if { [istarget mips*-*-linux*] } {
> -           # On Linux/mips, tmpdir/ld2 != tmpdir/ld3 is normal since
> -           # they are generated by different linkers, tmpdir/ld1 and
> -           # tmpdir/ld2. So we rebuild tmpdir/ld2 with tmpdir/ld3.
> -           if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
> -               fail $testname
> -               continue
> -           }
> +    if { "$flags" == "--static" && { [istarget ia64-*-elf*] || [istarget ia64-*-linux*] }
> +        || [istarget mips*-*-linux*] } {
> +       # On ia64 and mips, tmpdir/ld2 != tmpdir/ld3 is normal since they are
> +       # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
> +       # So we rebuild tmpdir/ld2 with tmpdir/ld3.
> +       regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
> +       if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
> +           fail $testname
> +           continue
>         }
>      }
>
> @@ -222,5 +225,6 @@ foreach flags $test_flags {
>      }
>  }
>
> +set gcc_B_opt $gcc_B_opt_save
>  catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
>  catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status
> diff --git a/ld/testsuite/ld-cdtest/cdtest.exp b/ld/testsuite/ld-cdtest/cdtest.exp
> index 31eb957..7920de5 100644
> --- a/ld/testsuite/ld-cdtest/cdtest.exp
> +++ b/ld/testsuite/ld-cdtest/cdtest.exp
> @@ -48,7 +48,7 @@ if {   ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.
>
>  set expected_output "$srcdir/$subdir/cdtest.dat"
>
> -if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
> +if ![ld_link $CC 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"
> @@ -95,7 +95,7 @@ if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/c
>  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] {
> +    if ![ld_link $CC tmpdir/cdtest tmpdir/cdtest.o] {
>         fail $test2
>      } else {
>         send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
> diff --git a/ld/testsuite/ld-checks/checks.exp b/ld/testsuite/ld-checks/checks.exp
> index 9775b34..b1c8454 100644
> --- a/ld/testsuite/ld-checks/checks.exp
> +++ b/ld/testsuite/ld-checks/checks.exp
> @@ -43,7 +43,7 @@ proc section_check {} {
>         return
>      }
>
> -    if ![ld_simple_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
> +    if ![ld_link $ld tmpdir/asm.x "$ldflags tmpdir/asm.o"] {
>         fail $test
>      } else {
>         pass $test
> @@ -55,7 +55,7 @@ proc section_check {} {
>      # script is used.
>      set ldflags "--check-sections -T $srcdir/$subdir/script -e foo"
>
> -    # Perform the equivalent of invoking ld_simple_link
> +    # Perform the equivalent of invoking ld_link
>      # except that we need to massage the output further.
>
>      set exec_output [run_host_cmd "$ld" "-o tmpdir/asm.x $ldflags tmpdir/asm.o"]
> diff --git a/ld/testsuite/ld-cygwin/exe-export.exp b/ld/testsuite/ld-cygwin/exe-export.exp
> index 4643bac..f3bf275 100644
> --- a/ld/testsuite/ld-cygwin/exe-export.exp
> +++ b/ld/testsuite/ld-cygwin/exe-export.exp
> @@ -63,7 +63,7 @@ proc run_dlltool { lib_file def_file } {
>  }
>
>  # ld_special_link
> -#       A copy of ld_simple_link (from ld-lib.exp) with extra
> +#       A copy of ld_link (from ld-lib.exp) with extra
>  #       code to strip warnings about creating libraries.
>  #
>  proc ld_special_link { ld target objects } {
> diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
> index b278ec1..aad5339 100644
> --- a/ld/testsuite/ld-elf/audit.exp
> +++ b/ld/testsuite/ld-elf/audit.exp
> @@ -25,11 +25,6 @@ if ![is_elf_format] {
>      return
>  }
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  # Check if compiler works
>  if { [which $CC] == 0 } {
>      return
> diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
> index 2a41bdf..61e6031 100644
> --- a/ld/testsuite/ld-elf/binutils.exp
> +++ b/ld/testsuite/ld-elf/binutils.exp
> @@ -61,7 +61,7 @@ proc binutils_test { prog_name ld_options test {test_name ""} {readelf_options "
>         return
>      }
>
> -    if { ![ld_simple_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } {
> +    if { ![ld_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } {
>         if { [string match "*not supported*" $link_output]
>              || [string match "*unrecognized option*" $link_output]
>              || [string match "*-z relro ignored*" $link_output] } {
> diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
> index a5c154f..b2b6ca1 100644
> --- a/ld/testsuite/ld-elf/compress.exp
> +++ b/ld/testsuite/ld-elf/compress.exp
> @@ -25,11 +25,6 @@ if ![is_elf_format] {
>      return
>  }
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  # Check if compiler works
>  if { [which $CC] == 0 } {
>      return
> @@ -92,22 +87,22 @@ set run_tests {
>       "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o" ""
>       {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
>      {"Run zlibnormal with libzlibfoo.so with zlib compressed debug sections"
> -     "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o --compress-debug-sections=zlib" ""
> +     "tmpdir/begin.o tmpdir/libzlibfoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
>       {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
>      {"Run zlibnormal with libfoozlib.so with zlib compressed debug sections"
> -     "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib" ""
> +     "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib" ""
>       {main.c} "zlibnormal" "normal.out" "-Wa,--compress-debug-sections=zlib"}
>      {"Run gnunormal with libgnufoo.so with zlib-gnu compressed debug sections"
> -     "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
> +     "tmpdir/gnubegin.o tmpdir/libgnufoo.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
>       {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
>      {"Run gnunormal with libfoozlib.so with zlib-gnu compressed debug sections"
> -     "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o --compress-debug-sections=zlib-gnu" ""
> +     "tmpdir/gnubegin.o tmpdir/libfoozlib.so tmpdir/end.o -Wl,--compress-debug-sections=zlib-gnu" ""
>       {main.c} "gnunormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gnu"}
>      {"Run gabinormal with libgabifoo.so with zlib-gabi compressed debug sections"
> -     "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
> +     "tmpdir/zlibbegin.o tmpdir/libgabifoo.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
>       {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
>      {"Run gabinormal with libfoozlib.so with zlib-gabi compressed debug sections"
> -     "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o --compress-debug-sections=zlib-gabi" ""
> +     "tmpdir/zlibbegin.o tmpdir/libfoozlib.so tmpdir/gabiend.o -Wl,--compress-debug-sections=zlib-gabi" ""
>       {main.c} "gabinormal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
>  }
>
> diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp
> index 86b4896..572c704 100644
> --- a/ld/testsuite/ld-elf/dwarf.exp
> +++ b/ld/testsuite/ld-elf/dwarf.exp
> @@ -29,11 +29,6 @@ if ![is_elf_format] {
>      return
>  }
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  # Check if compiler works
>  if { [which $CC] == 0 } {
>      return
> @@ -52,7 +47,7 @@ set build_tests {
>
>  set run_tests {
>      {"Run with libdwarf1.so first"
> -     "tmpdir/libdwarf1.so" ""
> +     "-Wl,--no-as-needed tmpdir/libdwarf1.so" ""
>       {dwarf1main.c} "dwarf1a" "dwarf1.out"
>       "-g -feliminate-dwarf2-dups"}
>      {"Run with libdwarf1.so last"
> @@ -73,7 +68,7 @@ proc strip_test {} {
>      set test_name "Strip -s $test"
>      set prog $strip
>
> -    if ![ld_simple_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
> +    if ![ld_link $ld tmpdir/$test "-shared tmpdir/dwarf1.o"] {
>         unresolved "$test_name"
>         return
>      }
> diff --git a/ld/testsuite/ld-elf/eh-group.exp b/ld/testsuite/ld-elf/eh-group.exp
> index 17dd2f9..59f6092 100644
> --- a/ld/testsuite/ld-elf/eh-group.exp
> +++ b/ld/testsuite/ld-elf/eh-group.exp
> @@ -65,7 +65,7 @@ set build_tests_ld [list                      \
>  run_ld_link_tests $build_tests_ld
>
>  set testname "Link eh-group.o to eh-group"
> -if [ld_simple_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
> +if [ld_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
>      pass $testname
>  } else {
>      fail $testname
> diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
> index e8b2d64..a5244e4 100644
> --- a/ld/testsuite/ld-elf/elf.exp
> +++ b/ld/testsuite/ld-elf/elf.exp
> @@ -221,11 +221,6 @@ if { [istarget *-*-*linux*]
>
>  set LDFLAGS $old_ldflags
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  if [check_gc_sections_available] {
>      run_cc_link_tests {
>         {"PR ld/13195" "-Wl,--gc-sections" ""
> @@ -234,23 +229,36 @@ if [check_gc_sections_available] {
>  }
>
>  set array_tests {
> -    {"preinit array" "" "" {preinit.c} "preinit" "preinit.out"}
> -    {"init array" "" "" {init.c} "init" "init.out"}
> -    {"fini array" "" "" {fini.c} "fini" "fini.out"}
> -    {"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
> +    {"preinit array" "" ""
> +       {preinit.c} "preinit" "preinit.out"}
> +    {"init array" "" ""
> +       {init.c} "init" "init.out"}
> +    {"fini array" "" ""
> +       {fini.c} "fini" "fini.out"}
> +    {"init array mixed" "" ""
> +       {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
>  }
>  set array_tests_pie {
> -    {"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" }
> -    {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"}
> -    {"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"}
> -    {"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
> -    {"PIE PR ld/14525" "-pie" "" {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
> +    {"PIE preinit array" "-pie" ""
> +       {preinit.c} "preinit" "preinit.out" "-fPIE"}
> +    {"PIE init array" "-pie" ""
> +       {init.c} "init" "init.out" "-fPIE"}
> +    {"PIE fini array" "-pie" ""
> +       {fini.c} "fini" "fini.out" "-fPIE"}
> +    {"PIE init array mixed" "-pie" ""
> +       {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
> +    {"PIE PR ld/14525" "-pie" ""
> +       {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
>  }
>  set array_tests_static {
> -    {"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"}
> -    {"static init array" "-static" "" {init.c} "init" "init.out"}
> -    {"static fini array" "-static" "" {fini.c} "fini" "fini.out"}
> -    {"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
> +    {"static preinit array" "-static" ""
> +       {preinit.c} "preinit" "preinit.out"}
> +    {"static init array" "-static" ""
> +       {init.c} "init" "init.out"}
> +    {"static fini array" "-static" ""
> +       {fini.c} "fini" "fini.out"}
> +    {"static init array mixed" "-static" ""
> +       {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
>  }
>
>  # NetBSD ELF systems do not currently support the .*_array sections.
> diff --git a/ld/testsuite/ld-elf/exclude.exp b/ld/testsuite/ld-elf/exclude.exp
> index 438fd02..9b6dd2f 100644
> --- a/ld/testsuite/ld-elf/exclude.exp
> +++ b/ld/testsuite/ld-elf/exclude.exp
> @@ -70,7 +70,7 @@ if {![string match "" $catch_output]} {
>
>  # Test that the symbol is normally exported.
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
> +if { [ld_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
>      pass $test1
>  } else {
>      if [string match "*shared not supported*" $link_output] {
> @@ -92,7 +92,7 @@ if ![ld_nm $nm "-D" tmpdir/exclude.so] {
>
>  # Test --exclude-libs libexclude
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
>      pass $test3
>  } else {
>      fail $test3
> @@ -109,7 +109,7 @@ if ![ld_nm $nm "-D" tmpdir/exclude.so] {
>
>  # Test alternate spellings of --exclude-libs
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
>       && [ld_nm $nm "-D" tmpdir/exclude.so]
>       && ! [info exists nm_output(exclude_common)]
>       && ! [info exists nm_output(exclude_sym)] } {
> @@ -118,7 +118,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared
>      fail $test5
>  }
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
>       && [ld_nm $nm "-D" tmpdir/exclude.so]
>       && ! [info exists nm_output(exclude_common)]
>       && ! [info exists nm_output(exclude_sym)] } {
> @@ -127,7 +127,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/e
>      fail $test6
>  }
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
>       && [ld_nm $nm "-D" tmpdir/exclude.so]
>       && ! [info exists nm_output(exclude_common)]
>       && ! [info exists nm_output(exclude_sym)] } {
> @@ -136,7 +136,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --sh
>      fail $test7
>  }
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
>       && [ld_nm $nm "-D" tmpdir/exclude.so]
>       && ! [info exists nm_output(exclude_common)]
>       && ! [info exists nm_output(exclude_sym)] } {
> @@ -145,7 +145,7 @@ if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --sh
>      fail $test8
>  }
>
> -if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
> +if { [ld_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
>       && [ld_nm $nm "-D" tmpdir/exclude.so]
>       && [info exists nm_output(exclude_common)]
>       && [info exists nm_output(exclude_sym)] } {
> diff --git a/ld/testsuite/ld-elf/frame.exp b/ld/testsuite/ld-elf/frame.exp
> index 3363568..0ddd77e 100644
> --- a/ld/testsuite/ld-elf/frame.exp
> +++ b/ld/testsuite/ld-elf/frame.exp
> @@ -64,7 +64,7 @@ if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/tbss.s tmpdir/tbss.o ]
>      return
>  }
>
> -if { [ld_simple_link $ld tmpdir/frame.so "--shared tmpdir/frame.o tmpdir/tbss.o"] } {
> +if { [ld_link $ld tmpdir/frame.so "--shared tmpdir/frame.o tmpdir/tbss.o"] } {
>      pass "$test1"
>  } else {
>      if [string match "*shared not supported*" $link_output] {
> @@ -79,7 +79,7 @@ if ![ld_assemble_flags $as $as_opt $srcdir/$subdir/table.s tmpdir/table.o ] {
>      return
>  }
>
> -if { [ld_simple_link $ld tmpdir/table.so "--shared tmpdir/table.o tmpdir/tbss.o"] } {
> +if { [ld_link $ld tmpdir/table.so "--shared tmpdir/table.o tmpdir/tbss.o"] } {
>      pass "$test2"
>  } else {
>      if [string match "*shared not supported*" $link_output] {
> diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp
> index a650505..5c5382c 100644
> --- a/ld/testsuite/ld-elf/indirect.exp
> +++ b/ld/testsuite/ld-elf/indirect.exp
> @@ -126,59 +126,54 @@ set testname "Indirect symbol 2"
>  set cmd "$ld -shared  -o tmpdir/indirect2.so tmpdir/indirect2.o"
>  check_link_message "$cmd" [list $string2 $string] "$testname"
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  set run_tests {
>      {"Run with libindirect3c.so 1"
> -     "tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
> +     "-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
>       {dummy.c} "indirect3a" "indirect3.out"}
>      {"Run with libindirect3c.so 2"
> -     "tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
> +     "-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" ""
>       {dummy.c} "indirect3b" "indirect3.out"}
>      {"Run with libindirect3c.so 3"
> -     "tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
> +     "-Wl,--no-as-needed tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" ""
>       {dummy.c} "indirect3c" "indirect3.out"}
>      {"Run with libindirect3c.so 4"
> -     "tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
> +     "-Wl,--no-as-needed tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" ""
>       {dummy.c} "indirect3d" "indirect3.out"}
>      {"Run with libindirect4c.so 1"
> -     "tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
> +     "-Wl,--no-as-needed tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" ""
>       {dummy.c} "indirect4a" "indirect4.out"}
>      {"Run with libindirect4c.so 2"
> -     "tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
> +     "-Wl,--no-as-needed tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" ""
>       {dummy.c} "indirect4b" "indirect4.out"}
>      {"Run with libindirect4c.so 3"
> -     "tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
> +     "-Wl,--no-as-needed tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" ""
>       {dummy.c} "indirect4c" "indirect4.out"}
>      {"Run with libindirect4c.so 4"
> -     "tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
> +     "-Wl,--no-as-needed tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
>       {dummy.c} "indirect4d" "indirect4.out"}
>      {"Run with libpr18720c.so 1"
> -     "tmpdir/pr18720a.o tmpdir/pr18720b.o tmpdir/libpr18720c.so" ""
> +     "-Wl,--no-as-needed tmpdir/pr18720a.o tmpdir/pr18720b.o tmpdir/libpr18720c.so" ""
>       {check-ptr-eq.c} "pr18720a" "pr18720.out"}
>      {"Run with libpr18720c.so 2"
> -     "tmpdir/pr18720a.o tmpdir/libpr18720c.so tmpdir/pr18720b.o" ""
> +     "-Wl,--no-as-needed tmpdir/pr18720a.o tmpdir/libpr18720c.so tmpdir/pr18720b.o" ""
>       {check-ptr-eq.c} "pr18720b" "pr18720.out"}
>      {"Run with libpr18720c.so 3"
> -     "tmpdir/pr18720b.o tmpdir/libpr18720c.so tmpdir/pr18720a.o" ""
> +     "-Wl,--no-as-needed tmpdir/pr18720b.o tmpdir/libpr18720c.so tmpdir/pr18720a.o" ""
>       {check-ptr-eq.c} "pr18720c" "pr18720.out"}
>      {"Run with libpr18720c.so 4"
> -     "tmpdir/libpr18720c.so tmpdir/pr18720b.o tmpdir/pr18720a.o" ""
> +     "-Wl,--no-as-needed tmpdir/libpr18720c.so tmpdir/pr18720b.o tmpdir/pr18720a.o" ""
>       {check-ptr-eq.c} "pr18720d" "pr18720.out"}
>      {"Run with libpr18720c.so 5"
> -     "tmpdir/libpr18720c.so tmpdir/pr18720b1.o tmpdir/pr18720a.o" ""
> +     "-Wl,--no-as-needed tmpdir/libpr18720c.so tmpdir/pr18720b1.o tmpdir/pr18720a.o" ""
>       {check-ptr-eq.c} "pr18720d" "pr18720.out"}
>      {"Run with libpr19553b.so"
> -     "tmpdir/libpr19553b.so tmpdir/libpr19553d.so -rpath-link ." ""
> +     "-Wl,--no-as-needed tmpdir/libpr19553b.so tmpdir/libpr19553d.so -Wl,-rpath-link,." ""
>       {pr19553a.c} "pr19553b" "pr19553b.out"}
>      {"Run with libpr19553c.so"
> -     "tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" ""
> +     "-Wl,--no-as-needed tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" ""
>       {pr19553a.c} "pr19553c" "pr19553c.out"}
>      {"Run with libpr19553d.so"
> -     "tmpdir/libpr19553d.so tmpdir/libpr19553b.so -rpath-link ." ""
> +     "-Wl,--no-as-needed tmpdir/libpr19553d.so tmpdir/libpr19553b.so -Wl,-rpath-link,." ""
>       {pr19553a.c} "pr19553d" "pr19553d.out"}
>  }
>
> diff --git a/ld/testsuite/ld-elf/sec-to-seg.exp b/ld/testsuite/ld-elf/sec-to-seg.exp
> index 05da6ef..5d86a32 100644
> --- a/ld/testsuite/ld-elf/sec-to-seg.exp
> +++ b/ld/testsuite/ld-elf/sec-to-seg.exp
> @@ -40,7 +40,7 @@ proc sec_to_seg_test { testname scriptname same_seg } {
>      global exec_output
>      global READELF
>
> -    if {! [ld_simple_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then {
> +    if {! [ld_link $ld tmpdir/sec-to-seg "-T $srcdir/$subdir/$scriptname tmpdir/sec-to-seg1.o tmpdir/sec-to-seg2.o"] } then {
>         fail $testname
>         return 0
>      }
> diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
> index 3cdac45..52baadd 100644
> --- a/ld/testsuite/ld-elf/shared.exp
> +++ b/ld/testsuite/ld-elf/shared.exp
> @@ -21,13 +21,6 @@
>
>  # Exclude non-ELF targets.
>
> -# The following tests require running the executable generated by ld,
> -# or enough of a build environment to create a fully linked executable.
> -# This is not commonly available when testing a cross-built linker.
> -if ![isnative] {
> -    return
> -}
> -
>  if ![is_elf_format] {
>      return
>  }
> @@ -38,6 +31,7 @@ if { [which $CC] == 0 } {
>  }
>
>  # Add -ldl to extralibs if needed
> +set extralibs ""
>  if { ![istarget *-*-freebsd*]} {
>      set extralibs "-ldl"
>  }
> @@ -55,7 +49,7 @@ set build_tests {
>    {"Build warn libbar.so"
>     "-shared" "-fPIC"
>     {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd}} "libbarw.so"
> -    "C" "^.*\\\): warning: function foo is deprecated$"}
> +   "c" {^.*\): warning: function foo is deprecated$} }
>    {"Build hidden libbar.so"
>     "-shared" "-fPIC"
>     {begin.c endhidden.c} {} "libbarh.so"}
> @@ -283,156 +277,156 @@ set build_tests {
>
>  run_cc_link_tests $build_tests
>
> -set run_tests {
> -    {"Run normal with libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
> -     {main.c} "normal" "normal.out"}
> -    {"Run protected with libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
> -     {main.c} "protected" "normal.out"}
> -    {"Run hidden with libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
> -     {main.c} "hidden" "hidden.out"}
> -    {"Run normal with versioned libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
> -     {main.c} "normalv" "normal.out"}
> -    {"Run warn with versioned libfoo.so"
> -     "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
> -     {main.c} "warn" "warn.out"
> -     "" "" "^.*\\\): warning: function foo is deprecated$"}
> -    {"Run protected with versioned libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
> -     {main.c} "protected" "normal.out"}
> -    {"Run hidden with versioned libfoo.so"
> -     "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
> -     {main.c} "hiddenv" "hidden.out"}
> -    {"Run normal libbar.so with libfoo.so"
> -     "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
> -     {main.c} "normal" "normal.out"}
> -    {"Run protected libbar.so with libfoo.so"
> -     "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
> -     {main.c} "protected" "normal.out"}
> -    {"Run hidden libbar.so with libfoo.so"
> -     "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
> -     {main.c} "hidden" "hidden.out"}
> -    {"Run normal libbar.so with versioned libfoo.so"
> -     "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
> -     {main.c} "normal" "normal.out"}
> -    {"Run protected libbar.so with versioned libfoo.so"
> -     "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
> -     {main.c} "protected" "normal.out"}
> -    {"Run hidden libbar.so with versioned libfoo.so"
> -     "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
> -     {main.c} "hidden" "hidden.out"}
> -    {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so"
> -     "--dynamic-list=dl1.list $extralibs" ""
> -     {dl1main.c} "dl1a" "dl1.out"}
> -    {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so"
> -     "--dynamic-list-data $extralibs" ""
> -     {dl1main.c} "dl1b" "dl1.out"}
> -    {"Run with libdl2a.so"
> -     "tmpdir/libdl2a.so" ""
> -     {dl2main.c} "dl2a" "dl2a.out"}
> -    {"Run with libdl2b.so"
> -     "tmpdir/libdl2b.so" ""
> -     {dl2main.c} "dl2b" "dl2b.out"}
> -    {"Run with libdl2c.so"
> -     "tmpdir/libdl2c.so" ""
> -     {dl2main.c} "dl2c" "dl2b.out"}
> -    {"Run with libdl4a.so"
> -     "tmpdir/libdl4a.so" ""
> -     {dl4main.c} "dl4a" "dl4a.out"}
> -    {"Run with libdl4b.so"
> -     "tmpdir/libdl4b.so" ""
> -     {dl4main.c} "dl4b" "dl4a.out"}
> -    {"Run with libdl4c.so"
> -     "tmpdir/libdl4c.so" ""
> -     {dl4main.c} "dl4c" "dl4b.out"}
> -    {"Run with libdl4d.so"
> -     "tmpdir/libdl4d.so" ""
> -     {dl4main.c} "dl4d" "dl4b.out"}
> -    {"Run with libdl4e.so"
> -     "tmpdir/libdl4e.so" ""
> -     {dl4main.c} "dl4e" "dl4a.out"}
> -    {"Run with libdl4f.so"
> -     "tmpdir/libdl4f.so" ""
> -     {dl4main.c} "dl4f" "dl4a.out"}
> -    {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so"
> -     "--dynamic-list-data $extralibs" ""
> -     {dl6amain.c} "dl6a1" "dl6a.out"}
> -    {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so"
> -     "-Bsymbolic-functions $extralibs" ""
> -     {dl6amain.c} "dl6a2" "dl6b.out"}
> -    {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so"
> -     "-Bsymbolic $extralibs" ""
> -     {dl6amain.c} "dl6a3" "dl6b.out"}
> -    {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so"
> -     "-Bsymbolic --dynamic-list-data $extralibs" ""
> -     {dl6amain.c} "dl6a4" "dl6a.out"}
> -    {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so"
> -     "-Bsymbolic-functions --dynamic-list-cpp-new $extralibs" ""
> -     {dl6amain.c} "dl6a5" "dl6b.out"}
> -    {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so"
> -     "--dynamic-list-cpp-new -Bsymbolic-functions $extralibs" ""
> -     {dl6amain.c} "dl6a6" "dl6b.out"}
> -    {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so"
> -     "--dynamic-list-data -Bsymbolic $extralibs" ""
> -     {dl6amain.c} "dl6a7" "dl6a.out"}
> -    {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so"
> -     "--dynamic-list-data $extralibs" ""
> -     {dl6bmain.c} "dl6b1" "dl6a.out"}
> -    {"Run dl6b2 with dlopen on libdl6b.so"
> -     "$extralibs" ""
> -     {dl6bmain.c} "dl6b2" "dl6b.out"}
> -    {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so"
> -     "--dynamic-list-data $extralibs" ""
> -     {dl6cmain.c} "dl6c1" "dl6b.out"}
> -    {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so"
> -     "--dynamic-list-data $extralibs" ""
> -     {dl6dmain.c} "dl6d1" "dl6b.out"}
> -    {"Run with libdata1.so"
> -     "tmpdir/libdata1.so" ""
> -     {dynbss1.c} "dynbss1" "pass.out"}
> -    {"Run with libdata2.so"
> -     "tmpdir/libdata2.so" ""
> -     {weakdef1.c} "weakdef1" "pass.out"}
> -    {"Run with libfunc1.so comm1.o"
> -     "tmpdir/libfunc1.so tmpdir/comm1.o" ""
> -     {dummy.c} "comm1" "pass.out"}
> -    {"Run with comm1.o libfunc1.so"
> -     "tmpdir/comm1.o tmpdir/libfunc1.so" ""
> -     {dummy.c} "comm1" "pass.out"}
> -    {"Run with pr11138-2.c libpr11138-1.so"
> -     "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" ""
> -     {dummy.c} "pr11138a" "pr11138.out"}
> -    {"Run with libpr11138-1.so pr11138-2.c"
> -     "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" ""
> -     {dummy.c} "pr11138b" "pr11138.out"}
> -    {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
> -     "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
> -     {dummy.c} "pr13250" "pass.out"}
> -    {"Run with pr14323-1.c pr14323-2.so"
> -     "tmpdir/libpr14323-2.so" ""
> -     {pr14323-1.c} "pr14323" "pass.out"}
> -    {"Run with pr14862-1.c libpr14862.so"
> -     "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
> -     {dummy.c} "pr14862" "pr14862.out"}
> -    {"Link with --add-needed"
> -     "tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" ""
> -     {dummy.c} "needed1a" "needed1.out"}
> -    {"Link with --copy-dt-needed-entries"
> -     "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" ""
> -     {dummy.c} "needed1b" "needed1.out"}
> -    {"Run relmain"
> -     "--no-as-needed -rpath=tmpdir -Ltmpdir -lrel" ""
> -     {relmain.c} "relmain" "relmain.out"}
> -    {"Run pr2404"
> -     "tmpdir/pr2404b.o tmpdir/libpr2404a.so" ""
> -     {dummy.c} "pr2404" "pr2404.out"}
> -    {"Run pr18458"
> -     "tmpdir/libpr18458a.so tmpdir/libpr18458b.so -z now" ""
> -     {pr18458c.c} "pr18458" "pass.out"}
> -}
> +set run_tests [list \
> +    [list "Run normal with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
> +     {main.c} "normal" "normal.out" ] \
> +    [list "Run protected with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
> +     {main.c} "protected" "normal.out" ] \
> +    [list "Run hidden with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
> +     {main.c} "hidden" "hidden.out" ] \
> +    [list "Run normal with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
> +     {main.c} "normalv" "normal.out" ] \
> +    [list "Run warn with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
> +     {main.c} "warn" "warn.out" \
> +     "" "c" {^.*\): warning: function foo is deprecated$} ] \
> +    [list "Run protected with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
> +     {main.c} "protected" "normal.out" ] \
> +    [list "Run hidden with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
> +     {main.c} "hiddenv" "hidden.out" ] \
> +    [list "Run normal libbar.so with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
> +     {main.c} "normal" "normal.out" ] \
> +    [list "Run protected libbar.so with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
> +     {main.c} "protected" "normal.out" ] \
> +    [list "Run hidden libbar.so with libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
> +     {main.c} "hidden" "hidden.out" ] \
> +    [list "Run normal libbar.so with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
> +     {main.c} "normal" "normal.out" ] \
> +    [list "Run protected libbar.so with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
> +     {main.c} "protected" "normal.out" ] \
> +    [list "Run hidden libbar.so with versioned libfoo.so" \
> +     "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
> +     {main.c} "hidden" "hidden.out" ] \
> +    [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
> +     "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
> +     {dl1main.c} "dl1a" "dl1.out" ] \
> +    [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
> +     {dl1main.c} "dl1b" "dl1.out" ] \
> +    [list "Run with libdl2a.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
> +     {dl2main.c} "dl2a" "dl2a.out" ] \
> +    [list "Run with libdl2b.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
> +     {dl2main.c} "dl2b" "dl2b.out" ] \
> +    [list "Run with libdl2c.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
> +     {dl2main.c} "dl2c" "dl2b.out" ] \
> +    [list "Run with libdl4a.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
> +     {dl4main.c} "dl4a" "dl4a.out" ] \
> +    [list "Run with libdl4b.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
> +     {dl4main.c} "dl4b" "dl4a.out" ] \
> +    [list "Run with libdl4c.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
> +     {dl4main.c} "dl4c" "dl4b.out" ] \
> +    [list "Run with libdl4d.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
> +     {dl4main.c} "dl4d" "dl4b.out" ] \
> +    [list "Run with libdl4e.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
> +     {dl4main.c} "dl4e" "dl4a.out" ] \
> +    [list "Run with libdl4f.so" \
> +     "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
> +     {dl4main.c} "dl4f" "dl4a.out" ] \
> +    [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
> +     {dl6amain.c} "dl6a1" "dl6a.out" ] \
> +    [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
> +     {dl6amain.c} "dl6a2" "dl6b.out" ] \
> +    [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
> +     {dl6amain.c} "dl6a3" "dl6b.out" ] \
> +    [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
> +     {dl6amain.c} "dl6a4" "dl6a.out" ] \
> +    [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
> +     {dl6amain.c} "dl6a5" "dl6b.out" ] \
> +    [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
> +     {dl6amain.c} "dl6a6" "dl6b.out" ] \
> +    [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
> +     {dl6amain.c} "dl6a7" "dl6a.out" ] \
> +    [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
> +     {dl6bmain.c} "dl6b1" "dl6a.out" ] \
> +    [list "Run dl6b2 with dlopen on libdl6b.so" \
> +     "-Wl,--no-as-needed $extralibs" "" \
> +     {dl6bmain.c} "dl6b2" "dl6b.out" ] \
> +    [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
> +     {dl6cmain.c} "dl6c1" "dl6b.out" ] \
> +    [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
> +     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
> +     {dl6dmain.c} "dl6d1" "dl6b.out" ] \
> +    [list "Run with libdata1.so" \
> +     "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
> +     {dynbss1.c} "dynbss1" "pass.out" ] \
> +    [list "Run with libdata2.so" \
> +     "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
> +     {weakdef1.c} "weakdef1" "pass.out" ] \
> +    [list "Run with libfunc1.so comm1.o" \
> +     "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
> +     {dummy.c} "comm1" "pass.out" ] \
> +    [list "Run with comm1.o libfunc1.so" \
> +     "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
> +     {dummy.c} "comm1" "pass.out" ] \
> +    [list "Run with pr11138-2.c libpr11138-1.so" \
> +     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
> +     {dummy.c} "pr11138a" "pr11138.out" ] \
> +    [list "Run with libpr11138-1.so pr11138-2.c" \
> +     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
> +     {dummy.c} "pr11138b" "pr11138.out" ] \
> +    [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
> +     "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \
> +     {dummy.c} "pr13250" "pass.out" ] \
> +    [list "Run with pr14323-1.c pr14323-2.so" \
> +     "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
> +     {pr14323-1.c} "pr14323" "pass.out" ] \
> +    [list "Run with pr14862-1.c libpr14862.so" \
> +     "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
> +     {dummy.c} "pr14862" "pr14862.out" ] \
> +    [list "Link with --add-needed" \
> +     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
> +     {dummy.c} "needed1a" "needed1.out" ] \
> +    [list "Link with --copy-dt-needed-entries" \
> +     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
> +     {dummy.c} "needed1b" "needed1.out" ] \
> +    [list "Run relmain" \
> +     "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
> +     {relmain.c} "relmain" "relmain.out" ] \
> +    [list "Run pr2404" \
> +     "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
> +     {dummy.c} "pr2404" "pr2404.out" ] \
> +    [list "Run pr18458" \
> +     "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
> +     {pr18458c.c} "pr18458" "pass.out" ] \
> +]
>
>  # NetBSD ELF systems do not currently support the .*_array sections.
>  run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
> @@ -502,10 +496,10 @@ set run_cxx_tests {
>       "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
>       {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
>      {"Run with libnew1a.so"
> -     "tmpdir/libnew1a.so" ""
> +     "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
>       {dl5.cc} "dl5a" "dl5.out" "" "c++"}
>      {"Run with libnew1b.so"
> -     "tmpdir/libnew1b.so" ""
> +     "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
>       {dl5.cc} "dl5b" "dl5.out" "" "c++"}
>  }
>
> @@ -543,7 +537,7 @@ if { [istarget *-*-linux*]
>      run_ld_link_exec_tests [list \
>         [list \
>             "Run pr2404 with PIE" \
> -           "-pie tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
> +           "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
>             "" \
>             { dummy.c } \
>             "pr2404pie" \
> @@ -597,7 +591,7 @@ if { [istarget *-*-linux*]
>         ] \
>         [list \
>             "Run pr19579" \
> -           "-pie -z text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
> +           "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
>             "" \
>             {dummy.c} \
>             "pr19579" \
> @@ -641,7 +635,7 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
>      run_ld_link_exec_tests [list \
>         [list \
>             "Run $exe fun defined" \
> -           "$ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so -rpath tmpdir" \
> +           "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
>             "" \
>             { pr19719a.c pr19719c.c } \
>             $exe \
> @@ -657,6 +651,11 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
>         setup_xfail $targ
>      }
>
> +    if ![isnative] {
> +       unsupported "Run $exe fun undefined"
> +       return
> +    }
> +
>      set exec_output [run_host_cmd "tmpdir/$exe" ""]
>      if {![string match "PASS" $exec_output]} {
>         fail "Run $exe fun undefined"
> diff --git a/ld/testsuite/ld-elf/tls_common.exp b/ld/testsuite/ld-elf/tls_common.exp
> index 7ebe016..b900312 100644
> --- a/ld/testsuite/ld-elf/tls_common.exp
> +++ b/ld/testsuite/ld-elf/tls_common.exp
> @@ -47,13 +47,13 @@ if { ![ld_assemble $as "--elf-stt-common=no $srcdir/$subdir/tls_common.s" tmpdir
>      return
>  }
>
> -if { ![ld_simple_link $ld tmpdir/tls_common1a.o "-r tmpdir/tls_commona.o"]
> -     || ![ld_simple_link $ld tmpdir/tls_common1b.o "-r tmpdir/tls_commona.o"] } {
> +if { ![ld_link $ld tmpdir/tls_common1a.o "-r tmpdir/tls_commona.o"]
> +     || ![ld_link $ld tmpdir/tls_common1b.o "-r tmpdir/tls_commona.o"] } {
>      fail "tls_common"
>      return
>  }
>
> -if { ![ld_simple_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
> +if { ![ld_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
>      if { [string match "*not supported*" $link_output]
>          || [string match "*unrecognized option*" $link_output] } {
>         unsupported "$ld_options is not supported by this target"
> @@ -65,7 +65,7 @@ if { ![ld_simple_link $ld tmpdir/tls_commona "tmpdir/tls_common1a.o"] } {
>      return
>  }
>
> -if { ![ld_simple_link $ld tmpdir/tls_commonb "tmpdir/tls_common1b.o"] } {
> +if { ![ld_link $ld tmpdir/tls_commonb "tmpdir/tls_common1b.o"] } {
>      if { [string match "*not supported*" $link_output]
>          || [string match "*unrecognized option*" $link_output] } {
>         unsupported "$ld_options is not supported by this target"
> diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp
> index be88ef6..4bf8faa 100644
> --- a/ld/testsuite/ld-elf/wrap.exp
> +++ b/ld/testsuite/ld-elf/wrap.exp
> @@ -25,11 +25,6 @@ if ![is_elf_format] {
>      return
>  }
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  # Check if compiler works
>  if { [which $CC] == 0 } {
>      return
> @@ -46,10 +41,10 @@ set build_tests {
>
>  set run_tests {
>      {"Run with libwrap1a.so and libwrap1b.so"
> -     "--wrap par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" ""
> +     "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1a.so tmpdir/libwrap1b.so" ""
>       {wrap1.c} "wrap1" "wrap1.out"}
>      {"Run with libwrap1b.so and libwrap1a.so"
> -     "--wrap par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" ""
> +     "-Wl,--no-as-needed,--wrap,par tmpdir/libwrap1b.so tmpdir/libwrap1a.so" ""
>       {wrap1.c} "wrap1" "wrap1.out"}
>  }
>
> diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
> index 860ce98..da33768 100644
> --- a/ld/testsuite/ld-elfcomm/elfcomm.exp
> +++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
> @@ -58,7 +58,7 @@ proc test_sort_common {} {
>         return 0
>      }
>
> -    if { ![ld_simple_link $ld tmpdir/sort-common.dx "--sort-common=descending tmpdir/sort-common.o"] } {
> +    if { ![ld_link $ld tmpdir/sort-common.dx "--sort-common=descending tmpdir/sort-common.o"] } {
>         fail "$test"
>         return 0
>      }
> @@ -82,7 +82,7 @@ proc test_sort_common {} {
>
>      verbose "Check to see that --sort-common=ascending sorts in ascending alignment"
>
> -    if { ![ld_simple_link $ld tmpdir/sort-common.ax "--sort-common=ascending tmpdir/sort-common.o"] } {
> +    if { ![ld_link $ld tmpdir/sort-common.ax "--sort-common=ascending tmpdir/sort-common.o"] } {
>         fail "$test"
>         return 0
>      }
> @@ -146,7 +146,7 @@ proc stt_common_test { options testname } {
>
>      set options "$options tmpdir/common1c.o"
>
> -    if { ! [ld_simple_link $ld tmpdir/common.exe $options] } {
> +    if { ! [ld_link $ld tmpdir/common.exe $options] } {
>        unresolved $testname
>        return 0
>      }
> @@ -191,7 +191,7 @@ if [istarget sh64*-*-*] {
>      }
>  }
>
> -if { [ld_simple_link $ld tmpdir/common1.o $options] } {
> +if { [ld_link $ld tmpdir/common1.o $options] } {
>      unresolved $test1w1
>      return
>  }
> @@ -228,7 +228,7 @@ if [istarget sh64*-*-*] {
>      }
>  }
>
> -if { [ld_simple_link $ld tmpdir/common1.o $options] } {
> +if { [ld_link $ld tmpdir/common1.o $options] } {
>      unresolved $test1w2
>      return
>  }
> diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
> index 90f204f..bd35ae2 100644
> --- a/ld/testsuite/ld-elfvers/vers.exp
> +++ b/ld/testsuite/ld-elfvers/vers.exp
> @@ -22,8 +22,10 @@
>
>  #
>
> -# This test can only be run if ld generates native executables.
> -if ![isnative] then {return}
> +# Check to see if the C compiler works
> +if { [which $CC] == 0 } {
> +    return
> +}
>
>  # This test can only be run on a couple of ELF platforms.
>  # Square bracket expressions seem to confuse istarget.
> @@ -544,7 +546,7 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
>         set script_arg "$script $srcdir/$subdir/$mapfile"
>      }
>
> -    if {![ld_simple_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg $ldargs"]}     {
> +    if {![ld_link $ld $tmpdir/$libname.so "$shared $tmpdir/$libname.o $other_lib $script_arg $ldargs"]}     {
>         fail "$test"
>         return
>      }
> @@ -635,7 +637,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
>         set script_arg "-Wl,$script $srcdir/$subdir/$mapfile"
>      }
>
> -    if {![ld_simple_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]}     {
> +    if {![ld_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]}     {
>         pass "$test"
>         return
>      }
> @@ -733,7 +735,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
>         set solibname_lib $tmpdir/$solibname
>      }
>
> -    if {![ld_simple_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]}     {
> +    if {![ld_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]}     {
>         fail "$test"
>         return
>      }
> diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
> index 5331ad5..9d590c7 100644
> --- a/ld/testsuite/ld-elfvsb/elfvsb.exp
> +++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
> @@ -24,6 +24,11 @@
>
>  # Make sure that ld can generate ELF shared libraries with visibility.
>
> +# Check to see if the C compiler works
> +if { [which $CC] == 0 } {
> +    return
> +}
> +
>  # This test can only be run on a couple of ELF platforms.
>  # Square bracket expressions seem to confuse istarget.
>  if { ![istarget hppa*64*-*-hpux*] \
> @@ -56,9 +61,6 @@ foreach t $test_list {
>      run_dump_test [file rootname $t]
>  }
>
> -# The remaining tests can only be run if ld generates native executables.
> -if ![isnative] then {return}
> -
>  set tmpdir tmpdir
>  set SHCFLAG ""
>  set shared_needs_pic "no"
> @@ -121,7 +123,7 @@ if { [istarget *-*-linux*]
>       || [istarget *-*-nacl*]
>       || [istarget *-*-gnu*] } {
>      if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
> -      if [ld_simple_link $CC $tmpdir/main "$tmpdir/main.o"] {
> +      if [ld_link $CC $tmpdir/main "$tmpdir/main.o"] {
>         catch "exec $tmpdir/main" support_protected
>        }
>      }
> @@ -145,7 +147,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
>      if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
>         set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
>      }
> -    if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
> +    if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
>         if { [ string match $visibility "hidden_undef" ]
>              && [regexp "undefined reference to \`\.?visibility\'" $link_output]
>              && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
> @@ -168,7 +170,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
>      if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
>         set rpath /lib:$tmpdir
>      }
> -    if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
> +    if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
>         if { [ string match $visibility "hidden" ]
>              && [regexp "undefined reference to \`\.?visibility\'" $link_output]
>              && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
> @@ -191,6 +193,11 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
>         fail "$testname"
>      }
>
> +    if ![isnative] {
> +       unsupported "$testname"
> +       return
> +    }
> +
>      # Run the resulting program
>      send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
>      verbose "$tmpdir/$progname >$tmpdir/$progname.out"
> @@ -502,7 +509,7 @@ visibility_run normal
>  if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
>      unresolved "common hidden symbol"
>  } else {
> -    if ![ld_simple_link $ld tmpdir/common "tmpdir/common.o"] {
> +    if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
>         fail "common hidden symbol"
>      } else {
>         pass "common hidden symbol"
> @@ -515,15 +522,15 @@ if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
>     if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
>         unresolved "weak hidden symbol"
>      } else {
> -       if ![ld_simple_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
> +       if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
>             fail "weak hidden symbol"
>         } else {
> -           if ![ld_simple_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
> +           if ![ld_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
>                 fail "weak hidden symbol DSO last"
>             } else {
>                 pass "weak hidden symbol DSO last"
>             }
> -           if ![ld_simple_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
> +           if ![ld_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
>                 fail "weak hidden symbol DSO first"
>             } else {
>                 pass "weak hidden symbol DSO first"
> diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
> index 88df180..e62291e 100644
> --- a/ld/testsuite/ld-elfweak/elfweak.exp
> +++ b/ld/testsuite/ld-elfweak/elfweak.exp
> @@ -22,8 +22,10 @@
>  #           Eric Youngdale (eric@andante.jic.com)
>  #
>
> -# This test can only be run if ld generates native executables.
> -if ![isnative] then {return}
> +# Check to see if the C compiler works
> +if { [which $CC] == 0 } {
> +    return
> +}
>
>  # This test can only be run on a couple of ELF platforms.
>  # Square bracket expressions seem to confuse istarget.
> @@ -290,7 +292,7 @@ proc build_lib {test libname objs dynsymexp} {
>        set files "$files $tmpdir/$obj"
>      }
>
> -    if {![ld_simple_link $CC $tmpdir/$libname.so "$shared $files"]} {
> +    if {![ld_link $CC $tmpdir/$libname.so "$shared $files"]} {
>         fail $test
>         return
>      }
> @@ -316,7 +318,7 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
>        set files "$files $tmpdir/$obj"
>      }
>
> -    if {![ld_simple_link $CC $tmpdir/$execname "$flags $files"]} {
> +    if {![ld_link $CC $tmpdir/$execname "$flags $files"]} {
>         fail "$test"
>         return
>      }
> @@ -335,6 +337,10 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
>         }
>      }
>
> +    if ![isnative] {
> +       unsupported $test
> +       return
> +    }
>      # Run the resulting program
>      send_log "$tmpdir/$execname >$tmpdir/$execname.out\n"
>      verbose "$tmpdir/$execname >$tmpdir/$execname.out"
> @@ -402,7 +408,7 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c $tmpdir/main.o] {
>      return
>  }
>
> -if {![ld_simple_link $CC $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
> +if {![ld_link $CC $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} {
>      fail "ELF weak"
>      return
>  }
> @@ -437,17 +443,17 @@ if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]
>      return
>  }
>
> -if {![ld_simple_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} {
> +if {![ld_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} {
>      fail "ELF weak"
>      return
>  }
>
> -if {![ld_simple_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} {
> +if {![ld_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} {
>      fail "ELF weak"
>      return
>  }
>
> -if {![ld_simple_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} {
> +if {![ld_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} {
>      fail "ELF weak"
>      return
>  }
> diff --git a/ld/testsuite/ld-fastcall/fastcall.exp b/ld/testsuite/ld-fastcall/fastcall.exp
> index d6184fa4..261a668 100644
> --- a/ld/testsuite/ld-fastcall/fastcall.exp
> +++ b/ld/testsuite/ld-fastcall/fastcall.exp
> @@ -45,7 +45,7 @@ if ![ld_assemble $as $srcdir/$subdir/import.s tmpdir/import.o] {
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/extern.x "$ldflags tmpdir/export.o tmpdir/import.o"] {
> +if ![ld_link $ld tmpdir/extern.x "$ldflags tmpdir/export.o tmpdir/import.o"] {
>      fail $testname
>  } else {
>      pass $testname
> diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
> index 0e7b8c0..ba4f70b 100644
> --- a/ld/testsuite/ld-gc/gc.exp
> +++ b/ld/testsuite/ld-gc/gc.exp
> @@ -54,7 +54,7 @@ proc test_gc { testname filename linker ldflags} {
>
>      set outfile "tmpdir/$filename"
>      set options "-L$srcdir/$subdir"
> -    append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile
> +    append options " " $ldflags " " [ld_link_defsyms] " " $objfile
>
>      # SH64 targets needs an extra ld option for this test.
>      if [istarget sh64*-*-*] {
> @@ -65,7 +65,7 @@ proc test_gc { testname filename linker ldflags} {
>         }
>      }
>
> -    if ![ld_simple_link $linker $outfile $options] {
> +    if ![ld_link $linker $outfile $options] {
>         fail $testname
>         return
>      }
> @@ -112,7 +112,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
>         set gasopt "-mpic -mpid=near"
>      }
>      if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
> -       || ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
> +       || ![ld_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
>         fail libpersonality
>      } else {
>         run_dump_test "personality"
> @@ -125,7 +125,7 @@ if { [is_remote host] || [which $CC] != 0 } {
>          || [istarget "*-*-nacl*"]
>          || [istarget "*-*-gnu*"] } {
>         ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
> -       ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
> +       ld_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
>         ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
>         run_dump_test "pr11218"
>      }
> diff --git a/ld/testsuite/ld-ifunc/binutils.exp b/ld/testsuite/ld-ifunc/binutils.exp
> index 0567c20..a02b71f 100644
> --- a/ld/testsuite/ld-ifunc/binutils.exp
> +++ b/ld/testsuite/ld-ifunc/binutils.exp
> @@ -54,7 +54,7 @@ proc binutils_test { prog_name ld_options test } {
>         return
>      }
>
> -    if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
> +    if { ![ld_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
>         if { [string match "*not supported*" $link_output]
>              || [string match "*unrecognized option*" $link_output] } {
>             unsupported "$ld_options is not supported by this target"
> diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
> index 0b488d0..d7519b5 100644
> --- a/ld/testsuite/ld-ifunc/ifunc.exp
> +++ b/ld/testsuite/ld-ifunc/ifunc.exp
> @@ -41,15 +41,6 @@ if {!(([istarget "i?86-*-*"]
>      return
>  }
>
> -# We need a native system.  FIXME: Strictly speaking this
> -# is not true, we just need to know how to create a fully
> -# linked executable, including the C and Z libraries, using
> -# the linker that is under test.
> -if ![isnative] {
> -    verbose "IFUNC tests not run - not a native toolchain"
> -    return
> -}
> -
>  # We need a working compiler.  (Strictly speaking this is
>  # not true, we could use target specific assembler files).
>  if { [which $CC] == 0 } {
> @@ -200,7 +191,7 @@ if { $fails != 0 } {
>      return
>  }
>
> -if ![ld_simple_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
> +if ![ld_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
>      fail "Could not create a shared library containing an IFUNC symbol"
>      set fails [expr $fails + 1]
>  }
> @@ -213,27 +204,27 @@ if { $fails != 0 } {
>      return
>  }
>
> -if ![default_ld_link $ld "tmpdir/dynamic_prog" "-Ltmpdir tmpdir/shared_prog.o -Bdynamic -lshared_ifunc -rpath ./tmpdir"] {
> +if ![ld_link $CC "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] {
>      fail "Could not link a dynamic executable"
>      set fails [expr $fails + 1]
>  }
> -if ![default_ld_link $ld "tmpdir/local_prog" "-Ltmpdir tmpdir/static_prog.o -lifunc"] {
> +if ![ld_link $CC "tmpdir/local_prog" "-Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] {
>      fail "Could not link a dynamic executable using local ifunc"
>      set fails [expr $fails + 1]
>  }
> -if ![default_ld_link $ld "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
> +if ![ld_link $CC "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
>      fail "Could not link a static executable"
>      set fails [expr $fails + 1]
>  }
> -if ![ld_simple_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
> +if ![ld_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
>      fail "Could not link a non-ifunc using static executable"
>      set fails [expr $fails + 1]
>  }
> -if ![default_ld_link $ld "tmpdir/test-1" "tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
> +if ![ld_link $CC "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
>      fail "Could not link test-1"
>      set fails [expr $fails + 1]
>  }
> -if ![ld_simple_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
> +if ![ld_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
>      fail "Could not link libtest-2.so"
>      set fails [expr $fails + 1]
>  }
> @@ -251,6 +242,11 @@ if { $fails == 0 } {
>  # ifunc should have an OSABI field of GNU.  The linked non-ifunc using
>  # executable should have an OSABI field of NONE (aka System V).
>
> +case $target_triplet in {
> +    { hppa*-*-linux* } { set expected_none {UNIX - GNU} }
> +    default { set expected_none {UNIX - System V} }
> +}
> +
>  if {! [check_osabi tmpdir/libshared_ifunc.so {UNIX - GNU}]} {
>      fail "Shared libraries containing ifunc does not have an OS/ABI field of GNU"
>      set fails [expr $fails + 1]
> @@ -263,12 +259,12 @@ if {! [check_osabi tmpdir/static_prog {UNIX - GNU}]} {
>      fail "Static ifunc-using executable does not have an OS/ABI field of GNU"
>      set fails [expr $fails + 1]
>  }
> -if {! [check_osabi tmpdir/dynamic_prog {UNIX - System V}]} {
> -    fail "Dynamic ifunc-using executable does not have an OS/ABI field of System V"
> +if {! [check_osabi tmpdir/dynamic_prog $expected_none]} {
> +    fail "Dynamic ifunc-using executable does not have an OS/ABI field of $expected_none"
>      set fails [expr $fails + 1]
>  }
> -if {! [check_osabi tmpdir/static_nonifunc_prog {UNIX - System V}]} {
> -    fail "Static non-ifunc-using executable does not have an OS/ABI field of System V"
> +if {! [check_osabi tmpdir/static_nonifunc_prog $expected_none]} {
> +    fail "Static non-ifunc-using executable does not have an OS/ABI field of $expected_none"
>      set fails [expr $fails + 1]
>  }
>
> @@ -335,21 +331,6 @@ if { $fails == 0 } {
>    pass "Checking ifunc binaries"
>  }
>
> -# Clean up, unless we are being verbose, in which case we leave the files available.
> -if { $verbose < 1 } {
> -    remote_file host delete "tmpdir/shared_prog.o"
> -    remote_file host delete "tmpdir/static_prog.o"
> -    remote_file host delete "tmpdir/shared_ifunc.o"
> -    remote_file host delete "tmpdir/static_ifunc.o"
> -    remote_file host delete "tmpdir/static_noifunc.o"
> -    remote_file host delete "tmpdir/libshared_ifunc.so"
> -    remote_file host delete "tmpdir/libifunc.a"
> -    remote_file host delete "tmpdir/dynamic_prog"
> -    remote_file host delete "tmpdir/local_prog"
> -    remote_file host delete "tmpdir/static_prog"
> -    remote_file host delete "tmpdir/static_nonifunc_prog"
> -}
> -
>  run_cc_link_tests [list \
>      [list \
>         "Build libpr16467a.so" \
> @@ -433,7 +414,7 @@ run_cc_link_tests [list \
>  run_ld_link_exec_tests [list \
>      [list \
>         "Run pr16467" \
> -       "tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
> +       "-Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
>         "" \
>         { dummy.c } \
>         "pr16467" \
> @@ -442,7 +423,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run ifunc-main" \
> -       "tmpdir/libifunc-lib.so" \
> +       "-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
>         "" \
>         { ifunc-main.c } \
>         "ifunc-main" \
> @@ -450,7 +431,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run ifunc-main with -fpic" \
> -       "tmpdir/libifunc-lib.so" \
> +       "-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
>         "" \
>         { ifunc-main.c } \
>         "ifunc-main" \
> @@ -510,7 +491,7 @@ run_cc_link_tests [list \
>  run_ld_link_exec_tests [list \
>      [list \
>         "Run pr18808" \
> -       "tmpdir/pr18808a.o tmpdir/libpr18808.so" \
> +       "-Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808.so" \
>         "" \
>         { dummy.c } \
>         "pr18808" \
> @@ -518,7 +499,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run pr18841 with libpr18841b.so" \
> -       "tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
> +       "-Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
>         "" \
>         { dummy.c } \
>         "pr18841b" \
> @@ -526,7 +507,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run pr18841 with libpr18841c.so" \
> -       "--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
> +       "-Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
>         "" \
>         { dummy.c } \
>         "pr18841c" \
> diff --git a/ld/testsuite/ld-mep/mep.exp b/ld/testsuite/ld-mep/mep.exp
> index 4b8e3a9..d6df072 100644
> --- a/ld/testsuite/ld-mep/mep.exp
> +++ b/ld/testsuite/ld-mep/mep.exp
> @@ -31,7 +31,7 @@ set testbsrweak "MeP bsr to undefined weak function"
>
>  if ![ld_assemble $as "$srcdir/$subdir/mep1.s" tmpdir/mep1.o] {
>      unresolved $testbsrweak
> -} else { if ![ld_simple_link $ld tmpdir/mep1 "-T$srcdir/$subdir/mep1.ld tmpdir/mep1.o"] {
> +} else { if ![ld_link $ld tmpdir/mep1 "-T$srcdir/$subdir/mep1.ld tmpdir/mep1.o"] {
>      fail $testbsrweak
>  } else {
>      pass $testbsrweak
> diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
> index 80f218f..dd84c9c 100644
> --- a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
> +++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
> @@ -67,7 +67,7 @@ proc good_combination {arglist flags} {
>
>      if {$objs == ""} {
>         unresolved $testname
> -    } elseif {![ld_simple_link "$ld $ldemul" $finalobj "-r $objs"]} {
> +    } elseif {![ld_link "$ld $ldemul" $finalobj "-r $objs"]} {
>         fail $testname
>      } else {
>         catch "exec $READELF --headers $finalobj" output
> @@ -106,7 +106,7 @@ proc bad_combination {arglist message} {
>
>      if {$objs == ""} {
>         unresolved $testname
> -    } elseif {[ld_simple_link "$ld $ldemul" $finalobj "-r $objs"]
> +    } elseif {[ld_link "$ld $ldemul" $finalobj "-r $objs"]
>               || [string first $message $link_output] < 0} {
>         fail $testname
>      } else {
> diff --git a/ld/testsuite/ld-mn10300/mn10300.exp b/ld/testsuite/ld-mn10300/mn10300.exp
> index 98c77cd..503dd77 100644
> --- a/ld/testsuite/ld-mn10300/mn10300.exp
> +++ b/ld/testsuite/ld-mn10300/mn10300.exp
> @@ -147,12 +147,12 @@ proc i126256-test { } {
>         return
>      }
>
> -    if { ![ld_simple_link $ld $tmpdir/i126256-1.so "-shared $tmpdir/i126256-1.o -e 0"]} {
> +    if { ![ld_link $ld $tmpdir/i126256-1.so "-shared $tmpdir/i126256-1.o -e 0"]} {
>          unresolved $testname
>         return
>      }
>
> -    if { ![ld_simple_link $ld $tmpdir/i126256-2.so "--relax -shared $tmpdir/i126256-2.o $tmpdir/i126256-1.so -e 0"]} {
> +    if { ![ld_link $ld $tmpdir/i126256-2.so "--relax -shared $tmpdir/i126256-2.o $tmpdir/i126256-1.so -e 0"]} {
>          fail $testname
>         return
>      }
> diff --git a/ld/testsuite/ld-nios2/nios2.exp b/ld/testsuite/ld-nios2/nios2.exp
> index b8ffd49..b712e9e 100644
> --- a/ld/testsuite/ld-nios2/nios2.exp
> +++ b/ld/testsuite/ld-nios2/nios2.exp
> @@ -22,7 +22,7 @@ if ![ld_assemble $as "-march=r2 $srcdir/$subdir/${test}b.s" tmpdir/${test}b.o] {
>      return
>  }
>
> -if { ![ld_simple_link $ld tmpdir/$test "tmpdir/${test}a.o tmpdir/${test}b.o"] } {
> +if { ![ld_link $ld tmpdir/$test "tmpdir/${test}a.o tmpdir/${test}b.o"] } {
>      if [string match "*architecture * is incompatible*" $link_output] {
>         pass "$test_name"
>      } {
> diff --git a/ld/testsuite/ld-pe/pe-compile.exp b/ld/testsuite/ld-pe/pe-compile.exp
> index 67a63e2..f29e5cf 100644
> --- a/ld/testsuite/ld-pe/pe-compile.exp
> +++ b/ld/testsuite/ld-pe/pe-compile.exp
> @@ -52,7 +52,7 @@ proc run_basefile_test { testname } {
>      global subdir
>      global verbose
>
> -    if ![ld_simple_link "$LD -e start \
> +    if ![ld_link "$LD -e start \
>             --base-file=tmpdir/$testname.base \
>             --export-all-symbols" tmpdir/$testname.dll \
>             "tmpdir/basefile1.o"] {
> @@ -92,7 +92,7 @@ proc run_ver_script_test { testname } {
>      global subdir
>      global verbose
>
> -    if ![ld_simple_link "$CC -shared \
> +    if ![ld_link "$CC -shared \
>             -Wl,--version-script,$srcdir/$subdir/$testname.ver \
>             -Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
>             "tmpdir/vers-script-dll.o"] {
> diff --git a/ld/testsuite/ld-pe/pe-run.exp b/ld/testsuite/ld-pe/pe-run.exp
> index 3fda17c..9fa6848 100644
> --- a/ld/testsuite/ld-pe/pe-run.exp
> +++ b/ld/testsuite/ld-pe/pe-run.exp
> @@ -71,9 +71,9 @@ proc test_direct_link_dll {} {
>      # Compile the dll.
>      if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
>         fail "compiling shared lib"
> -    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
> +    } elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
>         fail "linking shared lib (.dll)"
> -    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
> +    } elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
>         fail "linking shared lib (.sl)"
>      } else {
>         # Compile and link the client program.
> @@ -82,7 +82,7 @@ proc test_direct_link_dll {} {
>         } else {
>             # Check linking directly to direct_dll.dll.
>             set msg "linking client (.dll)"
> -           if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
> +           if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
>               "$tmpdir/direct_client.o $tmpdir/direct_dll.dll" ] {
>                 pass $msg
>             } else {
> @@ -91,7 +91,7 @@ proc test_direct_link_dll {} {
>
>             # Check linking directly to direct_dll.sl.
>             set msg "linking client (.sl)"
> -           if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
> +           if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
>               "$tmpdir/direct_client.o $tmpdir/direct_dll.sl" ] {
>                 pass $msg
>             } else {
> @@ -102,7 +102,7 @@ proc test_direct_link_dll {} {
>             # Create symbolic link.
>             catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch
>             set msg "linking client (symlink -> .dll)"
> -           if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
> +           if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
>               "$tmpdir/direct_client.o $tmpdir/libdirect_dll.dll.a" ] {
>                 pass $msg
>             } else {
> @@ -113,7 +113,7 @@ proc test_direct_link_dll {} {
>             # Create symbolic link.
>             catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch
>             set msg "linking client (symlink -> .sl)"
> -           if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
> +           if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
>               "$tmpdir/direct_client.o $tmpdir/libdirect_sl.dll.a" ] {
>                 pass $msg
>             } else {
> diff --git a/ld/testsuite/ld-pe/pe-run2.exp b/ld/testsuite/ld-pe/pe-run2.exp
> index 9e0a60b..5c8c48f 100644
> --- a/ld/testsuite/ld-pe/pe-run2.exp
> +++ b/ld/testsuite/ld-pe/pe-run2.exp
> @@ -73,9 +73,9 @@ proc test_direct2_link_dll {} {
>      # Compile the dll.
>      if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
>         fail "compiling shared lib fastcall/stdcall"
> -    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
> +    } elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
>         fail "linking shared lib (.dll) fastcall/stdcall"
> -    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
> +    } elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
>         fail "linking shared lib (.sl) fastcall/stdcall"
>      } else {
>         # Compile and link the client program.
> @@ -84,7 +84,7 @@ proc test_direct2_link_dll {} {
>         } else {
>             # Check linking directly to direct2_dll.dll.
>             set msg "linking client (.dll) fastcall/stdcall"
> -           if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
> +           if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
>               "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
>                 pass $msg
>             } else {
> @@ -93,7 +93,7 @@ proc test_direct2_link_dll {} {
>
>             # Check linking directly to direct2_dll.sl.
>             set msg "linking client (.sl) fastcall/stdcall"
> -           if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
> +           if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
>               "$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] {
>                 pass $msg
>             } else {
> @@ -104,7 +104,7 @@ proc test_direct2_link_dll {} {
>             # Create symbolic link.
>             catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
>             set msg "linking client (symlink -> .dll) fastcall/stdcall"
> -           if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
> +           if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
>               "$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] {
>                 pass $msg
>             } else {
> @@ -115,7 +115,7 @@ proc test_direct2_link_dll {} {
>             # Create symbolic link.
>             catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
>             set msg "linking client (symlink -> .sl) fastcall/stdcall"
> -           if [ld_simple_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
> +           if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
>               "$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] {
>                 pass $msg
>             } else {
> diff --git a/ld/testsuite/ld-pie/pie.exp b/ld/testsuite/ld-pie/pie.exp
> index aaac450..e9d1162 100644
> --- a/ld/testsuite/ld-pie/pie.exp
> +++ b/ld/testsuite/ld-pie/pie.exp
> @@ -19,9 +19,6 @@
>  # MA 02110-1301, USA.
>  #
>
> -# This test can only be run if ld generates native executables.
> -if ![isnative] then {return}
> -
>  if { ![istarget *-*-linux*]
>       && ![istarget *-*-nacl*]
>       && ![istarget *-*-gnu*] } {
> @@ -37,8 +34,10 @@ if { ![string match "" $exec_output] } {
>  }
>
>  set array_tests {
> -    {"weak undefined" "-pie" "" {weakundef.c} "weakundef" "weakundef.out" "-fPIC"}
> -    {"weak undefined data" "-pie" "" {weakundef-data.c} "weakundef-data" "weakundef.out" "-fPIC"}
> +    {"weak undefined" "-pie" ""
> +       {weakundef.c} "weakundef" "weakundef.out" "-fPIC"}
> +    {"weak undefined data" "-pie" ""
> +       {weakundef-data.c} "weakundef-data" "weakundef.out" "-fPIC"}
>  }
>
>  run_ld_link_exec_tests $array_tests
> diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
> index d1ef17e..bfc1b1cfd 100644
> --- a/ld/testsuite/ld-plugin/lto.exp
> +++ b/ld/testsuite/ld-plugin/lto.exp
> @@ -476,11 +476,6 @@ run_ld_link_tests [list \
>     {dummy.s} {} "pr19317-r.o"] \
>  ]
>
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
>  run_ld_link_exec_tests $lto_run_tests
>
>  if { [is_elf_format] } {
> diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
> index 1323a09..ba32818 100644
> --- a/ld/testsuite/ld-plugin/plugin.exp
> +++ b/ld/testsuite/ld-plugin/plugin.exp
> @@ -124,7 +124,7 @@ set testsrcfiles "tmpdir/main.o $srcdir/$subdir/func.c tmpdir/text.o"
>  set testsrcfiles_notext "tmpdir/main.o $srcdir/$subdir/func.c"
>  # Rather than having libs we just define dummy values for anything
>  # we may need to link a target exe; we aren't going to run it anyway.
> -set libs "[ld_simple_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
> +set libs "[ld_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
>  if { $dotsym } {
>      append libs " --defsym .printf=.main --defsym .puts=.main"
>  }
> diff --git a/ld/testsuite/ld-scripts/align.exp b/ld/testsuite/ld-scripts/align.exp
> index 302efa2..297aa13 100644
> --- a/ld/testsuite/ld-scripts/align.exp
> +++ b/ld/testsuite/ld-scripts/align.exp
> @@ -38,7 +38,7 @@ if [istarget "x86_64-*-mingw*"] then {
>    set LDFLAGS "$LDFLAGS --image-base 0"
>  }
>
> -if ![ld_simple_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
> +if ![ld_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
>      fail $testname
>  } else {
>      pass $testname
> diff --git a/ld/testsuite/ld-scripts/alignof.exp b/ld/testsuite/ld-scripts/alignof.exp
> index e5d1ea9..91f05e1 100644
> --- a/ld/testsuite/ld-scripts/alignof.exp
> +++ b/ld/testsuite/ld-scripts/alignof.exp
> @@ -32,7 +32,7 @@ if ![ld_assemble $as $srcdir/$subdir/alignof.s tmpdir/alignof.o] {
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] {
> +if ![ld_link $ld tmpdir/alignof "-T $srcdir/$subdir/alignof.t tmpdir/alignof.o"] {
>      fail $testname
>      return
>  }
> diff --git a/ld/testsuite/ld-scripts/assert.exp b/ld/testsuite/ld-scripts/assert.exp
> index c0d9e84..1ea0b02 100644
> --- a/ld/testsuite/ld-scripts/assert.exp
> +++ b/ld/testsuite/ld-scripts/assert.exp
> @@ -26,7 +26,7 @@ if ![ld_assemble $as $srcdir/$subdir/assert.s tmpdir/assert.o] {
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/assert "-T $srcdir/$subdir/assert.t tmpdir/assert.o"] {
> +if ![ld_link $ld tmpdir/assert "-T $srcdir/$subdir/assert.t tmpdir/assert.o"] {
>      fail $testname
>  } else {
>      pass $testname
> diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
> index 79c4e45..215e7b6 100644
> --- a/ld/testsuite/ld-scripts/defined.exp
> +++ b/ld/testsuite/ld-scripts/defined.exp
> @@ -33,7 +33,7 @@ if [istarget "x86_64-*-mingw*"] then {
>    set LDFLAGS "$LDFLAGS --image-base 0"
>  }
>
> -if ![ld_simple_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] {
> +if ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] {
>      fail $testname
>  } else {
>      if ![ld_nm $nm "" tmpdir/def] {
> diff --git a/ld/testsuite/ld-scripts/extern.exp b/ld/testsuite/ld-scripts/extern.exp
> index f6048c4..b8d2b2d 100644
> --- a/ld/testsuite/ld-scripts/extern.exp
> +++ b/ld/testsuite/ld-scripts/extern.exp
> @@ -26,7 +26,7 @@ if ![ld_assemble $as $srcdir/$subdir/extern.s tmpdir/extern.o] {
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] {
> +if ![ld_link $ld tmpdir/extern "-T $srcdir/$subdir/extern.t tmpdir/extern.o"] {
>      fail $testname
>  }
>
> diff --git a/ld/testsuite/ld-scripts/log2.exp b/ld/testsuite/ld-scripts/log2.exp
> index 9654a4d..48b2688 100644
> --- a/ld/testsuite/ld-scripts/log2.exp
> +++ b/ld/testsuite/ld-scripts/log2.exp
> @@ -26,7 +26,7 @@ if {![ld_assemble $as $srcdir/$subdir/log2.s tmpdir/log2.o]} {
>         return
>  }
>
> -if {![ld_simple_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} {
> +if {![ld_link $ld tmpdir/log2 "-T $srcdir/$subdir/log2.t tmpdir/log2.o"]} {
>         fail $testname
>  } else {
>         pass $testname
> diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp
> index 72df317..7a5cccb 100644
> --- a/ld/testsuite/ld-scripts/map-address.exp
> +++ b/ld/testsuite/ld-scripts/map-address.exp
> @@ -26,7 +26,7 @@ if {![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/map-address.o]} {
>      return
>  }
>
> -if {![ld_simple_link $ld tmpdir/map-address \
> +if {![ld_link $ld tmpdir/map-address \
>          "-T $srcdir/$subdir/map-address.t \
>           tmpdir/map-address.o \
>           -Map tmpdir/map-address.map"]} {
> diff --git a/ld/testsuite/ld-scripts/phdrs.exp b/ld/testsuite/ld-scripts/phdrs.exp
> index 4c268bc..5d9f6d4 100644
> --- a/ld/testsuite/ld-scripts/phdrs.exp
> +++ b/ld/testsuite/ld-scripts/phdrs.exp
> @@ -48,7 +48,7 @@ if [is_elf64 tmpdir/phdrs.o] {
>  }
>
>  set ldopt "$ldopt -T $srcdir/$subdir/phdrs.t tmpdir/phdrs.o"
> -if ![ld_simple_link $ld tmpdir/phdrs $ldopt] {
> +if ![ld_link $ld tmpdir/phdrs $ldopt] {
>      fail $testname
>  } else {
>      if {![is_remote host] && [which $objdump] == 0} {
> diff --git a/ld/testsuite/ld-scripts/phdrs2.exp b/ld/testsuite/ld-scripts/phdrs2.exp
> index 5ab8b89..625b07a 100644
> --- a/ld/testsuite/ld-scripts/phdrs2.exp
> +++ b/ld/testsuite/ld-scripts/phdrs2.exp
> @@ -55,7 +55,7 @@ set phdrs_regexp \
>      ".*Program Header:.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]*.*LOAD *off *0x00\[0-9a-f\]* *vaddr *0x00*800004 *paddr *0x00*800004.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags rw.*"
>
>  set ldopt "$ldopt -T $srcdir/$subdir/phdrs2.t tmpdir/phdrs2.o"
> -if ![ld_simple_link $ld tmpdir/phdrs2 $ldopt] {
> +if ![ld_link $ld tmpdir/phdrs2 $ldopt] {
>      fail $testname
>  } else {
>      if {![is_remote host] && [which $objdump] == 0} {
> diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp
> index 7a04480..bb2c7b6 100644
> --- a/ld/testsuite/ld-scripts/script.exp
> +++ b/ld/testsuite/ld-scripts/script.exp
> @@ -192,7 +192,7 @@ if {[istarget "*-*-pe*"] \
>    set flags "--image-base 0"
>  }
>
> -if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
> +if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
>      fail $testname
>  } else {
>      check_script
> @@ -200,7 +200,7 @@ if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir
>
>  set testname "MRI script"
>
> -if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
> +if ![ld_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
>      fail $testname
>  } else {
>      check_script
> @@ -208,14 +208,14 @@ if ![ld_simple_link $ld tmpdir/script "$flags -c $srcdir/$subdir/scriptm.t"] {
>
>  set testname "MEMORY"
>
> -if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
> +if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir/script.o"] {
>      fail $testname
>  } else {
>      check_script
>  }
>
>  set testname "MEMORY with symbols"
> -if ![ld_simple_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
> +if ![ld_link $ld tmpdir/script "$flags -defsym DATA_ORIGIN=0x1000 -defsym DATA_LENGTH=0x10000 -T $srcdir/$subdir/memory_sym.t tmpdir/script.o"] {
>      fail $testname
>      untested "extract symbols"
>  } else {
> diff --git a/ld/testsuite/ld-scripts/section-flags.exp b/ld/testsuite/ld-scripts/section-flags.exp
> index 417db4a..550ae79 100644
> --- a/ld/testsuite/ld-scripts/section-flags.exp
> +++ b/ld/testsuite/ld-scripts/section-flags.exp
> @@ -33,7 +33,7 @@ foreach test {"section-flags-1" "section-flags-2"} {
>      if ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o] {
>         unresolved $test
>      } else {
> -       if ![ld_simple_link $ldcmd tmpdir/$test \
> +       if ![ld_link $ldcmd tmpdir/$test \
>                 "-T $srcdir/$subdir/$test.t tmpdir/$test.o"] {
>             fail $test
>         } else {
> diff --git a/ld/testsuite/ld-scripts/sizeof.exp b/ld/testsuite/ld-scripts/sizeof.exp
> index f9dc9ee..5324ea4 100644
> --- a/ld/testsuite/ld-scripts/sizeof.exp
> +++ b/ld/testsuite/ld-scripts/sizeof.exp
> @@ -27,7 +27,7 @@ if ![ld_assemble $as $srcdir/$subdir/sizeof.s tmpdir/sizeof.o] {
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] {
> +if ![ld_link $ld tmpdir/sizeof "-T $srcdir/$subdir/sizeof.t tmpdir/sizeof.o"] {
>      fail $testname
>      return
>  }
> diff --git a/ld/testsuite/ld-scripts/sysroot-prefix.exp b/ld/testsuite/ld-scripts/sysroot-prefix.exp
> index 2f41bd4..2bb67e4 100644
> --- a/ld/testsuite/ld-scripts/sysroot-prefix.exp
> +++ b/ld/testsuite/ld-scripts/sysroot-prefix.exp
> @@ -141,7 +141,7 @@ proc single_sysroot_prefix_test { type xtestname finalscript ldopt errstr } {
>      close $ofd
>      verbose -log "script: $finalscript"
>
> -    set res [ld_simple_link $ld tmpdir/output "$ldopt tmpdir/main.o -Ltmpdir -lsysroottest"]
> +    set res [ld_link $ld tmpdir/output "$ldopt tmpdir/main.o -Ltmpdir -lsysroottest"]
>      set ld_output "$exec_output"
>      set expect_success [expr [string length $errstr] == 0]
>
> diff --git a/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp
> index 04b19aa..1affef6 100644
> --- a/ld/testsuite/ld-scripts/weak.exp
> +++ b/ld/testsuite/ld-scripts/weak.exp
> @@ -55,7 +55,7 @@ set weak_regexp_big \
>  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 "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
> +if {! [ld_link $ld tmpdir/weak "$flags -T $srcdir/$subdir/weak.t tmpdir/weak1.o tmpdir/weak2.o"] } then {
>      fail $testname
>  } else {
>      if {![is_remote host] && [which $objdump] == 0} then {
> diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
> index ac456e4..8d58c16 100644
> --- a/ld/testsuite/ld-selective/selective.exp
> +++ b/ld/testsuite/ld-selective/selective.exp
> @@ -151,7 +151,7 @@ foreach testitem $seltests {
>         set objfile "$objfile --defsym _.d2=0"
>      }
>
> -    if ![ld_simple_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
> +    if ![ld_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
>         fail $testname
>         continue
>      }
> diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp
> index ce9dad4..f87911b 100644
> --- a/ld/testsuite/ld-sh/sh.exp
> +++ b/ld/testsuite/ld-sh/sh.exp
> @@ -37,7 +37,7 @@ 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"] {
> +} else { if ![ld_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
>      fail $testsimple
>  } else {
>      if ![ld_nm $nm "" tmpdir/sh1] {
> @@ -73,7 +73,7 @@ if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
>  } else {
>      set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
>  }
> -if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
> +if ![ld_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
>      fail $testsrec
>  } else {
>      # The file name is embedded in the S-records, so create both
> @@ -114,7 +114,7 @@ set testadjsw8 "SH switch8 adjustment after relax"
>  if ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] {
>      unresolved $testadjsw8
>  } else {
> -    if ![ld_simple_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
> +    if ![ld_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
>         fail $testadjsw8
>      } else {
>         send_log "exec $objdump -s tmpdir/adjsw8\n"
> @@ -156,7 +156,7 @@ if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
>      return
>  }
>
> -if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
> +if ![ld_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
>      fail $testlink
>      unresolved $testjsr
>      unresolved $testrun
> diff --git a/ld/testsuite/ld-sh/sh64/relax.exp b/ld/testsuite/ld-sh/sh64/relax.exp
> index c862c5e..fbde450 100644
> --- a/ld/testsuite/ld-sh/sh64/relax.exp
> +++ b/ld/testsuite/ld-sh/sh64/relax.exp
> @@ -114,7 +114,7 @@ proc run_sh64relaxtest {sh64relaxtests} {
>         # disabled.  Hence the lax checking here.
>
>         file delete $binfile
> -       set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
> +       set result [ld_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
>         if ![file exists $binfile] {
>
>             if {$expect_relaxed == -1} {
> diff --git a/ld/testsuite/ld-sh/sh64/relfail.exp b/ld/testsuite/ld-sh/sh64/relfail.exp
> index fdfce76..427e8d3 100644
> --- a/ld/testsuite/ld-sh/sh64/relfail.exp
> +++ b/ld/testsuite/ld-sh/sh64/relfail.exp
> @@ -180,7 +180,7 @@ proc run_sh64relfailtests {sh64relfailtests} {
>
>         file delete $binfile
>         set objects "tmpdir/relfail-$testindex.o $baseobj"
> -       set result [ld_simple_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
> +       set result [ld_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
>
>         set exists [file exists $binfile]
>         if {$exists && $expect_fail == ""} {
> diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
> index 748a93b..93181dc 100644
> --- a/ld/testsuite/ld-shared/shared.exp
> +++ b/ld/testsuite/ld-shared/shared.exp
> @@ -25,8 +25,10 @@
>  # 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}
> +# Check to see if the C compiler works
> +if { [which $CC] == 0 } {
> +    return
> +}
>
>  # This test can only be run on a couple of ELF platforms.
>  # Square bracket expressions seem to confuse istarget.
> @@ -137,7 +139,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
>      if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
>         set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
>      }
> -    if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
> +    if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
>          fail "$testname"
>         return
>      }
> @@ -150,11 +152,16 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
>      if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
>         set rpath /lib:$tmpdir
>      }
> -    if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
> +    if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
>         fail "$testname"
>         return
>      }
>
> +    if ![isnative] {
> +       unsupported $testname
> +       return
> +    }
> +
>      # Run the resulting program
>      send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
>      verbose "$tmpdir/$progname >$tmpdir/$progname.out"
> diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp
> index 53ae96b..d4c3b8f 100644
> --- a/ld/testsuite/ld-size/size.exp
> +++ b/ld/testsuite/ld-size/size.exp
> @@ -49,12 +49,6 @@ foreach t $test_list {
>      run_dump_test [file rootname $t]
>  }
>
> -# We need a native system.
> -if ![isnative] {
> -    verbose "Native size relocation tests not run - not a native toolchain"
> -    return
> -}
> -
>  # We need a working compiler.
>  if { [which $CC] == 0 } {
>      verbose "Native size relocation tests not run - no compiler available"
> @@ -179,7 +173,7 @@ if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/size-7.out" ] } then {
>  run_ld_link_exec_tests [list \
>      [list \
>         "Run size-1" \
> -       "tmpdir/libsize-1.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-1.so" \
>         "" \
>         {size-1.c} \
>         "size-1" \
> @@ -187,7 +181,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-2" \
> -       "tmpdir/libsize-2.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-2.so" \
>         "" \
>         {size-2.c} \
>         "size-2" \
> @@ -203,7 +197,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-3b" \
> -       "tmpdir/libsize-3a.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-3a.so" \
>         "" \
>         {size-3.c} \
>         "size-3b" \
> @@ -219,7 +213,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-3d (1)" \
> -       "tmpdir/libsize-3b.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-3b.so" \
>         "" \
>         {size-3.c} \
>         "size-3d1" \
> @@ -235,7 +229,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>      {"Run size-3e"
> -     "tmpdir/libsize-3c.so" ""
> +     "-Wl,--no-as-needed tmpdir/libsize-3c.so" ""
>       {size-3.c} "size-3e" "size-3.out"}
>      ] \
>      [list \
> @@ -276,7 +270,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-6" \
> -       "tmpdir/libsize-6b.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-6b.so" \
>         "" \
>         {size-6a.c} \
>         "size-6" \
> @@ -285,7 +279,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-8" \
> -       "tmpdir/libsize-8.so --hash-styl=gnu" \
> +       "-Wl,--no-as-needed,--hash-styl=gnu tmpdir/libsize-8.so" \
>         "" \
>         {size-8a.c} \
>         "size-8" \
> @@ -294,7 +288,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-9" \
> -       "tmpdir/libsize-9.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-9.so" \
>         "" \
>         {size-9a.c} \
>         "size-9" \
> @@ -302,7 +296,7 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "Run size-10" \
> -       "tmpdir/libsize-10.so" \
> +       "-Wl,--no-as-needed tmpdir/libsize-10.so" \
>         "" \
>         {size-10a.c} \
>         "size-10" \
> diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
> index eb68d83..2720043 100644
> --- a/ld/testsuite/ld-srec/srec.exp
> +++ b/ld/testsuite/ld-srec/srec.exp
> @@ -230,7 +230,7 @@ proc run_srec_test { test objs } {
>      # Tell the ELF linker to not do anything clever with .eh_frame,
>      # not to put anything in small data, and define various symbols.
>      set flags "--traditional-format -G 0 "
> -    append flags [ld_simple_link_defsyms]
> +    append flags [ld_link_defsyms]
>
>      # 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
> @@ -305,8 +305,8 @@ proc run_srec_test { test objs } {
>         set flags "$flags -no-relax"
>      }
>
> -    if { ![ld_simple_link $ld tmpdir/sr1 "$flags $objs"] \
> -        || ![ld_simple_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
> +    if { ![ld_link $ld tmpdir/sr1 "$flags $objs"] \
> +        || ![ld_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
>         fail $test
>         return
>      }
> diff --git a/ld/testsuite/ld-tic6x/tic6x.exp b/ld/testsuite/ld-tic6x/tic6x.exp
> index 3129b02..c1b0608 100644
> --- a/ld/testsuite/ld-tic6x/tic6x.exp
> +++ b/ld/testsuite/ld-tic6x/tic6x.exp
> @@ -148,12 +148,12 @@ if { ![ld_assemble_flags $as "-mpic -mpid=near" $srcdir/$subdir/shlib-1.s tmpdir
>       || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-1.s tmpdir/shlib-1b.o]
>       || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-2.s tmpdir/shlib-2b.o]
>       || ![ld_assemble_flags $as -mbig-endian $srcdir/$subdir/shlib-app-1.s tmpdir/shlib-app-1b.o]
> -     || ![ld_simple_link $ld tmpdir/libtest.so "-shared tmpdir/shlib-1.o tmpdir/shlib-2.o"]
> -     || ![ld_simple_link $ld tmpdir/libtestb.so "-shared -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
> -     || ![ld_simple_link $ld tmpdir/shlib.o "-r tmpdir/shlib-1.o tmpdir/shlib-2.o"]
> -     || ![ld_simple_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
> -     || ![ld_simple_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"]
> -     || ![ld_simple_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } {
> +     || ![ld_link $ld tmpdir/libtest.so "-shared tmpdir/shlib-1.o tmpdir/shlib-2.o"]
> +     || ![ld_link $ld tmpdir/libtestb.so "-shared -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
> +     || ![ld_link $ld tmpdir/shlib.o "-r tmpdir/shlib-1.o tmpdir/shlib-2.o"]
> +     || ![ld_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
> +     || ![ld_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"]
> +     || ![ld_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } {
>      unresolved "TIC6X OSABI tests"
>      return
>  }
> diff --git a/ld/testsuite/ld-undefined/weak-undef.exp b/ld/testsuite/ld-undefined/weak-undef.exp
> index 9109a22..eb28c2c 100644
> --- a/ld/testsuite/ld-undefined/weak-undef.exp
> +++ b/ld/testsuite/ld-undefined/weak-undef.exp
> @@ -29,7 +29,7 @@ if { ![is_elf_format] && ![is_pecoff_format] } then {
>             tmpdir/weak-undef.o]} then {
>      # It's OK if .weak doesn't work on this target.
>      unresolved $testname
> -} elseif {![ld_simple_link $ld tmpdir/weak-undef \
> +} elseif {![ld_link $ld tmpdir/weak-undef \
>                 "tmpdir/weak-undef.o -T $srcdir/$subdir/weak-undef.t"]} then {
>      # Weak symbols are broken for non-i386 PE targets.
>      if {! [istarget i?86-*-*]} {
> @@ -71,7 +71,7 @@ if { $asflags == "" || ![is_elf_format] || ![check_shared_lib_support]} then {
>  } elseif {![ld_assemble $as "$asflags $srcdir/$subdir/weak-fundef.s" \
>                 tmpdir/weak-fundef.o]} then {
>      fail $testname
> -} elseif {![ld_simple_link $ld tmpdir/weak-fundef.so \
> +} elseif {![ld_link $ld tmpdir/weak-fundef.so \
>             "--shared tmpdir/weak-fundef.o"]} then {
>      fail $testname
>  } elseif {![is_remote host] && [which $nm] == 0} then {
> @@ -92,7 +92,7 @@ if { $asflags == "" || ![is_elf_format] || ![check_shared_lib_support]} then {
>      # When linking a dynamic executable, weak undefined symbols become dynamic.
>      set testname "weak undefined function symbols in dynamic exe"
>
> -    if {![ld_simple_link $ld tmpdir/weak-fundef \
> +    if {![ld_link $ld tmpdir/weak-fundef \
>           "--no-as-needed tmpdir/weak-fundef.o tmpdir/weak-fundef.so"]} then {
>         fail $testname
>      } else {
> diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
> index 3a4ce22..668ac95 100644
> --- a/ld/testsuite/ld-unique/unique.exp
> +++ b/ld/testsuite/ld-unique/unique.exp
> @@ -37,15 +37,6 @@ if { ![supports_gnu_unique] } {
>
>  run_dump_test "unique"
>
> -# We need a native system.  FIXME: Strictly speaking this
> -# is not true, we just need to know how to create a fully
> -# linked executable, including the C and Z libraries, using
> -# the linker that is under test.
> -if ![isnative] {
> -    verbose "UNIQUE compiled tests not run - not a native toolchain"
> -    return
> -}
> -
>  # We need a working compiler.  (Strictly speaking this is
>  # not true, we could use target specific assembler files).
>  if { [which $CC] == 0 } {
> @@ -124,25 +115,25 @@ if ![ld_compile "$CC -c -fPIC" "$srcdir/$subdir/unique_shared.s" "tmpdir/unique_
>  }
>
>  # Create executable containing unique symbol.
> -if ![default_ld_link $ld "tmpdir/unique_prog" "tmpdir/unique.o"] {
> +if ![ld_link $CC "tmpdir/unique_prog" "tmpdir/unique.o"] {
>      fail "Could not link a unique executable"
>      set fails [expr $fails + 1]
>  }
>
>  # Create shared library containing unique symbol.
> -if ![ld_simple_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"] {
> +if ![ld_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"] {
>      fail "Could not create a shared library containing an unique symbol"
>      set fails [expr $fails + 1]
>  }
>
>  # Create executable NOT containing unique symbol linked against library.
> -if ![default_ld_link $ld "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Bdynamic -lunique_shared -rpath ./tmpdir"] {
> +if ![ld_link $CC "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] {
>      fail "Could not link a dynamic executable"
>      set fails [expr $fails + 1]
>  }
>
>  # Create shared library containing unique symbol with reference.
> -if ![ld_simple_link $ld "tmpdir/libunique_shared_ref.so" "-shared tmpdir/unique_shared.o tmpdir/unique_empty.o"] {
> +if ![ld_link $ld "tmpdir/libunique_shared_ref.so" "-shared tmpdir/unique_shared.o tmpdir/unique_empty.o"] {
>      fail "Could not create a shared library containing an unique symbol with reference"
>      set fails [expr $fails + 1]
>  }
> @@ -182,8 +173,12 @@ if { $fails == 0 } {
>  }
>
>  # Check the empty object file.
> -if {! [check_osabi tmpdir/unique_empty.o {UNIX - System V}]} {
> -    fail "Object NOT containing unique does not have an OS/ABI field of System V"
> +case $target_triplet in {
> +    { hppa*-*-linux* } { set expected_none {UNIX - GNU} }
> +    default { set expected_none {UNIX - System V} }
> +}
> +if {! [check_osabi tmpdir/unique_empty.o $expected_none]} {
> +    fail "Object NOT containing unique does not have an OS/ABI field of $expected_none"
>      set fails [expr $fails + 1]
>  }
>
> @@ -238,8 +233,8 @@ if { $fails == 0 } {
>  }
>
>  # Check the empty executable linked against unique shared library.
> -if {! [check_osabi tmpdir/unique_shared_prog {UNIX - System V}]} {
> -    fail "Executable NOT containing unique does not have an OS/ABI field of System V"
> +if {! [check_osabi tmpdir/unique_shared_prog $expected_none]} {
> +    fail "Executable NOT containing unique does not have an OS/ABI field of $expected_none"
>      set fails [expr $fails + 1]
>  }
>
> @@ -251,14 +246,3 @@ if {[contains_unique_symbol tmpdir/unique_shared_prog] == 1} {
>  if { $fails == 0 } {
>    pass "Checking shared empty executable"
>  }
> -
> -# Clean up, unless we are being verbose, in which case we leave the files available.
> -if { $verbose < 1 } {
> -    remote_file host delete "tmpdir/unique_empty.o"
> -    remote_file host delete "tmpdir/unique.o"
> -    remote_file host delete "tmpdir/unique_shared.o"
> -    remote_file host delete "tmpdir/libunique_shared.so"
> -    remote_file host delete "tmpdir/libunique_shared_ref.so"
> -    remote_file host delete "tmpdir/unique_prog"
> -    remote_file host delete "tmpdir/unique_shared_prog"
> -}
> diff --git a/ld/testsuite/ld-versados/versados.exp b/ld/testsuite/ld-versados/versados.exp
> index 9584b0c..55612e3 100644
> --- a/ld/testsuite/ld-versados/versados.exp
> +++ b/ld/testsuite/ld-versados/versados.exp
> @@ -75,7 +75,7 @@ proc inspect { whichone } {
>      return 1
>  }
>
> -if ![ld_simple_link $ld tmpdir/t1.out \
> +if ![ld_link $ld tmpdir/t1.out \
>         " -T $srcdir/$subdir/t1.ld $srcdir/$subdir/t1-1.ro  $srcdir/$subdir/t1-2.ro"] {
>      fail $testname
>      return
> @@ -87,7 +87,7 @@ if ![ld_simple_link $ld tmpdir/t1.out \
>  }
>
>
> -if ![ld_simple_link $ld  tmpdir/t2.out \
> +if ![ld_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
> diff --git a/ld/testsuite/ld-x86-64/dwarfreloc.exp b/ld/testsuite/ld-x86-64/dwarfreloc.exp
> index c96ffd0..7e2486b 100644
> --- a/ld/testsuite/ld-x86-64/dwarfreloc.exp
> +++ b/ld/testsuite/ld-x86-64/dwarfreloc.exp
> @@ -58,14 +58,14 @@ set build_tests_ld {
>  run_ld_link_tests $build_tests_ld
>
>  set testname "Link dwarfreloc1xa.o and dwarfreloc2xa.o to dwarfreloca.o"
> -if [ld_simple_link $ld "tmpdir/dwarfreloca.o" "-r tmpdir/dwarfreloc1xa.o tmpdir/dwarfreloc2xa.o"] {
> +if [ld_link $ld "tmpdir/dwarfreloca.o" "-r tmpdir/dwarfreloc1xa.o tmpdir/dwarfreloc2xa.o"] {
>      pass $testname
>  } else {
>      fail $testname
>  }
>
>  set testname "Link dwarfreloc1xb.o and dwarfreloc2xb.o to dwarfrelocb.o"
> -if [ld_simple_link $ld "tmpdir/dwarfrelocb.o" "-r tmpdir/dwarfreloc1xb.o tmpdir/dwarfreloc2xb.o"] {
> +if [ld_link $ld "tmpdir/dwarfrelocb.o" "-r tmpdir/dwarfreloc1xb.o tmpdir/dwarfreloc2xb.o"] {
>      pass $testname
>  } else {
>      fail $testname
> diff --git a/ld/testsuite/ld-x86-64/tls.exp b/ld/testsuite/ld-x86-64/tls.exp
> index 2eddc31..7061320 100644
> --- a/ld/testsuite/ld-x86-64/tls.exp
> +++ b/ld/testsuite/ld-x86-64/tls.exp
> @@ -97,8 +97,8 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "TLS GD/LD -> IE transition without PLT" \
> -       "tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
> -        tmpdir/libtls-1a.so -R tmpdir" \
> +       "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
> +        tmpdir/tls-gd1.o tmpdir/tls-ld1.o tmpdir/libtls-1a.so" \
>         "" \
>         { dummy.s } \
>         "tls-1d" \
> @@ -106,8 +106,8 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "TLS without PLT (1)" \
> -       "tmpdir/tls-main1.o \
> -        tmpdir/libtls-1a.so tmpdir/libtls-1b.so -R tmpdir" \
> +       "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
> +        tmpdir/libtls-1a.so tmpdir/libtls-1b.so" \
>         "" \
>         { dummy.s } \
>         "tls-1e" \
> @@ -115,8 +115,8 @@ run_ld_link_exec_tests [list \
>      ] \
>      [list \
>         "TLS without PLT (2)" \
> -       "tmpdir/tls-main1.o tmpdir/tls-def1.o \
> -        tmpdir/libtls-1b.so -R tmpdir" \
> +       "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
> +        tmpdir/tls-def1.o tmpdir/libtls-1b.so" \
>         "" \
>         { dummy.s } \
>         "tls-1f" \
> diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
> index ac63a1d..26d739e 100644
> --- a/ld/testsuite/ld-x86-64/x86-64.exp
> +++ b/ld/testsuite/ld-x86-64/x86-64.exp
> @@ -247,7 +247,7 @@ global ld
>
>  set test_name "Mixed x86_64 and i386 input test 1"
>  set test mixed1
> -if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
> +if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
>      if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
>         pass "$test_name"
>      } {
> @@ -257,7 +257,7 @@ if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}
>
>  set test_name "Mixed x86_64 and i386 input test 2"
>  set test mixed2
> -if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
> +if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
>      if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
>         pass "$test_name"
>      } {
> @@ -538,7 +538,7 @@ proc undefined_weak {cflags ldflags} {
>      }
>
>      if { [ regexp "\-fPIE" $cflags]
> -        && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } {
> +        && ![ regexp "nodynamic-undefined-weak" $ldflags] } {
>         set weak_symbol "Weak defined"
>      } else {
>         set weak_symbol "Weak undefined"
> @@ -568,7 +568,7 @@ proc undefined_weak {cflags ldflags} {
>      run_ld_link_exec_tests [list \
>         [list \
>             "Run pr19704" \
> -           "$ldflags tmpdir/libpr19704.so -R tmpdir" \
> +           "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
>             "" \
>             { pr19704a.c } \
>             "pr19704" \
> @@ -833,8 +833,8 @@ if { [isnative] && [which $CC] != 0 } {
>      run_ld_link_exec_tests [list \
>         [list \
>             "Run plt-main" \
> -           "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
> -            tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
> +           "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
> +            tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
>             "" \
>             { plt-main5.c } \
>             "plt-main" \
> @@ -842,8 +842,8 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run plt-main with PIE" \
> -           "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
> -            tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
> +           "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
> +            tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
>             "" \
>             { plt-main5.c } \
>             "plt-main-pie" \
> @@ -852,7 +852,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run copyreloc-main with PIE without -fPIE" \
> -           "--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
> +           "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
>             "" \
>             { dummy.s } \
>             "copyreloc-main" \
> @@ -860,7 +860,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run pr17689 with PIE without -fPIE" \
> -           "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
> +           "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
>             "" \
>             { dummy.s } \
>             "pr17689" \
> @@ -868,7 +868,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run pr17689 with PIE -z now without -fPIE" \
> -           "--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
> +           "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
>             "" \
>             { dummy.s } \
>             "pr17689now" \
> @@ -876,7 +876,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run pr18900" \
> -           "tmpdir/pr18900.o tmpdir/pr18900.so" \
> +           "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
>             "" \
>             { dummy.s } \
>             "pr18900" \
> @@ -884,7 +884,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run pr19031" \
> -           "tmpdir/pr19031.so" \
> +           "-Wl,--no-as-needed tmpdir/pr19031.so" \
>             "" \
>             { pr19031b.S pr19031c.c } \
>             "pr19031" \
> @@ -892,7 +892,7 @@ if { [isnative] && [which $CC] != 0 } {
>         ] \
>         [list \
>             "Run gotpcrel1" \
> -           "tmpdir/gotpcrel1d.so" \
> +           "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
>             "" \
>             { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
>             "gotpcrel1" \
> @@ -930,7 +930,7 @@ if { [isnative] && [which $CC] != 0 } {
>         run_ld_link_exec_tests [list \
>             [list \
>                 "Run pr19784a" \
> -               "tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
> +               "-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
>                 "" \
>                 { dummy.s } \
>                 "pr19784a" \
> @@ -938,7 +938,7 @@ if { [isnative] && [which $CC] != 0 } {
>             ] \
>             [list \
>                 "Run pr19784b" \
> -               "--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
> +               "-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
>                 "" \
>                 { dummy.s } \
>                 "pr19784b" \
> @@ -974,8 +974,9 @@ if { [isnative] && [which $CC] != 0 } {
>         run_ld_link_exec_tests [list \
>             [list \
>                 "Run plt-main with -z bndplt" \
> -               "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
> -                tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt" \
> +               "-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
> +                tmpdir/plt-main2.o tmpdir/plt-main3.o \
> +                tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
>                 "" \
>                 { plt-main5.c } \
>                 "plt-main-bnd" \
> @@ -983,8 +984,9 @@ if { [isnative] && [which $CC] != 0 } {
>             ] \
>             [list \
>                 "Run plt-main with PIE and -z bndplt" \
> -               "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
> -                tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie" \
> +               "-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
> +                tmpdir/plt-main2.o tmpdir/plt-main3.o \
> +                tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
>                 "" \
>                 { plt-main5.c } \
>                 "plt-main-pie-bnd" \
> @@ -993,7 +995,7 @@ if { [isnative] && [which $CC] != 0 } {
>             ] \
>             [list \
>                 "Run pr20800" \
> -               "-pie -z now" \
> +               "-Wl,-z,now -pie" \
>                 "" \
>                 { pr20800a.S pr20800b.S } \
>                 "pr20800" \
> @@ -1005,8 +1007,8 @@ if { [isnative] && [which $CC] != 0 } {
>      undefined_weak "" ""
>      undefined_weak "-fPIE" ""
>      undefined_weak "-fPIE" "-pie"
> -    undefined_weak "-fPIE" "-z nodynamic-undefined-weak"
> -    undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
> +    undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
> +    undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
>  }
>
>  if { ![istarget "x86_64-*-linux*"]} {
> diff --git a/ld/testsuite/ld-xtensa/coalesce.exp b/ld/testsuite/ld-xtensa/coalesce.exp
> index 425f865..a61624c 100644
> --- a/ld/testsuite/ld-xtensa/coalesce.exp
> +++ b/ld/testsuite/ld-xtensa/coalesce.exp
> @@ -69,7 +69,7 @@ if ![ld_assemble $as $srcdir/$subdir/coalesce2.s tmpdir/coalesce2.o] {
>  set object "tmpdir/coalesce"
>  set outputfile "$object.txt"
>
> -if ![ld_simple_link $ld $object "-T $srcdir/$subdir/coalesce.t tmpdir/coalesce1.o tmpdir/coalesce2.o"] {
> +if ![ld_link $ld $object "-T $srcdir/$subdir/coalesce.t tmpdir/coalesce1.o tmpdir/coalesce2.o"] {
>      verbose -log "failure in ld"
>      fail $testname
>      return
> diff --git a/ld/testsuite/ld-xtensa/diff_overflow.exp b/ld/testsuite/ld-xtensa/diff_overflow.exp
> index 3d857d4..c130ce7 100644
> --- a/ld/testsuite/ld-xtensa/diff_overflow.exp
> +++ b/ld/testsuite/ld-xtensa/diff_overflow.exp
> @@ -36,7 +36,7 @@ if ![ld_assemble $as "--text-section-literals $srcdir/$subdir/diff_overflow2.s"
>
>  set object "tmpdir/diff_overflow"
>
> -if ![ld_simple_link $ld $object "tmpdir/diff_overflow1.o tmpdir/diff_overflow2.o"] {
> +if ![ld_link $ld $object "tmpdir/diff_overflow1.o tmpdir/diff_overflow2.o"] {
>      verbose -log "failure in ld"
>      fail $testname
>      return
> diff --git a/ld/testsuite/ld-xtensa/lcall.exp b/ld/testsuite/ld-xtensa/lcall.exp
> index 209079f..895406e 100644
> --- a/ld/testsuite/ld-xtensa/lcall.exp
> +++ b/ld/testsuite/ld-xtensa/lcall.exp
> @@ -69,7 +69,7 @@ if ![ld_assemble $as $srcdir/$subdir/lcall2.s tmpdir/lcall2.o] {
>  set object "tmpdir/lcall"
>  set outputfile "$object.txt"
>
> -if ![ld_simple_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] {
> +if ![ld_link $ld $object "-T $srcdir/$subdir/lcall.t tmpdir/lcall1.o tmpdir/lcall2.o"] {
>      verbose -log "failure in ld"
>      fail $testname
>      return
> diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
> index d3bda4d..f8d5ec6 100644
> --- a/ld/testsuite/lib/ld-lib.exp
> +++ b/ld/testsuite/lib/ld-lib.exp
> @@ -199,41 +199,9 @@ proc big_or_little_endian {} {
>      return $flags
>  }
>
> -# Link a program using ld.
> +# Link a program using ld
>  #
>  proc default_ld_link { ld target objects } {
> -    global HOSTING_EMU
> -    global HOSTING_CRT0
> -    global HOSTING_SCRT0
> -    global HOSTING_LIBS
> -    global HOSTING_SLIBS
> -    global LIBS
> -    global host_triplet
> -    global link_output
> -    global exec_output
> -
> -    if { [ string match "* -pie *" $objects ] } {
> -       set objs "$HOSTING_SCRT0 $objects"
> -       set libs "$LIBS $HOSTING_SLIBS"
> -    } else {
> -       set objs "$HOSTING_CRT0 $objects"
> -       set libs "$LIBS $HOSTING_LIBS"
> -    }
> -
> -    if [is_endian_output_format $objects] then {
> -       set flags [big_or_little_endian]
> -    } else {
> -       set flags ""
> -    }
> -
> -    remote_file host delete $target
> -
> -    return [run_host_cmd_yesno "$ld" "$HOSTING_EMU $flags -o $target $objs $libs"]
> -}
> -
> -# Link a program using ld, without including any libraries.
> -#
> -proc default_ld_simple_link { ld target objects } {
>      global host_triplet
>      global exec_output
>
> @@ -409,7 +377,7 @@ proc default_ld_nm { nm nmflags object } {
>
>  # Define various symbols needed when not linking against all
>  # target libs.
> -proc ld_simple_link_defsyms {} {
> +proc ld_link_defsyms {} {
>
>      set flags "--defsym __stack_chk_fail=0"
>
> @@ -1269,7 +1237,7 @@ proc run_ld_link_tests { ldtests args } {
>             if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } {
>                 set failed 1
>             }
> -       } elseif { ![ld_simple_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
> +       } elseif { ![ld_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
>             set maybe_failed 1
>             set ld_output "$exec_output"
>         }
> @@ -1452,20 +1420,12 @@ proc run_ld_link_exec_tests { ldtests args } {
>             }
>         }
>
> -       # We have to use $CC to build PIE and shared library.
> -       if { [ string match "c" $lang ] } {
> -           set link_proc ld_simple_link
> -           set link_cmd $CC
> -       } elseif { [ string match "c++" $lang ] } {
> -           set link_proc ld_simple_link
> +       if { [ string match "c++" $lang ] } {
> +           set link_proc ld_link
>             set link_cmd $CXX
> -       } elseif { [ string match "-shared" $ld_options ] \
> -                  || [ string match "-pie" $ld_options ] } {
> -           set link_proc ld_simple_link
> -           set link_cmd $CC
>         } else {
>             set link_proc ld_link
> -           set link_cmd $ld
> +           set link_cmd $CC
>         }
>
>         if { $binfile eq "tmpdir/" } {
> @@ -1486,7 +1446,7 @@ proc run_ld_link_exec_tests { ldtests args } {
>             }
>         }
>
> -       if { $failed == 0 } {
> +       if { $failed == 0 && [isnative] } {
>             send_log "Running: $binfile > $binfile.out\n"
>             verbose "Running: $binfile > $binfile.out"
>             catch "exec $binfile > $binfile.out" exec_output
> @@ -1511,6 +1471,8 @@ proc run_ld_link_exec_tests { ldtests args } {
>
>         if { $failed != 0 } {
>             fail $testname
> +       } elseif ![isnative] {
> +           unsupported $testname
>         } else {
>             set errcnt 0
>             pass $testname
> @@ -1609,7 +1571,7 @@ proc run_cc_link_tests { ldtests } {
>                 set failed 1
>             }
>         } else {
> -           if { ![ld_simple_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
> +           if { ![ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
>                 set failed 1
>             }
>
>
> --
> Alan Modra
> Australia Development Lab, IBM


Since you committed this patch, I've noticed errors on AArch4 and ARM
(but that's probably true on other targets as well):

Running /XXX/ld/testsuite/ld-elf/elf.exp ...
ERROR: arm-linux-gnueabi-cc does not exist

So it looks like these tests require a C compiler, rather than being
executed natively?

Christophe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-02 16:05 ` Christophe Lyon
@ 2017-01-03  0:29   ` Alan Modra
  2017-01-03  2:36     ` Alan Modra
  2017-01-11 19:22     ` Maciej W. Rozycki
  0 siblings, 2 replies; 22+ messages in thread
From: Alan Modra @ 2017-01-03  0:29 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: binutils

On Mon, Jan 02, 2017 at 05:04:54PM +0100, Christophe Lyon wrote:
> Running /XXX/ld/testsuite/ld-elf/elf.exp ...
> ERROR: arm-linux-gnueabi-cc does not exist
> 
> So it looks like these tests require a C compiler, rather than being
> executed natively?

Yes.  Removing the [isnative] check requires that we test for a C
compiler.  I'm looking into the other testsuite fails, which didn't
show up with an older compiler..

	* testsuite/ld-elf/elf.exp: Check that $CC exists before C tests.
	* testsuite/ld-pie/pie.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.

diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index a5244e4..9a26a7c 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -221,6 +221,11 @@ if { [istarget *-*-*linux*]
 
 set LDFLAGS $old_ldflags
 
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
+
 if [check_gc_sections_available] {
     run_cc_link_tests {
 	{"PR ld/13195" "-Wl,--gc-sections" ""
diff --git a/ld/testsuite/ld-pie/pie.exp b/ld/testsuite/ld-pie/pie.exp
index e9d1162..44d9f09 100644
--- a/ld/testsuite/ld-pie/pie.exp
+++ b/ld/testsuite/ld-pie/pie.exp
@@ -25,6 +25,11 @@ if { ![istarget *-*-linux*]
     return
 }
 
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
+
 # Check if -pie is supported or not.
 send_log "$CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie"
 catch "exec $CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index bfc1b1cfd..b13c540 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -18,6 +18,11 @@
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
+# Check to see if the C compiler works
+if { [which $CC] == 0 } {
+    return
+}
+
 # These tests require plugin and LTO.
 if { ![check_plugin_api_available]
      || ![check_lto_available] } {

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-03  0:29   ` Alan Modra
@ 2017-01-03  2:36     ` Alan Modra
  2017-01-11 19:22     ` Maciej W. Rozycki
  1 sibling, 0 replies; 22+ messages in thread
From: Alan Modra @ 2017-01-03  2:36 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: binutils

On Tue, Jan 03, 2017 at 10:59:42AM +1030, Alan Modra wrote:
> compiler.  I'm looking into the other testsuite fails, which didn't
> show up with an older compiler..

So it wasn't the older compiler, but that I was configuring with a
sysroot.  The following should fix the regressions for most targets.
Some targets of course do show up more fails now when cross building
simply because we're running more tests.

Needed for cross-builds without --sysroot, where USE_LIBPATH isn't
set.  See elf32.em after_open.  Perhap ld ought to look at -rpath in
this case?

	* testsuite/ld-elf/shared.exp: Add -rpath-link and -no-as-needed
	to various tests.
	* testsuite/ld-elfweak/elfweak.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp (vers19): Fix -rpath-link option.

diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 52baadd..aac3acc 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -190,16 +190,16 @@ set build_tests {
    "-r -nostdlib" "-fPIC"
    {needed1c.c} {} "libneeded1pic.o"}
   {"Build needed1a.so with --add-needed"
-   "-shared tmpdir/libneeded1pic.o -Wl,--add-needed,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
    {dummy.c} {} "needed1a.so"}
   {"Build needed1b.so with --copy-dt-needed-entries"
-   "-shared tmpdir/libneeded1pic.o -Wl,--copy-dt-needed-entries,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
    {dummy.c} {} "needed1b.so"}
   {"Build needed1a.so with --no-add-needed"
-   "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed -Ltmpdir -lneeded1a" ""
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
    {dummy.c} {} "needed1c.so"}
   {"Build needed1b.so with --no-copy-dt-needed-entries"
-   "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
    {dummy.c} {} "needed1d.so"}
   {"Build librel.so"
    "-shared" "-fPIC"
@@ -247,7 +247,7 @@ set build_tests {
    "" "-fPIC"
    {pr16496b.c} {} "libpr16496b.a"}
   {"Build libpr16496b.so"
-   "-shared tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
+   "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
    {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
   {"Build libpr16452a.so"
    "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
@@ -256,10 +256,10 @@ set build_tests {
    "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
    {dummy.c} {} "libpr16452b.so"}
   {"Build pr16452"
-   "tmpdir/libpr16452b.so -Wl,-rpath=tmpdir" ""
+   "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
    {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"}
   {"Build pr16457"
-   "tmpdir/libpr16452b.so -Wl,-rpath=tmpdir" ""
+   "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
    {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"}
   {"Build libpr18458a.so"
    "-shared -Wl,-z,now" "-fPIC"
@@ -412,10 +412,10 @@ set run_tests [list \
      "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
      {dummy.c} "pr14862" "pr14862.out" ] \
     [list "Link with --add-needed" \
-     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
      {dummy.c} "needed1a" "needed1.out" ] \
     [list "Link with --copy-dt-needed-entries" \
-     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir -Ltmpdir -lneeded1a" "" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
      {dummy.c} "needed1b" "needed1.out" ] \
     [list "Run relmain" \
      "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index bd35ae2..5587591 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -909,7 +909,7 @@ build_exec "vers16" vers16.c vers16 "-Wl,--no-as-needed" vers16a.so "" vers16.ds
 # Test a weak versioned symbol.
 build_vers_lib_pic "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym ""
 build_vers_lib_pic "vers18" vers18.c vers18 vers17.so vers18.map vers18.ver vers18.dsym vers18.sym
-build_exec "vers19" vers19.c vers19 "-Wl,-rpath,. -Wl,-rpath-link,--no-as-needed" vers18.so vers19.ver vers19.dsym ""
+build_exec "vers19" vers19.c vers19 "-Wl,--no-as-needed,-rpath,.,-rpath-link,." vers18.so vers19.ver vers19.dsym ""
 
 build_vers_lib_no_pic "vers20a" vers20.c vers20a "" vers20.map vers20a.ver vers20.dsym ""
 exec cp $tmpdir/vers20a.so $tmpdir/vers20b.so
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index e62291e..49b6c56 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -479,8 +479,8 @@ build_exec "ELF weak data first common" foo "main1.o bar1a.o foo1b.o" "" strongd
 build_exec "ELF weak data last common" foo "foo1b.o main1.o bar1a.o" "" strongdata "" strongcomm.sym
 build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
 build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
-build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
-build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
+build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,--no-as-needed,-rpath,.,-rpath-link,." weakdata weakdata.dsym ""
+build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,--no-as-needed,-rpath,.,-rpath-link,." weakdata weakdata.dsym ""
 
 if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o] {
     unresolved "ELF weak (size)"

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-02 13:35 Run more ld tests when not native Alan Modra
  2017-01-02 16:05 ` Christophe Lyon
@ 2017-01-03 21:16 ` Dimitar Dimitrov
  2017-01-03 23:06   ` Alan Modra
  2017-01-10 19:01 ` H.J. Lu
  2019-02-14 16:53 ` Thomas Schwinge
  3 siblings, 1 reply; 22+ messages in thread
From: Dimitar Dimitrov @ 2017-01-03 21:16 UTC (permalink / raw)
  To: binutils; +Cc: Alan Modra

> diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
> index b278ec1..aad5339 100644
> --- a/ld/testsuite/ld-elf/audit.exp
> +++ b/ld/testsuite/ld-elf/audit.exp
> @@ -25,11 +25,6 @@ if ![is_elf_format] {
>      return
>  }
> 
> -# The following tests require running the executable generated by ld.
> -if ![isnative] {
> -    return
> -}
> -
With isnative check removed, shouldn't this test be skipped for embedded 
targets? In other words:
+if ![check_shared_lib_support] {
+    return
+}

Regards,
Dimitar

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-03 21:16 ` Run more ld tests when not native Dimitar Dimitrov
@ 2017-01-03 23:06   ` Alan Modra
  0 siblings, 0 replies; 22+ messages in thread
From: Alan Modra @ 2017-01-03 23:06 UTC (permalink / raw)
  To: Dimitar Dimitrov; +Cc: binutils

On Tue, Jan 03, 2017 at 11:15:44PM +0200, Dimitar Dimitrov wrote:
> > diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
> > index b278ec1..aad5339 100644
> > --- a/ld/testsuite/ld-elf/audit.exp
> > +++ b/ld/testsuite/ld-elf/audit.exp
> > @@ -25,11 +25,6 @@ if ![is_elf_format] {
> >      return
> >  }
> > 
> > -# The following tests require running the executable generated by ld.
> > -if ![isnative] {
> > -    return
> > -}
> > -
> With isnative check removed, shouldn't this test be skipped for embedded 
> targets? In other words:
> +if ![check_shared_lib_support] {
> +    return
> +}

True.

	* testsuite/ld-elf/audit.exp: Check for shared lib support.
	* testsuite/ld-elf/compress.exp: Likewise.
	* testsuite/ld-elf/dwarf.exp: Likewise.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-elf/wrap.exp: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Check $CXX exists.

diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
index aad5339..83ee355 100644
--- a/ld/testsuite/ld-elf/audit.exp
+++ b/ld/testsuite/ld-elf/audit.exp
@@ -25,6 +25,12 @@ if ![is_elf_format] {
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
index b2b6ca1..5620f3c 100644
--- a/ld/testsuite/ld-elf/compress.exp
+++ b/ld/testsuite/ld-elf/compress.exp
@@ -25,6 +25,12 @@ if ![is_elf_format] {
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp
index 572c704..529ebcc 100644
--- a/ld/testsuite/ld-elf/dwarf.exp
+++ b/ld/testsuite/ld-elf/dwarf.exp
@@ -29,6 +29,12 @@ if ![is_elf_format] {
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index aac3acc..f38cd7b 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -25,6 +25,12 @@ if ![is_elf_format] {
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # Check to see if the C compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp
index 4bf8faa..4a166be 100644
--- a/ld/testsuite/ld-elf/wrap.exp
+++ b/ld/testsuite/ld-elf/wrap.exp
@@ -25,6 +25,12 @@ if ![is_elf_format] {
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # Check if compiler works
 if { [which $CC] == 0 } {
     return
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index d7519b5..ffff2f1 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -41,6 +41,12 @@ if {!(([istarget "i?86-*-*"]
     return
 }
 
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
 # We need a working compiler.  (Strictly speaking this is
 # not true, we could use target specific assembler files).
 if { [which $CC] == 0 } {
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index b13c540..b525acf 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -18,8 +18,8 @@
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
-# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+# Check to see if the C and C++ compilers work
+if { [which $CC] == 0 || [which $CXX] == 0 } {
     return
 }
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-02 13:35 Run more ld tests when not native Alan Modra
  2017-01-02 16:05 ` Christophe Lyon
  2017-01-03 21:16 ` Run more ld tests when not native Dimitar Dimitrov
@ 2017-01-10 19:01 ` H.J. Lu
  2017-01-10 21:50   ` Alan Modra
  2019-02-14 16:53 ` Thomas Schwinge
  3 siblings, 1 reply; 22+ messages in thread
From: H.J. Lu @ 2017-01-10 19:01 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

[-- Attachment #1: Type: text/plain, Size: 7250 bytes --]

On Mon, Jan 2, 2017 at 5:34 AM, Alan Modra <amodra@gmail.com> wrote:
> Many of the ld tests are not run for cross builds, in some cases
> because the test needs to run a newly linked executable, and in others
> simply because it was easier to write the test for native only.  Even
> when a test needs to run, it's good to compile and link to exercise
> the linker.  So that's what this patch does.  I've also rid us of
> the old ld_link procedure with all the HOSTING_CRT0 etc. setup.  It's
> much simpler to just link with $CC.
>
> This does mean that a cross build with cross-compiler installed but
> no cross C-library will give lots of failures.  If that turns out to
> be too annoying, I guess we can write a tcl procedure to detect it and
> not run all the extra tests.
>
>         * Makefile.am (bootstrap): Delete rule.
>         (ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
>         (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
>         (HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
>         * configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
>         (HOSTING_LIBS, HOSTING_SLIBS): Likewise.
>         * configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
>         * Makefile.in: Regenerate.
>         * configure: Regenerate.
>         * testsuite/config/default.exp (get_link_files): Delete.
>         (HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
>         define.
>         (ld_simple_link): Delete.
>         * testsuite/lib/ld-lib.exp (default_ld_link): Delete
>         (default_ld_simple_link): Rename to default_ld_link.
>         (ld_simple_link_defsyms): Rename to ld_link_defsyms.
>         (run_ld_link_tests): Use ld_link, not ld_simple_link.
>         (run_cc_link_tests): Likewise.
>         (run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
>         Don't run exe when not native, and return unsupported.
>         * testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
>         Link ld1 etc. using $CC.
>         * testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
>         * testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
>         * testsuite/ld-cygwin/exe-export.exp: Likewise.
>         * testsuite/ld-elf/binutils.exp: Likewise.
>         * testsuite/ld-elf/eh-group.exp: Likewise.
>         * testsuite/ld-elf/exclude.exp: Likewise.
>         * testsuite/ld-elf/frame.exp: Likewise.
>         * testsuite/ld-elf/sec-to-seg.exp: Likewise.
>         * testsuite/ld-elf/tls_common.exp: Likewise.
>         * testsuite/ld-elfcomm/elfcomm.exp: Likewise.
>         * testsuite/ld-fastcall/fastcall.exp: Likewise.
>         * testsuite/ld-gc/gc.exp: Likewise.
>         * testsuite/ld-ifunc/binutils.exp: Likewise.
>         * testsuite/ld-mep/mep.exp: Likewise.
>         * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
>         * testsuite/ld-mn10300/mn10300.exp: Likewise.
>         * testsuite/ld-nios2/nios2.exp: Likewise.
>         * testsuite/ld-pe/pe-compile.exp: Likewise.
>         * testsuite/ld-pe/pe-run.exp: Likewise.
>         * testsuite/ld-pe/pe-run2.exp: Likewise.
>         * testsuite/ld-plugin/plugin.exp: Likewise.
>         * testsuite/ld-scripts/align.exp: Likewise.
>         * testsuite/ld-scripts/alignof.exp: Likewise.
>         * testsuite/ld-scripts/assert.exp: Likewise.
>         * testsuite/ld-scripts/defined.exp: Likewise.
>         * testsuite/ld-scripts/extern.exp: Likewise.
>         * testsuite/ld-scripts/log2.exp: Likewise.
>         * testsuite/ld-scripts/map-address.exp: Likewise.
>         * testsuite/ld-scripts/phdrs.exp: Likewise.
>         * testsuite/ld-scripts/phdrs2.exp: Likewise.
>         * testsuite/ld-scripts/script.exp: Likewise.
>         * testsuite/ld-scripts/section-flags.exp: Likewise.
>         * testsuite/ld-scripts/sizeof.exp: Likewise.
>         * testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
>         * testsuite/ld-scripts/weak.exp: Likewise.
>         * testsuite/ld-selective/selective.exp: Likewise.
>         * testsuite/ld-sh/sh.exp: Likewise.
>         * testsuite/ld-sh/sh64/relax.exp: Likewise.
>         * testsuite/ld-sh/sh64/relfail.exp: Likewise.
>         * testsuite/ld-srec/srec.exp: Likewise.
>         * testsuite/ld-tic6x/tic6x.exp: Likewise.
>         * testsuite/ld-undefined/weak-undef.exp: Likewise.
>         * testsuite/ld-versados/versados.exp: Likewise.
>         * testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
>         * testsuite/ld-xtensa/coalesce.exp: Likewise.
>         * testsuite/ld-xtensa/diff_overflow.exp: Likewise.
>         * testsuite/ld-xtensa/lcall.exp: Likewise.
>         * testsuite/ld-elf/audit.exp: Run non-native too.
>         * testsuite/ld-elf/compress.exp: Likewise.  Replace ld options with
>         gcc -Wl, options.
>         * testsuite/ld-elf/dwarf.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Add -Wl,--no-as-needed to some tests.
>         * testsuite/ld-elf/elf.exp: Run non-native too.  Formatting.
>         * testsuite/ld-elf/indirect.exp: Run non-native too.  Add
>         -Wl,--no-as-needed to most tests.
>         * testsuite/ld-elf/shared.exp: Run non-native too.  Use braces
>         to simplify quoting.  Set run_tests using [list] rather than
>         brace assignment to expand $extralibs.  Add -Wl,--no-as-needed
>         to many test.  Prefix ld options with -Wl,.
>         (mix_pic_and_non_pic): Don't run exe if not native.
>         * testsuite/ld-elf/wrap.exp: Run non-native too.  Add
>         -Wl,--no-as-needed and prefix ld options with -Wl,.
>         * testsuite/ld-elfvers/vers.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.
>         * testsuite/ld-elfvsb/elfvsb.exp: Likewise.
>         (visibility_test): Don't run exe if not native.
>         * testsuite/ld-elfweak/elfweak.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.
>         (build_exec): Don't run exe if not native.
>         * testsuite/ld-ifunc/ifunc.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
>         to some tests and prefix ld options with -Wl,.  Expect GNU
>         for hppa-linux even when no ifuncs.  Delete cleanup.
>         * testsuite/ld-pie/pie.exp: Run non-native too.
>         * testsuite/ld-plugin/lto.exp: Likewise.
>         * testsuite/ld-shared/shared.exp: Likewise.  Use ld_link,
>         not ld_simple_link.
>         (shared_test): Don't run exe if not native.
>         * testsuite/ld-size/size.exp: Run non-native too.  Add
>         -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
>         * testsuite/ld-unique/unique.exp: Run non-native too.  Use ld_link,
>         not ld_simple_link.  Link using $CC.  Add -Wl,--no-as-needed
>         to some tests and prefix ld options with -Wl,.  Expect GNU
>         for hppa-linux even when no unique syms.  Delete cleanup.
>         * testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
>         tests and prefix ld options with -Wl,.
>         * testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
>         Add -Wl,--no-as-needed to some tests.  Prefix ld options with -Wl,.
>

I checked in this patch to fix i386 ld tests.

H.J.

[-- Attachment #2: 0001-i386-Pass-Wl-R-tmpdir-Wl-as-needed-to-CC.patch --]
[-- Type: text/x-patch, Size: 2746 bytes --]

From e92372274e77fc0ce87f35a833de8a60d733580a Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 10 Jan 2017 10:54:39 -0800
Subject: [PATCH] i386: Pass -Wl,-R,tmpdir/-Wl --as-needed to $CC

Since linker tests were changed to use $CC, instead of $LD, we need
to pass -Wl,-R,tmpdir and -Wl,--as-needed to $CC.

	* testsuite/ld-i386/i386.exp: Pass -Wl,-R,tmpdir to GCC driver.
	* testsuite/ld-i386/tls.exp: Likewise.
---
 ld/ChangeLog                  | 6 ++++++
 ld/testsuite/ld-i386/i386.exp | 4 ++--
 ld/testsuite/ld-i386/tls.exp  | 6 +++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 72826b9..ef2c466 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* testsuite/ld-i386/i386.exp: Pass -Wl,-R,tmpdir and
+	-Wl,--as-needed to $CC.
+	* testsuite/ld-i386/tls.exp: Likewise.
+
 2017-01-10  Nick Clifton  <nickc@redhat.com>
 
 	* po/sv.po: Updated Swedish translation.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index e748e8b..973a110 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -472,7 +472,7 @@ proc undefined_weak {cflags ldflags} {
     run_ld_link_exec_tests [list \
 	[list \
 	    "Run pr19704" \
-	    "$ldflags tmpdir/libpr19704.so -R tmpdir" \
+	    "$ldflags tmpdir/libpr19704.so -Wl,-R,tmpdir" \
 	    "" \
 	    { pr19704a.c } \
 	    "pr19704" \
@@ -757,7 +757,7 @@ if { [isnative]
 	] \
 	[list \
 	    "Run copyreloc-main with PIE and GOTOFF" \
-	    "--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wl,--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
 	    "" \
 	    { dummy.s } \
 	    "copyreloc-main" \
diff --git a/ld/testsuite/ld-i386/tls.exp b/ld/testsuite/ld-i386/tls.exp
index 3cf183e..1653104 100644
--- a/ld/testsuite/ld-i386/tls.exp
+++ b/ld/testsuite/ld-i386/tls.exp
@@ -98,7 +98,7 @@ run_ld_link_exec_tests [list \
     [list \
 	"TLS GD/LD -> IE transition without PLT" \
 	"tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
-	 tmpdir/libtls-1a.so -R tmpdir" \
+	 tmpdir/libtls-1a.so -Wl,-R,tmpdir" \
 	"" \
 	{ dummy.s } \
 	"tls-1d" \
@@ -107,7 +107,7 @@ run_ld_link_exec_tests [list \
     [list \
 	"TLS without PLT (1)" \
 	"tmpdir/tls-main1.o \
-	 tmpdir/libtls-1a.so tmpdir/libtls-1b.so -R tmpdir" \
+	 tmpdir/libtls-1a.so tmpdir/libtls-1b.so -Wl,-R,tmpdir" \
 	"" \
 	{ dummy.s } \
 	"tls-1e" \
@@ -116,7 +116,7 @@ run_ld_link_exec_tests [list \
     [list \
 	"TLS without PLT (2)" \
 	"tmpdir/tls-main1.o tmpdir/tls-def1.o \
-	 tmpdir/libtls-1b.so -R tmpdir" \
+	 tmpdir/libtls-1b.so -Wl,-R,tmpdir" \
 	"" \
 	{ dummy.s } \
 	"tls-1f" \
-- 
2.7.4


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-10 19:01 ` H.J. Lu
@ 2017-01-10 21:50   ` Alan Modra
  2017-01-10 22:06     ` H.J. Lu
  0 siblings, 1 reply; 22+ messages in thread
From: Alan Modra @ 2017-01-10 21:50 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Tue, Jan 10, 2017 at 11:00:51AM -0800, H.J. Lu wrote:
> I checked in this patch to fix i386 ld tests.

Sorry, and thanks for cleaning up after me.  I didn't modify the
x86_64 and i386 tests to run when non-native, thinking there were
plenty of people running native tests.  Perhaps the i386 tests at
least should be run non-native?

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-10 21:50   ` Alan Modra
@ 2017-01-10 22:06     ` H.J. Lu
  2017-01-11  0:56       ` Alan Modra
  0 siblings, 1 reply; 22+ messages in thread
From: H.J. Lu @ 2017-01-10 22:06 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

On Tue, Jan 10, 2017 at 1:50 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jan 10, 2017 at 11:00:51AM -0800, H.J. Lu wrote:
>> I checked in this patch to fix i386 ld tests.
>
> Sorry, and thanks for cleaning up after me.  I didn't modify the
> x86_64 and i386 tests to run when non-native, thinking there were
> plenty of people running native tests.  Perhaps the i386 tests at
> least should be run non-native?
>

Some i386 tests are run-time tests.  I build and test i386 binutils on
x86-64 with

CC="/usr/gcc-6.1.1-32bit/bin/gcc -m32"
CXX="/usr/gcc-6.1.1-32bit/bin/g++ -m32"  RUNTESTFLAGS="--target_board
'unix{-m32}'" \
/export/gnu/import/git/sources/binutils-gdb/configure \


-- 
H.J.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-10 22:06     ` H.J. Lu
@ 2017-01-11  0:56       ` Alan Modra
  2017-01-11 18:40         ` H.J. Lu
  0 siblings, 1 reply; 22+ messages in thread
From: Alan Modra @ 2017-01-11  0:56 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Tue, Jan 10, 2017 at 02:06:36PM -0800, H.J. Lu wrote:
> On Tue, Jan 10, 2017 at 1:50 PM, Alan Modra <amodra@gmail.com> wrote:
> > On Tue, Jan 10, 2017 at 11:00:51AM -0800, H.J. Lu wrote:
> >> I checked in this patch to fix i386 ld tests.
> >
> > Sorry, and thanks for cleaning up after me.  I didn't modify the
> > x86_64 and i386 tests to run when non-native, thinking there were
> > plenty of people running native tests.  Perhaps the i386 tests at
> > least should be run non-native?
> >
> 
> Some i386 tests are run-time tests.  I build and test i386 binutils on
> x86-64 with

I understand.  What I was suggesting is that those run-time tests be
compiled and linked if you have $CC available, eg. i686-linux-gnu-gcc
installed on your x86_64-linux-gnu system.  run_ld_link_exec_tests now
tests isnative itself before running a test binary.

The downside of making a change like the following is that if your
system does have i686-linux-gnu-gcc available but not the
corresponding C library then you'll get more linker testsuite
failures.

diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 973a110..2c54552 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -494,9 +494,8 @@ proc undefined_weak {cflags ldflags} {
 # Add $PLT_CFLAGS if PLT is expected.
 global PLT_CFLAGS
 
-# Must be Linux native with the C compiler
-if { [isnative]
-     && [istarget "i?86-*-linux*"]
+# Must be Linux with the C compiler
+if { [istarget "i?86-*-linux*"]
      && [which $CC] != 0 } {
     run_cc_link_tests [list \
 	[list \
@@ -820,9 +819,8 @@ if { [isnative]
     undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
 }
 
-# Must be native with the C compiler and working IFUNC support,
-if { [isnative]
-     && [check_ifunc_available]
+# Must have a compiler and working IFUNC support,
+if { [check_ifunc_available]
      && [istarget "i?86-*-*"]
      && [which $CC] != 0 } {
     run_cc_link_tests [list \

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-11  0:56       ` Alan Modra
@ 2017-01-11 18:40         ` H.J. Lu
  0 siblings, 0 replies; 22+ messages in thread
From: H.J. Lu @ 2017-01-11 18:40 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

On Tue, Jan 10, 2017 at 4:56 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jan 10, 2017 at 02:06:36PM -0800, H.J. Lu wrote:
>> On Tue, Jan 10, 2017 at 1:50 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Tue, Jan 10, 2017 at 11:00:51AM -0800, H.J. Lu wrote:
>> >> I checked in this patch to fix i386 ld tests.
>> >
>> > Sorry, and thanks for cleaning up after me.  I didn't modify the
>> > x86_64 and i386 tests to run when non-native, thinking there were
>> > plenty of people running native tests.  Perhaps the i386 tests at
>> > least should be run non-native?
>> >
>>
>> Some i386 tests are run-time tests.  I build and test i386 binutils on
>> x86-64 with
>
> I understand.  What I was suggesting is that those run-time tests be
> compiled and linked if you have $CC available, eg. i686-linux-gnu-gcc
> installed on your x86_64-linux-gnu system.  run_ld_link_exec_tests now
> tests isnative itself before running a test binary.
>
> The downside of making a change like the following is that if your
> system does have i686-linux-gnu-gcc available but not the
> corresponding C library then you'll get more linker testsuite
> failures.

Sure.

> diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
> index 973a110..2c54552 100644
> --- a/ld/testsuite/ld-i386/i386.exp
> +++ b/ld/testsuite/ld-i386/i386.exp
> @@ -494,9 +494,8 @@ proc undefined_weak {cflags ldflags} {
>  # Add $PLT_CFLAGS if PLT is expected.
>  global PLT_CFLAGS
>
> -# Must be Linux native with the C compiler
> -if { [isnative]
> -     && [istarget "i?86-*-linux*"]
> +# Must be Linux with the C compiler
> +if { [istarget "i?86-*-linux*"]
>       && [which $CC] != 0 } {
>      run_cc_link_tests [list \
>         [list \
> @@ -820,9 +819,8 @@ if { [isnative]
>      undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
>  }
>
> -# Must be native with the C compiler and working IFUNC support,
> -if { [isnative]
> -     && [check_ifunc_available]
> +# Must have a compiler and working IFUNC support,
> +if { [check_ifunc_available]
>       && [istarget "i?86-*-*"]
>       && [which $CC] != 0 } {
>      run_cc_link_tests [list \
>
> --
> Alan Modra
> Australia Development Lab, IBM



-- 
H.J.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-03  0:29   ` Alan Modra
  2017-01-03  2:36     ` Alan Modra
@ 2017-01-11 19:22     ` Maciej W. Rozycki
  2017-01-20  0:33       ` Alan Modra
  1 sibling, 1 reply; 22+ messages in thread
From: Maciej W. Rozycki @ 2017-01-11 19:22 UTC (permalink / raw)
  To: Alan Modra; +Cc: Christophe Lyon, binutils

On Tue, 3 Jan 2017, Alan Modra wrote:

> diff --git a/ld/testsuite/ld-pie/pie.exp b/ld/testsuite/ld-pie/pie.exp
> index e9d1162..44d9f09 100644
> --- a/ld/testsuite/ld-pie/pie.exp
> +++ b/ld/testsuite/ld-pie/pie.exp
> @@ -25,6 +25,11 @@ if { ![istarget *-*-linux*]
>      return
>  }
>  
> +# Check to see if the C compiler works
> +if { [which $CC] == 0 } {
> +    return
> +}
> +
>  # Check if -pie is supported or not.
>  send_log "$CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie"
>  catch "exec $CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output

 If you've decided to broaden coverage like this, then I think that beyond 
a simple check that $CC can be found in $PATH a proper installation check 
for the standard system libraries ought to be made, such as by trying to 
build a trivial executable comprised of `int main(void) { return 0; }'.  
This check might be executed once only per LD test suite invocation and 
cached rather than repeatedly for each dependent test script, taking 
advantage of all the test suite being executed in the same namespace (so 
that a plain global variable will do).  This is to avoid spurious failures 
in the case where a partial development environment has been installed 
only, e.g. binutils and a bootstrap compiler, but no C library.

 FWIW,

  Maciej

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-11 19:22     ` Maciej W. Rozycki
@ 2017-01-20  0:33       ` Alan Modra
  2017-01-20 16:17         ` [Patch] Honor ccflags when GCC used as linker driver Jiong Wang
  0 siblings, 1 reply; 22+ messages in thread
From: Alan Modra @ 2017-01-20  0:33 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Christophe Lyon, binutils

On Wed, Jan 11, 2017 at 07:22:05PM +0000, Maciej W. Rozycki wrote:
>  If you've decided to broaden coverage like this, then I think that beyond 
> a simple check that $CC can be found in $PATH a proper installation check 
> for the standard system libraries ought to be made, such as by trying to 
> build a trivial executable comprised of `int main(void) { return 0; }'.  
> This check might be executed once only per LD test suite invocation and 
> cached rather than repeatedly for each dependent test script, taking 
> advantage of all the test suite being executed in the same namespace (so 
> that a plain global variable will do).  This is to avoid spurious failures 
> in the case where a partial development environment has been installed 
> only, e.g. binutils and a bootstrap compiler, but no C library.

On the other hand, a trival executable may fail to link due to some
catastrophic ld failure.  I'm inclined to leave things as they are
unless we get a lot of complaints.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Patch] Honor ccflags when GCC used as linker driver
  2017-01-20  0:33       ` Alan Modra
@ 2017-01-20 16:17         ` Jiong Wang
  2017-01-22 21:18           ` Alan Modra
  2017-01-31 12:51           ` [ld, testsuite, obvious] Append $board_cflags in one more place in ld-unique/unique.exp Jiong Wang
  0 siblings, 2 replies; 22+ messages in thread
From: Jiong Wang @ 2017-01-20 16:17 UTC (permalink / raw)
  Cc: Binutils

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

There are a few more failures happen on AArch64 bare-metal recently as we
have enabled more elf tests.

As run_ld_link_exec_tests now always use gcc as linker driver, I think 
it should
start to specify all ccflags as well as ccflags may contain linker 
options for
example spec file.  There was similar fix before

   https://sourceware.org/ml/binutils/2014-10/msg00184.html

Meanwhile one unique test need to do the same thing.

This patch fixed quite a few failures on aarch64 bare-metal linker 
testing, no
regression.

OK for master?

2017-01-20  Jiong Wang  <jiong.wang@arm.com>

         * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
         board_cflags as gcc is used as linker driver.
         * ld/testsuite/ld-unique/unique.exp: Likewise

[-- Attachment #2: k.patch --]
[-- Type: text/x-diff, Size: 2129 bytes --]

diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index 0aecf01..f06622f 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -108,8 +108,17 @@ if ![ld_compile "$CC -c" "$srcdir/$subdir/unique_empty.s" "tmpdir/unique_empty.o
     set fails [expr $fails + 1]
 }
 
+# When using GCC as the linker driver, we need to specify board cflags when
+# linking because cflags may contain linker options.  For example when linker
+# options are included in GCC spec files then we need the -specs option.
+if [board_info [target_info name] exists cflags] {
+  set board_cflags " [board_info [target_info name] cflags]"
+} else {
+  set board_cflags ""
+}
+
 # Create executable containing unique symbol.
-if ![ld_link $CC "tmpdir/unique_prog" "tmpdir/unique.o"] {
+if ![ld_link "$CC $board_cflags" "tmpdir/unique_prog" "tmpdir/unique.o"] {
     fail "Could not link a unique executable"
     set fails [expr $fails + 1]
 }
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 5ca700b..a44358e 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1381,6 +1381,17 @@ proc run_ld_link_exec_tests { ldtests args } {
     global CXXFLAGS
     global errcnt
     global exec_output
+    global board_cflags
+
+    # When using GCC as the linker driver, we need to specify board cflags when
+    # linking because cflags may contain linker options.  For example when
+    # linker options are included in GCC spec files then we need the -specs
+    # option.
+    if [board_info [target_info name] exists cflags] {
+        set board_cflags " [board_info [target_info name] cflags]"
+    } else {
+	set board_cflags ""
+    }
 
     foreach testitem $ldtests {
 	foreach target $args {
@@ -1440,7 +1451,7 @@ proc run_ld_link_exec_tests { ldtests args } {
 	    # compile only
 	    pass $testname
 	    continue;
-	} elseif ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
+	} elseif ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles"] {
 	    set failed 1
 	}
 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Patch] Honor ccflags when GCC used as linker driver
  2017-01-20 16:17         ` [Patch] Honor ccflags when GCC used as linker driver Jiong Wang
@ 2017-01-22 21:18           ` Alan Modra
  2017-01-23 13:51             ` [ld, testsuite] Always assemble those intermeidate .o files used later Jiong Wang
  2017-01-31 12:51           ` [ld, testsuite, obvious] Append $board_cflags in one more place in ld-unique/unique.exp Jiong Wang
  1 sibling, 1 reply; 22+ messages in thread
From: Alan Modra @ 2017-01-22 21:18 UTC (permalink / raw)
  To: Jiong Wang; +Cc: Binutils

On Fri, Jan 20, 2017 at 04:17:37PM +0000, Jiong Wang wrote:
>         * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
>         board_cflags as gcc is used as linker driver.
>         * ld/testsuite/ld-unique/unique.exp: Likewise

Thanks, this is OK.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ld, testsuite] Always assemble those intermeidate .o files used later
  2017-01-22 21:18           ` Alan Modra
@ 2017-01-23 13:51             ` Jiong Wang
  2017-01-23 13:59               ` Christophe Lyon
  2017-01-24  0:44               ` Alan Modra
  0 siblings, 2 replies; 22+ messages in thread
From: Jiong Wang @ 2017-01-23 13:51 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]

On 22/01/17 21:18, Alan Modra wrote:
> On Fri, Jan 20, 2017 at 04:17:37PM +0000, Jiong Wang wrote:
>>          * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
>>          board_cflags as gcc is used as linker driver.
>>          * ld/testsuite/ld-unique/unique.exp: Likewise
> Thanks, this is OK.
>
Thanks for the review, pushed.

The only remaining failures on AArch64 bare-metal on my test environment is

FAIL: LTO 7
FAIL: LTO 8

which are caused by missing intermediate .o files.  The reason looks like the
assemble of some prerequisite .o files are gated by shared library check while
these .o are used later by non shared tests.

This patch simply split those compilation tests out to always run them,
meanwhile "LTO 7" has one .so participate linking, so it's gated by share
library check.

After this patch, above FAILs become UNSUPPORTED.
(I found some bare-metal tests actually are able to run on simulator, while ld
testsuite environment seems only support native run, might be a seperate issue)

Is this OK for master?

ld/
2017-01-23  Jiong Wang  <jiong.wang@arm.com>

         * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile 7",
         "Compile 8a", "Compile 8b"...
         (lto_compile_elf_tests): ...to here.  Always run these tests.
         (lto_run_elf_tests): Move "LTO 7"...
         (lto_run_elf_shared_tests): ...to here.  Restrict these tests on
         environment where share library is supported.


[-- Attachment #2: 1.patch --]
[-- Type: text/x-diff, Size: 2403 bytes --]

diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index b525acf..c738895 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -219,20 +219,23 @@ if { [at_least_gcc_version 4 7] } {
     ]]
 }
 
-# Generate input files for complex LTO tests for ELF.
-set lto_link_elf_tests [list \
+set lto_compile_elf_tests [list \
   [list "Compile 7" \
    "" "-flto -O2" \
    {lto-7a.c lto-7b.c lto-7c.c} {} ""] \
-  [list "Build liblto-7.so" \
-   "-shared" "-O2 -fpic" \
-   {lto-7d.c} {} "liblto-7.so" "c"] \
   [list "Compile 8a" \
    "" "-O2" \
    {lto-8a.c} {} ""] \
   [list "Compile 8b" \
    "" "-flto -O2" \
    {lto-8b.c} {} ""] \
+]
+
+# Generate input files for complex LTO tests for ELF.
+set lto_link_elf_tests [list \
+  [list "Build liblto-7.so" \
+   "-shared" "-O2 -fpic" \
+   {lto-7d.c} {} "liblto-7.so" "c"] \
   [list "Build liblto-17a.so" \
    "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto" \
    {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"] \
@@ -377,11 +380,15 @@ if { [at_least_gcc_version 4 7] } {
     ]]
 }
 
-# LTO run-time tests for ELF
-set lto_run_elf_tests [list \
+# LTO run-time tests for ELF which require shared library support.
+set lto_run_elf_shared_tests [list \
   [list "LTO 7" \
    "-O2 -flto -fuse-linker-plugin tmpdir/lto-7b.o tmpdir/lto-7c.o tmpdir/lto-7a.o -Wl,--no-as-needed tmpdir/liblto-7.so" "" \
    {dummy.c} "lto-7.exe" "lto-7.out" "" "c"] \
+]
+
+# LTO run-time tests for ELF
+set lto_run_elf_tests [list \
   [list "LTO 8" \
    "-O2 -flto -fuse-linker-plugin tmpdir/lto-8b.o tmpdir/lto-8a.o" "" \
    {dummy.c} "lto-8.exe" "lto-8.out" "" "c"] \
@@ -392,6 +399,10 @@ set lto_run_elf_tests [list \
 
 run_cc_link_tests $lto_link_tests
 
+# These compilation tests generate intermediate object files which will be used
+# by some elf tests besides shared libs tests.  So, always compile them.
+run_cc_link_tests $lto_compile_elf_tests
+
 # Restrict these to ELF targets that support shared libs and PIC.
 if { [is_elf_format] && [check_lto_shared_available] } {
     run_cc_link_tests $lto_link_elf_tests
@@ -487,6 +498,10 @@ if { [is_elf_format] } {
     run_ld_link_exec_tests $lto_run_elf_tests
 }
 
+if { [is_elf_format] && [check_lto_shared_available] } {
+    run_ld_link_exec_tests $lto_run_elf_shared_tests
+}
+
 proc pr20103 {cflags libs} {
     global CC
 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [ld, testsuite] Always assemble those intermeidate .o files used later
  2017-01-23 13:51             ` [ld, testsuite] Always assemble those intermeidate .o files used later Jiong Wang
@ 2017-01-23 13:59               ` Christophe Lyon
  2017-01-23 14:27                 ` Jiong Wang
  2017-01-24  0:44               ` Alan Modra
  1 sibling, 1 reply; 22+ messages in thread
From: Christophe Lyon @ 2017-01-23 13:59 UTC (permalink / raw)
  To: Jiong Wang; +Cc: Alan Modra, Binutils

Hi Jiong

On 23 January 2017 at 14:51, Jiong Wang <jiong.wang@foss.arm.com> wrote:
> On 22/01/17 21:18, Alan Modra wrote:
>>
>> On Fri, Jan 20, 2017 at 04:17:37PM +0000, Jiong Wang wrote:
>>>
>>>          * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
>>>          board_cflags as gcc is used as linker driver.
>>>          * ld/testsuite/ld-unique/unique.exp: Likewise
>>
>> Thanks, this is OK.
>>
> Thanks for the review, pushed.
>
> The only remaining failures on AArch64 bare-metal on my test environment is
>
> FAIL: LTO 7
> FAIL: LTO 8
>

Just curious: what is your test environment?
When cross-building+checking binutils for aarch64-none-elf, I have no
ld failure:
=== ld Summary ===

# of expected passes 470
# of expected failures 1
# of untested testcases 26
# of unsupported tests 33

Just wondering why?

> which are caused by missing intermediate .o files.  The reason looks like
> the
> assemble of some prerequisite .o files are gated by shared library check
> while
> these .o are used later by non shared tests.
>
> This patch simply split those compilation tests out to always run them,
> meanwhile "LTO 7" has one .so participate linking, so it's gated by share
> library check.
>
> After this patch, above FAILs become UNSUPPORTED.
> (I found some bare-metal tests actually are able to run on simulator, while
> ld
> testsuite environment seems only support native run, might be a seperate
> issue)
>
> Is this OK for master?
>
> ld/
> 2017-01-23  Jiong Wang  <jiong.wang@arm.com>
>
>         * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile
> 7",
>         "Compile 8a", "Compile 8b"...
>         (lto_compile_elf_tests): ...to here.  Always run these tests.
>         (lto_run_elf_tests): Move "LTO 7"...
>         (lto_run_elf_shared_tests): ...to here.  Restrict these tests on
>         environment where share library is supported.
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [ld, testsuite] Always assemble those intermeidate .o files used later
  2017-01-23 13:59               ` Christophe Lyon
@ 2017-01-23 14:27                 ` Jiong Wang
  2017-01-23 14:29                   ` Christophe Lyon
  0 siblings, 1 reply; 22+ messages in thread
From: Jiong Wang @ 2017-01-23 14:27 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: Alan Modra, Binutils



On 23/01/17 13:59, Christophe Lyon wrote:
> Hi Jiong
>
> On 23 January 2017 at 14:51, Jiong Wang <jiong.wang@foss.arm.com> wrote:
>> On 22/01/17 21:18, Alan Modra wrote:
>>> On Fri, Jan 20, 2017 at 04:17:37PM +0000, Jiong Wang wrote:
>>>>           * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
>>>>           board_cflags as gcc is used as linker driver.
>>>>           * ld/testsuite/ld-unique/unique.exp: Likewise
>>> Thanks, this is OK.
>>>
>> Thanks for the review, pushed.
>>
>> The only remaining failures on AArch64 bare-metal on my test environment is
>>
>> FAIL: LTO 7
>> FAIL: LTO 8
>>
> Just curious: what is your test environment?

It's a full cross toolchain environment

  cross gcc + cross binutils + newlib

> When cross-building+checking binutils for aarch64-none-elf, I have no
> ld failure:
> === ld Summary ===
>
> # of expected passes 470
> # of expected failures 1
> # of untested testcases 26
> # of unsupported tests 33
>
> Just wondering why?

I assume it's binutils only without all other toolchain components? If so, I guess some tests are simply returned, for example there are GCC availablilty check in ld-plugin/lto.exp etc.


>
>> which are caused by missing intermediate .o files.  The reason looks like
>> the
>> assemble of some prerequisite .o files are gated by shared library check
>> while
>> these .o are used later by non shared tests.
>>
>> This patch simply split those compilation tests out to always run them,
>> meanwhile "LTO 7" has one .so participate linking, so it's gated by share
>> library check.
>>
>> After this patch, above FAILs become UNSUPPORTED.
>> (I found some bare-metal tests actually are able to run on simulator, while
>> ld
>> testsuite environment seems only support native run, might be a seperate
>> issue)
>>
>> Is this OK for master?
>>
>> ld/
>> 2017-01-23  Jiong Wang  <jiong.wang@arm.com>
>>
>>          * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile
>> 7",
>>          "Compile 8a", "Compile 8b"...
>>          (lto_compile_elf_tests): ...to here.  Always run these tests.
>>          (lto_run_elf_tests): Move "LTO 7"...
>>          (lto_run_elf_shared_tests): ...to here.  Restrict these tests on
>>          environment where share library is supported.
>>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [ld, testsuite] Always assemble those intermeidate .o files used later
  2017-01-23 14:27                 ` Jiong Wang
@ 2017-01-23 14:29                   ` Christophe Lyon
  0 siblings, 0 replies; 22+ messages in thread
From: Christophe Lyon @ 2017-01-23 14:29 UTC (permalink / raw)
  To: Jiong Wang; +Cc: Alan Modra, Binutils

On 23 January 2017 at 15:27, Jiong Wang <jiong.wang@foss.arm.com> wrote:
>
>
> On 23/01/17 13:59, Christophe Lyon wrote:
>>
>> Hi Jiong
>>
>> On 23 January 2017 at 14:51, Jiong Wang <jiong.wang@foss.arm.com> wrote:
>>>
>>> On 22/01/17 21:18, Alan Modra wrote:
>>>>
>>>> On Fri, Jan 20, 2017 at 04:17:37PM +0000, Jiong Wang wrote:
>>>>>
>>>>>           * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests):
>>>>> Append
>>>>>           board_cflags as gcc is used as linker driver.
>>>>>           * ld/testsuite/ld-unique/unique.exp: Likewise
>>>>
>>>> Thanks, this is OK.
>>>>
>>> Thanks for the review, pushed.
>>>
>>> The only remaining failures on AArch64 bare-metal on my test environment
>>> is
>>>
>>> FAIL: LTO 7
>>> FAIL: LTO 8
>>>
>> Just curious: what is your test environment?
>
>
> It's a full cross toolchain environment
>
>  cross gcc + cross binutils + newlib
>
>> When cross-building+checking binutils for aarch64-none-elf, I have no
>> ld failure:
>> === ld Summary ===
>>
>> # of expected passes 470
>> # of expected failures 1
>> # of untested testcases 26
>> # of unsupported tests 33
>>
>> Just wondering why?
>
>
> I assume it's binutils only without all other toolchain components? If so, I
> guess some tests are simply returned, for example there are GCC availablilty
> check in ld-plugin/lto.exp etc.
>
Indeed, thanks.

>
>
>>
>>> which are caused by missing intermediate .o files.  The reason looks like
>>> the
>>> assemble of some prerequisite .o files are gated by shared library check
>>> while
>>> these .o are used later by non shared tests.
>>>
>>> This patch simply split those compilation tests out to always run them,
>>> meanwhile "LTO 7" has one .so participate linking, so it's gated by share
>>> library check.
>>>
>>> After this patch, above FAILs become UNSUPPORTED.
>>> (I found some bare-metal tests actually are able to run on simulator,
>>> while
>>> ld
>>> testsuite environment seems only support native run, might be a seperate
>>> issue)
>>>
>>> Is this OK for master?
>>>
>>> ld/
>>> 2017-01-23  Jiong Wang  <jiong.wang@arm.com>
>>>
>>>          * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move
>>> "Compile
>>> 7",
>>>          "Compile 8a", "Compile 8b"...
>>>          (lto_compile_elf_tests): ...to here.  Always run these tests.
>>>          (lto_run_elf_tests): Move "LTO 7"...
>>>          (lto_run_elf_shared_tests): ...to here.  Restrict these tests on
>>>          environment where share library is supported.
>>>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [ld, testsuite] Always assemble those intermeidate .o files used later
  2017-01-23 13:51             ` [ld, testsuite] Always assemble those intermeidate .o files used later Jiong Wang
  2017-01-23 13:59               ` Christophe Lyon
@ 2017-01-24  0:44               ` Alan Modra
  1 sibling, 0 replies; 22+ messages in thread
From: Alan Modra @ 2017-01-24  0:44 UTC (permalink / raw)
  To: Jiong Wang; +Cc: Binutils

On Mon, Jan 23, 2017 at 01:51:05PM +0000, Jiong Wang wrote:
>         * testsuite/ld-plugin/lto.exp (lto_link_elf_tests): Move "Compile 7",
>         "Compile 8a", "Compile 8b"...
>         (lto_compile_elf_tests): ...to here.  Always run these tests.
>         (lto_run_elf_tests): Move "LTO 7"...
>         (lto_run_elf_shared_tests): ...to here.  Restrict these tests on
>         environment where share library is supported.

OK.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [ld, testsuite, obvious] Append $board_cflags in one more place in ld-unique/unique.exp
  2017-01-20 16:17         ` [Patch] Honor ccflags when GCC used as linker driver Jiong Wang
  2017-01-22 21:18           ` Alan Modra
@ 2017-01-31 12:51           ` Jiong Wang
  1 sibling, 0 replies; 22+ messages in thread
From: Jiong Wang @ 2017-01-31 12:51 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

On 20/01/17 16:17, Jiong Wang wrote:
> There are a few more failures happen on AArch64 bare-metal recently as we
> have enabled more elf tests.
>
> As run_ld_link_exec_tests now always use gcc as linker driver, I think it should
> start to specify all ccflags as well as ccflags may contain linker options for
> example spec file.  There was similar fix before
>
>   https://sourceware.org/ml/binutils/2014-10/msg00184.html
>
> Meanwhile one unique test need to do the same thing.
>
> This patch fixed quite a few failures on aarch64 bare-metal linker testing, no
> regression.
>
> OK for master?
>
> 2017-01-20  Jiong Wang  <jiong.wang@arm.com>
>
>         * ld/testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Append
>         board_cflags as gcc is used as linker driver.
>         * ld/testsuite/ld-unique/unique.exp: Likewise

There is one more place in unique.exp where GCC is used as linker driver, so we
need to append board_cflags there. This is exposed by arm bare-metal linker
testing.

This patch fixed this and no regression on arm-none-eabi bare-metal check-ld
test and arm-none-linux-gnu native check-ld test.

This looks to me is an obvious fix, I will commit it if no objection within 24
hours.

ld/

2017-01-31  Jiong Wang  <jiong.wang@arm.com>

         * testsuite/ld-unique/unique.exp (Could not link a dynamic executable):
         Append $board_cflags to link commands.


[-- Attachment #2: k.patch --]
[-- Type: text/x-diff, Size: 735 bytes --]

diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp
index f06622f..61c070a 100644
--- a/ld/testsuite/ld-unique/unique.exp
+++ b/ld/testsuite/ld-unique/unique.exp
@@ -197,7 +197,7 @@ if {![ld_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"]
 }
 
 # Create executable NOT containing unique symbol linked against library.
-if {![ld_link $CC "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] } {
+if {![ld_link "$CC $board_cflags" "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] } {
     fail "Could not link a dynamic executable"
     set fails [expr $fails + 1]
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Run more ld tests when not native
  2017-01-02 13:35 Run more ld tests when not native Alan Modra
                   ` (2 preceding siblings ...)
  2017-01-10 19:01 ` H.J. Lu
@ 2019-02-14 16:53 ` Thomas Schwinge
  3 siblings, 0 replies; 22+ messages in thread
From: Thomas Schwinge @ 2019-02-14 16:53 UTC (permalink / raw)
  To: Alan Modra, binutils

[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]

Hi!

On Tue, 3 Jan 2017 00:04:53 +1030, Alan Modra <amodra@gmail.com> wrote:
> Many of the ld tests are not run for cross builds, in some cases
> because the test needs to run a newly linked executable, and in others
> simply because it was easier to write the test for native only.  Even
> when a test needs to run, it's good to compile and link to exercise
> the linker.  So that's what this patch does.  I've also rid us of
> the old ld_link procedure with all the HOSTING_CRT0 etc. setup.  It's
> much simpler to just link with $CC.

> --- a/ld/configure.host
> +++ b/ld/configure.host

> -#  HOSTING_CRT0		crt0.o file used for bootstrapping
> -#  HOSTING_LIBS		libraries used for bootstrapping

>  case "${host}" in

> -*-*-gnu*)
> -  # When creating static executables, we ought to use crt0.o instead of crt1.o,
> -  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
> -  # but the testing infrastructure is not prepared for that.  This is not
> -  # relevant for most tests, and the few remaining ones have been XFAILed.
> -  HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[ 	][ 	]*\(.*/ld[^ ]*\.so[^ 	]*\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
> -  HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
> -  ;;

Belatedly, thanks for cleaning up (that is, removing) this mess.  Thus
pushed to master the attached commit
abc163a4647f77bfa449e09da4a85a71e747cf4c "[ld, hurd] Remove
'ld-elf/elf.exp' XFAILs".


Grüße
 Thomas



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ld-hurd-Remove-ld-elf-elf.exp-XFAILs.patch --]
[-- Type: text/x-diff, Size: 1956 bytes --]

From abc163a4647f77bfa449e09da4a85a71e747cf4c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 29 Jun 2018 21:05:29 +0200
Subject: [PATCH] [ld, hurd] Remove 'ld-elf/elf.exp' XFAILs

... as a follow-up to commit d98164028637041c5de99af0d057bde3f168a8a8 "Run more
ld tests when not native", which replaced by a proper solution the following
mess before present in 'ld/configure.host':

    -*-*-gnu*)
    -  # When creating static executables, we ought to use crt0.o instead of crt1.o,
    -  # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>,
    -  # but the testing infrastructure is not prepared for that.  This is not
    -  # relevant for most tests, and the few remaining ones have been XFAILed.
    -  HOSTING_CRT0='[...]'
    -  HOSTING_LIBS='[...]'

	ld/
	* testsuite/ld-elf/elf.exp: Remove Hurd XFAILs.
---
 ld/ChangeLog                | 4 ++++
 ld/testsuite/ld-elf/elf.exp | 7 -------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index c213622ff2..508858f2af 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2019-02-14  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* testsuite/ld-elf/elf.exp: Remove Hurd XFAILs.
+
 2019-02-12  Nick Clifton  <nickc@redhat.com>
 
 	* po/fr.po: Updated French translation.
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 60a261b86d..4a5ef8a219 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -257,13 +257,6 @@ if { [istarget *-*-linux*]
     ]
 }
 
-# <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>
-# Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
-switch -regexp $target_triplet {
-    ^\[^-\]*-\[^-\]*-gnu.*$ {
-	set xfails "*-*-*"
-    }
-}
 run_ld_link_exec_tests $array_tests_static $xfails
 
 catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status
-- 
2.19.2


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-02-14 16:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-02 13:35 Run more ld tests when not native Alan Modra
2017-01-02 16:05 ` Christophe Lyon
2017-01-03  0:29   ` Alan Modra
2017-01-03  2:36     ` Alan Modra
2017-01-11 19:22     ` Maciej W. Rozycki
2017-01-20  0:33       ` Alan Modra
2017-01-20 16:17         ` [Patch] Honor ccflags when GCC used as linker driver Jiong Wang
2017-01-22 21:18           ` Alan Modra
2017-01-23 13:51             ` [ld, testsuite] Always assemble those intermeidate .o files used later Jiong Wang
2017-01-23 13:59               ` Christophe Lyon
2017-01-23 14:27                 ` Jiong Wang
2017-01-23 14:29                   ` Christophe Lyon
2017-01-24  0:44               ` Alan Modra
2017-01-31 12:51           ` [ld, testsuite, obvious] Append $board_cflags in one more place in ld-unique/unique.exp Jiong Wang
2017-01-03 21:16 ` Run more ld tests when not native Dimitar Dimitrov
2017-01-03 23:06   ` Alan Modra
2017-01-10 19:01 ` H.J. Lu
2017-01-10 21:50   ` Alan Modra
2017-01-10 22:06     ` H.J. Lu
2017-01-11  0:56       ` Alan Modra
2017-01-11 18:40         ` H.J. Lu
2019-02-14 16:53 ` Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).