]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/Makefile
Support compilers defaulting to PIE
[thirdparty/glibc.git] / elf / Makefile
index f20f52dee1ecd802ef5f448f92e8f6d11dd7a191..f21276c0064bb2bf6b2cdc6ef4c73d64e65e1851 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2007,2008,2009,2010,2011 Free Software Foundation, Inc.
+# Copyright (C) 1995-2015 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
 # Lesser General Public License for more details.
 
 # You should have received a copy of the GNU Lesser General Public
-# License along with the GNU C Library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA.
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
 
 # Makefile for elf subdirectory of GNU C Library.
 
 subdir         := elf
 
+include ../Makeconfig
+
 headers                = elf.h bits/elfclass.h link.h bits/link.h
-routines       = $(dl-routines) dl-support dl-iteratephdr \
+routines       = $(all-dl-routines) dl-support dl-iteratephdr \
                  dl-addr enbl-secure dl-profstub \
                  dl-origin dl-libc dl-sym dl-tsd dl-sysdep
 
 # The core dynamic linking functions are in libc for the static and
 # profiled libraries.
-dl-routines    = $(addprefix dl-,load cache lookup object reloc deps \
+dl-routines    = $(addprefix dl-,load lookup object reloc deps hwcaps \
                                  runtime error init fini debug misc \
                                  version profile conflict tls origin scope \
                                  execstack caller open close trampoline)
+ifeq (yes,$(use-ldconfig))
+dl-routines += dl-cache
+endif
 all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
 # But they are absent from the shared libc, because that code is in ld.so.
 elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
@@ -39,123 +43,39 @@ shared-only-routines += dl-caller
 
 # ld.so uses those routines, plus some special stuff for being the program
 # interpreter and operating independent of libc.
-rtld-routines  := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
+rtld-routines  = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal
 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
 
-distribute     := rtld-Rules \
-                  $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
-                  dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
-                  genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
-                  dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
-                  dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
-                  testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
-                  testobj6.c testobj1_1.c failobj.c unloadmod.c \
-                  ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
-                  chroot_canon.c gccframe.h \
-                  dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h unsecvars.h \
-                  vismain.c vismod1.c vismod2.c vismod3.c \
-                  constload2.c constload3.c filtmod1.c filtmod2.c \
-                  nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
-                  nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
-                  reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
-                  reldepmod5.c reldepmod6.c \
-                  reldep4mod1.c reldep4mod2.c reldep4mod3.c reldep4mod4.c \
-                  nextmod1.c nextmod2.c pathoptobj.c tst-pathopt.sh \
-                  neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
-                  neededobj5.c neededobj6.c firstobj.c \
-                  unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
-                  testobj.h vismod.h globalmod1.c \
-                  dblloadmod1.c dblloadmod2.c dblloadmod3.c \
-                  reldep6mod4.c reldep6mod3.c reldep6mod2.c reldep6mod1.c \
-                  reldep6mod0.c reldep7mod1.c reldep7mod2.c \
-                  unwind-dw2.c unwind-dw2-fde.c unwind.h unwind-pe.h \
-                  unwind-dw2-fde.h dwarf2.h dl-procinfo.c tls.h dl-tls.h \
-                  tst-tlsmod1.c tst-tlsmod2.c tst-tlsmod3.c tst-tlsmod4.c \
-                  tst-tlsmod5.c tst-tlsmod6.c tst-tlsmod7.c tst-tlsmod8.c \
-                  tst-tlsmod9.c tst-tlsmod10.c tst-tlsmod11.c \
-                  tst-tlsmod12.c tst-tls10.h tst-alignmod.c tst-alignmod2.c \
-                  circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \
-                  circlemod3.c circlemod3a.c nodlopenmod2.c \
-                  tst-tls19mod1.c tst-tls19mod2.c tst-tls19mod3.c \
-                  tls-macros.h \
-                  reldep8mod1.c reldep8mod2.c reldep8mod3.c \
-                  nodel2mod1.c nodel2mod2.c nodel2mod3.c \
-                  reldep9.c reldep9mod1.c reldep9mod2.c reldep9mod3.c \
-                  tst-array1.exp tst-array2.exp tst-array4.exp \
-                  tst-array2dep.c tst-piemod1.c \
-                  tst-execstack-mod.c tst-dlmodcount.c \
-                  check-textrel.c dl-sysdep.h test-dlopenrpathmod.c \
-                  tst-deep1mod1.c tst-deep1mod2.c tst-deep1mod3.c \
-                  unload3mod1.c unload3mod2.c unload3mod3.c unload3mod4.c \
-                  unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
-                  unload6mod1.c unload6mod2.c unload6mod3.c \
-                  unload7mod1.c unload7mod2.c \
-                  unload8mod1.c unload8mod1x.c unload8mod2.c unload8mod3.c \
-                  tst-audit1.c tst-audit2.c tst-audit3.c tst-audit4.c \
-                  tst-auditmod1.c tst-auditmod3a.c tst-auditmod3b.c \
-                  tst-auditmod4a.c tst-auditmod4b.c \
-                  tst-audit5.c tst-auditmod5a.c tst-auditmod5b.c \
-                  tst-audit6.c tst-auditmod6a.c tst-auditmod6b.c \
-                  tst-auditmod6c.c \
-                  tst-audit7.c tst-auditmod7a.c tst-auditmod7b.c \
-                  order2mod1.c order2mod2.c order2mod3.c order2mod4.c \
-                  tst-stackguard1.c tst-stackguard1-static.c \
-                  tst-array5.c tst-array5-static.c tst-array5dep.c \
-                  tst-array5.exp tst-leaks1.c check-execstack.c \
-                  ifuncmain1.c ifuncmain1pic.c ifuncmain1vis.c \
-                  ifuncmain1vispic.c ifuncmain1static.c \
-                  ifuncmain1staticpic.c ifuncmain1picstatic.c \
-                  ifuncdep1.c ifuncdep1pic.c ifuncmod1.c \
-                  ifuncmain1pie.c ifuncmain1vispie.c \
-                  ifuncmain1staticpie.c \
-                  ifuncmain2.c ifuncmain2static.c ifuncdep2.c \
-                  ifuncmain2pic.c ifuncmain2picstatic.c ifuncdep2pic.c \
-                  ifuncmain3.c ifuncmod3.c \
-                  ifuncmain4.c ifuncmain4static.c ifuncmain4picstatic.c \
-                  ifuncmain5.c ifuncmain5pic.c ifuncmain5picstatic.c \
-                  ifuncmain5pie.c ifuncmain5static.c \
-                  ifuncmain5staticpic.c \
-                  ifuncdep5.c ifuncdep5pic.c ifuncmod5.c \
-                  ifuncmain6pie.c ifuncmod6.c \
-                  ifuncmain7.c ifuncmain7pic.c ifuncmain7picstatic.c \
-                  ifuncmain7pie.c ifuncmain7static.c \
-                  tst-unique1.c tst-unique1mod1.c tst-unique1mod2.c \
-                  tst-unique2.c tst-unique2mod1.c tst-unique2mod2.c \
-                  tst-initordera1.c tst-initordera2.c tst-initorderb1.c \
-                  tst-initorderb2.c tst-initordera3.c tst-initordera4.c \
-                  tst-initorder.c \
-                  tst-initorder2.c
-
 CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
 
-include ../Makeconfig
-
 ifeq ($(unwind-find-fde),yes)
 routines += unwind-dw2-fde-glibc
 shared-only-routines += unwind-dw2-fde-glibc
 endif
 
-before-compile  = $(objpfx)trusted-dirs.h
-generated      := trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
-generated-dirs := for-renamed
+before-compile  += $(objpfx)trusted-dirs.h
+generated      += trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
+generated-dirs += for-renamed
 
-ifeq ($(versioning),yes)
+ifeq ($(build-shared),yes)
 ld-map         = $(common-objpfx)ld.map
 endif
 
 ifeq (yes,$(build-shared))
 extra-objs     = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
 generated      += librtld.os dl-allobjs.os ld.so ldd
-install-others = $(inst_slibdir)/$(rtld-installed-name)
+install-others = $(inst_rtlddir)/$(rtld-installed-name)
 install-bin-script = ldd
 endif
 
-others         = sprof sln pldd
-install-bin    = sprof pldd
+others         = sprof sln
+install-bin    = sprof
 others-static   = sln
 install-rootsbin = sln
+sln-modules    := static-stubs
+extra-objs     += $(sln-modules:=.o)
 
 ifeq (yes,$(use-ldconfig))
 ifeq (yes,$(build-shared))
@@ -163,58 +83,55 @@ others-static      += ldconfig
 others         += ldconfig
 install-rootsbin += ldconfig
 
-ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon
+ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon static-stubs
 extra-objs     += $(ldconfig-modules:=.o)
-
-pldd-modules := xmalloc
+endif
+endif
 
 # To find xmalloc.c and xstrdup.c
 vpath %.c ../locale/programs
 
-endif
-endif
-
-ifeq ($(have-ksh)$(build-shared),yesyes)
+ifeq ($(build-shared),yes)
 extra-objs += sotruss-lib.os sotruss-lib.so
 install-others += $(inst_auditdir)/sotruss-lib.so
 install-bin-script += sotruss
 generated += sotruss
-CPPFLAGS-sotruss-lib = -DNOT_IN_libc
+libof-sotruss-lib = extramodules
 $(objpfx)sotruss-lib.so: $(objpfx)sotruss-lib.os
        $(build-module-asneeded)
 $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
        $(common-objpfx)libc_nonshared.a
 
-$(objpfx)sotruss: sotruss.ksh $(common-objpfx)config.make
-       sed -e 's%@KSH@%$(KSH)%g' \
+$(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
+       sed -e 's%@BASH@%$(BASH)%g' \
            -e 's%@VERSION@%$(version)%g' \
            -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g' \
-           -e 's%@PREFIX@%$(prefix)%g' < $< > $@.new
+           -e 's%@PREFIX@%$(prefix)%g' \
+           -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
+           -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
+           < $< > $@.new
        chmod 555 $@.new
        mv -f $@.new $@
 $(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
        $(do-install-program)
 endif
 
-tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1
-ifeq (yes,$(have-initfini-array))
-tests += tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
-endif
-ifeq (yes,$(build-static))
-tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static
-ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
+tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
+       tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
+       tst-auxv
+tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
+              tst-leaks1-static tst-array1-static tst-array5-static \
+              tst-ptrguard1-static tst-dl-iter-static \
+              tst-tlsalign-static tst-tlsalign-extern-static
+ifeq (yes,$(build-shared))
 tests-static += tst-tls9-static
 tst-tls9-static-ENV = \
        LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
 endif
-ifeq (yes,$(have-initfini-array))
-tests-static += tst-array1-static tst-array5-static
-endif
 tests += $(tests-static)
-endif
 ifeq (yes,$(build-shared))
 tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
-        constload1 order vismain noload filter unload \
+        constload1 order noload filter unload \
         reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
         nodlopen nodlopen2 neededtest neededtest2 \
         neededtest3 neededtest4 unload2 lateglobal initfirst global \
@@ -226,24 +143,26 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
         tst-dlmodcount tst-dlopenrpath tst-deep1 \
         tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
         unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
-        tst-audit1 tst-audit2 \
+        tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
         tst-stackguard1 tst-addr1 tst-thrlock \
-        tst-unique1 tst-unique2 tst-unique3 tst-unique4 \
-        tst-initorder tst-initorder2
+        tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4) \
+        tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
+        tst-ptrguard1 tst-tlsalign tst-tlsalign-extern
 #       reldep9
+ifeq ($(build-hardcoded-path-in-tests),yes)
+tests += tst-dlopen-aout
+LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
+endif
 test-srcs = tst-pathopt
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 ifneq ($(selinux-enabled),1)
 tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
 endif
-ifeq (x86_64,$(config-machine))
-tests += tst-audit3 tst-audit4 tst-audit5
-ifeq (yes,$(config-cflags-avx))
-tests += tst-audit6 tst-audit7
 endif
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst-leaks1-mem.out \
+                $(objpfx)tst-leaks1-static-mem.out $(objpfx)noload-mem.out
 endif
-endif
-tests: $(objpfx)tst-leaks1-mem $(objpfx)noload-mem
 tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 tlsmod17a-modules = $(addprefix tst-tlsmod17a, $(tlsmod17a-suffixes))
@@ -287,26 +206,30 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
                order2mod1 order2mod2 order2mod3 order2mod4 \
                tst-unique1mod1 tst-unique1mod2 \
                tst-unique2mod1 tst-unique2mod2 \
-               tst-unique3lib tst-unique3lib2 \
-               tst-unique4lib \
+               tst-auditmod9a tst-auditmod9b \
+               $(if $(CXX),tst-unique3lib tst-unique3lib2 tst-unique4lib) \
                tst-initordera1 tst-initorderb1 \
                tst-initordera2 tst-initorderb2 \
                tst-initordera3 tst-initordera4 \
-               tst-initorder2a tst-initorder2b tst-initorder2c tst-initorder2d
-ifeq (yes,$(have-initfini-array))
-modules-names += tst-array2dep tst-array5dep
+               tst-initorder2a tst-initorder2b tst-initorder2c \
+               tst-initorder2d \
+               tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
+               tst-array5dep tst-null-argv-lib \
+               tst-tlsalign-lib
+ifeq (yes,$(have-protected-data))
+modules-names += tst-protected1moda tst-protected1modb
+tests += tst-protected1a tst-protected1b
+$(objpfx)tst-protected1a: $(addprefix $(objpfx),tst-protected1moda.so tst-protected1modb.so)
+$(objpfx)tst-protected1b: $(addprefix $(objpfx),tst-protected1modb.so tst-protected1moda.so)
+tst-protected1modb.so-no-z-defs = yes
 endif
 ifeq (yesyes,$(have-fpie)$(build-shared))
 modules-names += tst-piemod1
-tests += tst-pie1
-tests-pie += tst-pie1
-endif
-ifeq (x86_64,$(config-machine))
-modules-names += tst-auditmod3a tst-auditmod3b \
-               tst-auditmod4a tst-auditmod4b \
-               tst-auditmod5a tst-auditmod5b \
-               tst-auditmod6a tst-auditmod6b tst-auditmod6c \
-               tst-auditmod7a tst-auditmod7b
+tests += tst-pie1 tst-pie2
+tests-pie += tst-pie1 tst-pie2
+tests += vismain
+tests-pie += vismain
+CFLAGS-vismain.c = $(PIE-ccflag)
 endif
 modules-execstack-yes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
@@ -343,12 +266,31 @@ modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
 endif
 endif
 
+ifeq (yes,$(build-shared))
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out
+endif
+tests-special += $(objpfx)check-textrel.out $(objpfx)check-execstack.out \
+                $(objpfx)check-localplt.out
+endif
 
-include ../Rules
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
+                $(objpfx)tst-array1-static-cmp.out \
+                $(objpfx)tst-array2-cmp.out $(objpfx)tst-array3-cmp.out \
+                $(objpfx)tst-array4-cmp.out $(objpfx)tst-array5-cmp.out \
+                $(objpfx)tst-array5-static-cmp.out $(objpfx)order2-cmp.out \
+                $(objpfx)tst-initorder-cmp.out \
+                $(objpfx)tst-initorder2-cmp.out $(objpfx)tst-unused-dep.out \
+                $(objpfx)tst-unused-dep-cmp.out
+endif
 
-check-abi: check-abi-ld
+check-abi: $(objpfx)check-abi-ld.out
+tests-special += $(objpfx)check-abi-ld.out
 update-abi: update-abi-ld
 
+include ../Rules
+
 ifeq (yes,$(build-shared))
 # Make sure these things are built in the `make lib' pass so they can be used
 # to run programs during the `make others' pass.
@@ -412,18 +354,22 @@ generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
 z-now-yes = -Wl,-z,now
 
 $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
-       $(LINK.o) -nostdlib -nostartfiles -shared -o $@                 \
+# Link into a temporary file so that we don't touch $@ at all
+# if the sanity check below fails.
+       $(LINK.o) -nostdlib -nostartfiles -shared -o $@.new             \
                  $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))      \
                  $(filter-out $(map-file),$^) $(load-map-file)         \
                  -Wl,-soname=$(rtld-installed-name)                    \
                  -Wl,-defsym=_begin=0
-       readelf -s $@ \
+       $(call after-link,$@.new)
+       $(READELF) -s $@.new \
          | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
+       mv -f $@.new $@
 
-# interp.c exists just to get this string into the libraries.
-CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \
-                 -DNOT_IN_libc=1
-$(objpfx)interp.os: $(common-objpfx)config.make
+ifeq (yes,$(build-shared))
+# interp.c exists just to get the runtime linker path into libc.so.
+$(objpfx)interp.os: $(common-objpfx)runtime-linker.h
+endif
 
 ifneq (ld.so,$(rtld-installed-name))
 # Make sure ld.so.1 exists in the build directory so we can link
@@ -453,36 +399,32 @@ $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
        $(make-target-directory)
        $(do-install-program)
 
-$(inst_slibdir)/$(rtld-installed-name): \
+$(inst_rtlddir)/$(rtld-installed-name): \
   $(inst_slibdir)/$(rtld-version-installed-name) \
   $(inst_slibdir)/libc-$(version).so
+       $(make-target-directory)
        $(make-shlib-link)
 
 # Special target called by parent to install just the dynamic linker.
 .PHONY: ldso_install
-ldso_install: $(inst_slibdir)/$(rtld-installed-name)
+ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
 endif
 
 
-common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
-                    -e 's%@VERSION@%$(version)%g'
-sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
-bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
-                  -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
-
-ifneq ($(have-bash2),yes)
-ldd-shell = sh
-else
-ldd-shell = bash
-endif
+ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
+             -e 's%@VERSION@%$(version)%g' \
+             -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
+             -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
+             -e 's%@BASH@%$(BASH)%g' \
+             -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
 
 ifeq ($(ldd-rewrite-script),no)
 define gen-ldd
-LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
+LC_ALL=C sed $(ldd-rewrite) < $< > $@.new
 endef
 else
 define gen-ldd
-LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< \
+LC_ALL=C sed $(ldd-rewrite) < $< \
 | LC_ALL=C sed -f $(patsubst $(..)/%,/%,$(..)$(ldd-rewrite-script)) > $@.new
 endef
 endif
@@ -495,27 +437,25 @@ $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
 
 $(objpfx)sprof: $(libdl)
 
-$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
+$(objpfx)sln: $(sln-modules:%=$(objpfx)%.o)
 
-$(objpfx)pldd: $(pldd-modules:%=$(objpfx)%.o)
+$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
 
 SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
 CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
-                   -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
+                   -D'SLIBDIR="$(slibdir)"'
+libof-ldconfig = ldconfig
 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
 CFLAGS-cache.c = $(SYSCONF-FLAGS)
+CFLAGS-rtld.c = $(SYSCONF-FLAGS)
 
-CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
+cpp-srcs-left := $(all-rtld-routines:=.os)
+lib := rtld
+include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 
 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
 generated += $(addsuffix .so,$(strip $(modules-names)))
 
-ifeq (yes,$(build-shared))
-ifeq ($(cross-compiling),no)
-tests: $(objpfx)tst-pathopt.out
-endif
-endif
-
 $(objpfx)testobj1.so: $(libdl)
 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
 $(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
@@ -581,9 +521,31 @@ $(objpfx)tst-initorderb2.so: $(objpfx)tst-initorderb1.so $(objpfx)tst-initordera
 $(objpfx)tst-initordera3.so: $(objpfx)tst-initorderb2.so $(objpfx)tst-initorderb1.so
 $(objpfx)tst-initordera4.so: $(objpfx)tst-initordera3.so
 $(objpfx)tst-initorder: $(objpfx)tst-initordera4.so $(objpfx)tst-initordera1.so $(objpfx)tst-initorderb2.so
-
-LDFLAGS-tst-tlsmod5.so = -nostdlib
-LDFLAGS-tst-tlsmod6.so = -nostdlib
+$(objpfx)tst-null-argv: $(objpfx)tst-null-argv-lib.so
+$(objpfx)tst-tlsalign: $(objpfx)tst-tlsalign-lib.so
+
+# BZ#18383: broken on at least ARM (both).
+test-xfail-tst-tlsalign = yes
+test-xfail-tst-tlsalign-static = yes
+
+$(objpfx)tst-tlsalign-extern: $(objpfx)tst-tlsalign-vars.o
+$(objpfx)tst-tlsalign-extern-static: $(objpfx)tst-tlsalign-vars.o
+
+tst-null-argv-ENV = LD_DEBUG=all LD_DEBUG_OUTPUT=$(objpfx)tst-null-argv.debug.out
+LDFLAGS-nodel2mod3.so = $(no-as-needed)
+LDFLAGS-reldepmod5.so = $(no-as-needed)
+LDFLAGS-reldep6mod1.so = $(no-as-needed)
+LDFLAGS-reldep6mod4.so = $(no-as-needed)
+LDFLAGS-reldep8mod3.so = $(no-as-needed)
+LDFLAGS-unload4mod1.so = $(no-as-needed)
+LDFLAGS-unload4mod2.so = $(no-as-needed)
+LDFLAGS-tst-initorder = $(no-as-needed)
+LDFLAGS-tst-initordera2.so = $(no-as-needed)
+LDFLAGS-tst-initordera3.so = $(no-as-needed)
+LDFLAGS-tst-initordera4.so = $(no-as-needed)
+LDFLAGS-tst-initorderb2.so = $(no-as-needed)
+LDFLAGS-tst-tlsmod5.so = -nostdlib $(no-as-needed)
+LDFLAGS-tst-tlsmod6.so = -nostdlib $(no-as-needed)
 
 testobj1.so-no-z-defs = yes
 testobj3.so-no-z-defs = yes
@@ -627,6 +589,8 @@ unload4mod1.so-no-z-defs = yes
 ifuncmod1.so-no-z-defs = yes
 ifuncmod5.so-no-z-defs = yes
 ifuncmod6.so-no-z-defs = yes
+tst-auditmod9a.so-no-z-defs = yes
+tst-auditmod9b.so-no-z-defs = yes
 
 ifeq ($(build-shared),yes)
 # Build all the modules even when not actually running test programs.
@@ -650,7 +614,6 @@ $(objpfx)neededtest3: $(libdl)
 $(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
                          $(objpfx)neededobj3.so $(objpfx)neededobj4.so
 
-neededtest4-ENV = LC_ALL=C LANGUAGE=C
 $(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
 $(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
 
@@ -704,22 +667,21 @@ $(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
 
 $(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
 
-$(objpfx)order.out: $(objpfx)order
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)order > $@
-       (echo "0123456789" | cmp $@ -) > /dev/null
+$(objpfx)order-cmp.out: $(objpfx)order.out
+       (echo "0123456789" | cmp $< -) > $@; \
+       $(evaluate-test)
 
 $(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
 $(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
 vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
 
-$(objpfx)noload: $(objpfx)testobj1.so $(common-objpfx)dlfcn/libdl.so
-LDFLAGS-noload = -rdynamic
+$(objpfx)noload: $(objpfx)testobj1.so $(libdl)
+LDFLAGS-noload = -rdynamic $(no-as-needed)
 $(objpfx)noload.out: $(objpfx)testobj5.so
 
-$(objpfx)noload-mem: $(objpfx)noload.out
-       $(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@
+$(objpfx)noload-mem.out: $(objpfx)noload.out
+       $(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@; \
+       $(evaluate-test)
 noload-ENV = MALLOC_TRACE=$(objpfx)noload.mtrace
 
 LDFLAGS-nodelete = -rdynamic
@@ -760,6 +722,7 @@ $(objpfx)reldep4: $(libdl)
 $(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
 
 $(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
+LDFLAGS-next = $(no-as-needed)
 
 $(objpfx)unload2: $(libdl)
 $(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
@@ -770,7 +733,13 @@ $(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
 $(objpfx)tst-pathopt: $(libdl)
 $(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
                          $(objpfx)pathoptobj.so
-       $(SHELL) -e $< $(common-objpfx)
+       $(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
+                '$(run-program-env)'; \
+       $(evaluate-test)
+
+$(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
+       $(SHELL) $^ '$(test-wrapper)' '$(test-wrapper-env)' > $@; \
+       $(evaluate-test)
 
 $(objpfx)initfirst: $(libdl)
 $(objpfx)initfirst.out: $(objpfx)firstobj.so
@@ -907,118 +876,136 @@ $(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
 LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
 
 LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
+CFLAGS-tst-execstack-prog.c += -Wno-trampolines
+CFLAGS-tst-execstack-mod.c += -Wno-trampolines
 endif
 
-$(objpfx)tst-array1.out: $(objpfx)tst-array1
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)tst-array1 > $@
-       cmp $@ tst-array1.exp > /dev/null
+LDFLAGS-tst-array2 = $(no-as-needed)
+LDFLAGS-tst-array5 = $(no-as-needed)
+
+$(objpfx)tst-array1-cmp.out: tst-array1.exp $(objpfx)tst-array1.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
-$(objpfx)tst-array1-static.out: $(objpfx)tst-array1-static
-       $(objpfx)tst-array1-static > $@
-       cmp $@ tst-array1.exp > /dev/null
+$(objpfx)tst-array1-static-cmp.out: tst-array1.exp \
+                                   $(objpfx)tst-array1-static.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
 $(objpfx)tst-array2: $(objpfx)tst-array2dep.so
-$(objpfx)tst-array2.out: $(objpfx)tst-array2
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)tst-array2 > $@
-       cmp $@ tst-array2.exp > /dev/null
-
-$(objpfx)tst-array3.out: $(objpfx)tst-array3
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)tst-array3 > $@
-       cmp $@ tst-array1.exp > /dev/null
+$(objpfx)tst-array2-cmp.out: tst-array2.exp $(objpfx)tst-array2.out
+       cmp $^ > $@; \
+       $(evaluate-test)
+
+$(objpfx)tst-array3-cmp.out: tst-array1.exp $(objpfx)tst-array3.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
 $(objpfx)tst-array4: $(libdl)
-$(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $< > $@
-       cmp $@ tst-array4.exp > /dev/null
+$(objpfx)tst-array4.out: $(objpfx)tst-array2dep.so
+$(objpfx)tst-array4-cmp.out: tst-array4.exp $(objpfx)tst-array4.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
 $(objpfx)tst-array5: $(objpfx)tst-array5dep.so
-$(objpfx)tst-array5.out: $(objpfx)tst-array5
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)tst-array5 > $@
-       cmp $@ tst-array5.exp > /dev/null
+$(objpfx)tst-array5-cmp.out: tst-array5.exp $(objpfx)tst-array5.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
-$(objpfx)tst-array5-static.out: $(objpfx)tst-array5-static
-       $(objpfx)tst-array5-static > $@
-       cmp $@ tst-array5-static.exp > /dev/null
+$(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
+                               $(objpfx)tst-array5-static.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
 CFLAGS-tst-pie1.c += $(pie-ccflag)
+CFLAGS-tst-pie2.c += $(pie-ccflag)
 
 $(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
 
-check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
-$(objpfx)check-textrel: check-textrel.c
-       $(native-compile)
+ifeq (yes,$(build-shared))
+all-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
+                $(filter-out $(common-objpfx)linkobj/libc.so, \
+                             $(sort $(wildcard $(addprefix $(common-objpfx), \
+                                                           */lib*.so \
+                                                           iconvdata/*.so))))
+
+$(all-built-dso:=.dyn): %.dyn: %
+       @rm -f $@T
+       LC_ALL=C $(READELF) -W -d $< > $@T
+       test -s $@T
+       mv -f $@T $@
+common-generated += $(all-built-dso:$(common-objpfx)%=%.dyn)
+
+$(objpfx)check-textrel.out: $(..)scripts/check-textrel.awk \
+                           $(all-built-dso:=.dyn)
+       LC_ALL=C $(AWK) -f $^ > $@; \
+       $(evaluate-test)
+generated += check-textrel.out
 
-check-execstack-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 \
-                        $(objpfx:%/=-I%)
-$(objpfx)check-execstack: check-execstack.c $(objpfx)check-execstack.h
-       $(native-compile)
-$(objpfx)check-execstack.h: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
+$(objpfx)execstack-default: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
        $(make-target-directory)
-       { echo '#include <stackinfo.h>'; echo '@@@DEFAULT_STACK_PERMS@@@'; } | \
+       { echo '#include <elf.h>'; \
+         echo '#include <stackinfo.h>'; \
+         echo '#if (DEFAULT_STACK_PERMS & PF_X) == 0'; \
+         echo '@@@execstack-no@@@'; \
+         echo '#else'; \
+         echo '@@@execstack-yes@@@'; \
+         echo '#endif'; } | \
        $(CC) $(CFLAGS) $(CPPFLAGS) -E -x c-header - | \
-       sed -n -e 's/^@@@\(.*\)@@@/#define DEFAULT_STACK_PERMS \1/p' > $@T
+       sed -n -e 's/^@@@\(.*\)@@@/\1/p' > $@T
        mv -f $@T $@
-generated += check-execstack.h
+generated += execstack-default
 
-check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99
-$(objpfx)check-localplt: check-localplt.c
-       $(native-compile)
-
-ifeq (yes,$(build-shared))
-tests: $(objpfx)check-textrel.out $(objpfx)check-execstack.out
-
-all-built-dso = $(common-objpfx)libc.so \
-               $(filter-out $(common-objpfx)linkobj/libc.so, \
-                            $(sort $(wildcard $(common-objpfx)*/lib*.so \
-                                              $(common-objpfx)iconvdata/*.so)))
-
-$(objpfx)check-textrel.out: $(objpfx)check-textrel $(all-built-dso)
-       $(dir $<)$(notdir $<) $(filter-out $<, $^) > $@
-generated += check-textrel check-textrel.out
+$(all-built-dso:=.phdr): %.phdr: %
+       @rm -f $@T
+       LC_ALL=C $(READELF) -W -l $< > $@T
+       test -s $@T
+       mv -f $@T $@
+common-generated += $(all-built-dso:$(common-objpfx)%=%.phdr)
 
-$(objpfx)check-execstack.out: $(objpfx)check-execstack $(all-built-dso)
-       $(dir $<)$(notdir $<) $(filter-out $<, $^) > $@
-generated += check-execstack check-execstack.out
+$(objpfx)check-execstack.out: $(..)scripts/check-execstack.awk \
+                             $(objpfx)execstack-default \
+                             $(all-built-dso:=.phdr)
+       LC_ALL=C $(AWK) -f $^ > $@; \
+       $(evaluate-test)
+generated += check-execstack.out
 
 $(objpfx)tst-dlmodcount: $(libdl)
 $(objpfx)tst-dlmodcount.out: $(test-modules)
 
-check-data := $(firstword $(wildcard \
-               $(foreach D,$(add-ons) scripts,\
-                         $(patsubst %,$(..)$D/data/localplt-%.data,\
-                                    $(abi-name) \
-                                    $(addsuffix -$(config-os),\
-                                                $(config-machine) \
-                                                $(base-machine)) \
-                          generic))))
-
-tests: $(objpfx)check-localplt.out
-
+$(all-built-dso:=.jmprel): %.jmprel: % Makefile
+       @rm -f $@T
+       LC_ALL=C $(READELF) -W -S -d -r $< > $@T
+       test -s $@T
+       mv -f $@T $@
+common-generated += $(all-built-dso:$(common-objpfx)%=%.jmprel)
+
+localplt-built-dso := $(addprefix $(common-objpfx),\
+                                 libc.so \
+                                 elf/ld.so \
+                                 math/libm.so \
+                                 rt/librt.so \
+                                 dlfcn/libdl.so \
+                                 resolv/libresolv.so \
+                                 crypt/libcrypt.so \
+                      )
+ifeq ($(build-mathvec),yes)
+localplt-built-dso += $(addprefix $(common-objpfx), mathvec/libmvec.so)
+endif
 ifeq ($(have-thread-library),yes)
-thread-dso := $(filter-out %_nonshared.a, $(shared-thread-library))
+localplt-built-dso += $(filter-out %_nonshared.a, $(shared-thread-library))
 endif
 
-$(objpfx)check-localplt.out: $(objpfx)check-localplt \
-                            $(common-objpfx)libc.so \
-                            $(common-objpfx)math/libm.so $(thread-dso) \
-                            $(common-objpfx)rt/librt.so \
-                            $(common-objpfx)dlfcn/libdl.so \
-                            $(common-objpfx)resolv/libresolv.so \
-                            $(common-objpfx)crypt/libcrypt.so \
-                            $(check-data)
-       $(dir $<)$(notdir $<) $(filter-out $< $(check-data),$^) | \
-         LC_ALL=C sort | \
-         diff -u $(check-data) - > $@
+vpath localplt.data $(+sysdep_dirs)
+
+$(objpfx)check-localplt.out: $(..)scripts/check-localplt.awk \
+                            $(..)scripts/localplt.awk \
+                            $(localplt-built-dso:=.jmprel) \
+                            localplt.data
+       LC_ALL=C $(AWK) -f $(filter-out $< %localplt.data,$^) | \
+         LC_ALL=C $(AWK) -f $< $(filter %localplt.data,$^) - \
+         > $@; \
+       $(evaluate-test)
 endif
 
 $(objpfx)tst-dlopenrpathmod.so: $(libdl)
@@ -1046,57 +1033,61 @@ $(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so
 $(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so
 tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 
-$(objpfx)tst-audit2.out: $(objpfx)tst-auditmod1.so
+$(objpfx)tst-audit2: $(libdl)
+$(objpfx)tst-audit2.out: $(objpfx)tst-auditmod1.so $(objpfx)tst-auditmod9b.so
+# Prevent GCC-5 from translating a malloc/memset pair into calloc
+CFLAGS-tst-audit2.c += -fno-builtin
 tst-audit2-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 
-$(objpfx)tst-audit3: $(objpfx)tst-auditmod3a.so
-$(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so
-tst-audit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod3b.so
+$(objpfx)tst-audit9: $(libdl)
+$(objpfx)tst-audit9.out: $(objpfx)tst-auditmod9a.so $(objpfx)tst-auditmod9b.so
+tst-audit9-ENV = LD_AUDIT=$(objpfx)tst-auditmod9a.so
 
-$(objpfx)tst-audit4: $(objpfx)tst-auditmod4a.so
-$(objpfx)tst-audit4.out: $(objpfx)tst-auditmod4b.so
-tst-audit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod4b.so
-
-$(objpfx)tst-audit5: $(objpfx)tst-auditmod5a.so
-$(objpfx)tst-audit5.out: $(objpfx)tst-auditmod5b.so
-tst-audit5-ENV = LD_AUDIT=$(objpfx)tst-auditmod5b.so
-
-$(objpfx)tst-audit6: $(objpfx)tst-auditmod6a.so
-$(objpfx)tst-audit6.out: $(objpfx)tst-auditmod6b.so \
-                        $(objpfx)tst-auditmod6c.so
-tst-audit6-ENV = LD_AUDIT=$(objpfx)tst-auditmod6b.so:$(objpfx)tst-auditmod6c.so
-
-$(objpfx)tst-audit7: $(objpfx)tst-auditmod7a.so
-$(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so
-tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so
+$(objpfx)tst-audit8: $(libm)
+$(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so
+tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 
 $(objpfx)tst-global1: $(libdl)
 $(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
 
 $(objpfx)order2: $(libdl)
-$(objpfx)order2.out: $(objpfx)order2 $(objpfx)order2mod1.so \
-                    $(objpfx)order2mod2.so
-       $(elf-objpfx)$(rtld-installed-name) \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $(objpfx)order2 > $@
-       (echo "12345" | cmp $@ -) > /dev/null
+$(objpfx)order2.out: $(objpfx)order2mod1.so $(objpfx)order2mod2.so
+$(objpfx)order2-cmp.out: $(objpfx)order2.out
+       (echo "12345" | cmp $< -) > $@; \
+       $(evaluate-test)
 $(objpfx)order2mod1.so: $(objpfx)order2mod4.so
 $(objpfx)order2mod4.so: $(objpfx)order2mod3.so
 $(objpfx)order2mod2.so: $(objpfx)order2mod3.so
 order2mod2.so-no-z-defs = yes
+LDFLAGS-order2mod1.so = $(no-as-needed)
+LDFLAGS-order2mod2.so = $(no-as-needed)
 
-tst-stackguard1-ARGS = --command "$(built-program-cmd) --child"
+tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
 tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
 
+tst-ptrguard1-ARGS = --command "$(host-test-program-cmd) --child"
+# When built statically, the pointer guard interface uses
+# __pointer_chk_guard_local.
+CFLAGS-tst-ptrguard1-static.c = -DPTRGUARD_LOCAL
+tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
+
 $(objpfx)tst-leaks1: $(libdl)
-$(objpfx)tst-leaks1-mem: $(objpfx)tst-leaks1.out
-       $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@
+$(objpfx)tst-leaks1-mem.out: $(objpfx)tst-leaks1.out
+       $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@; \
+       $(evaluate-test)
+
+$(objpfx)tst-leaks1-static: $(common-objpfx)dlfcn/libdl.a
+$(objpfx)tst-leaks1-static-mem.out: $(objpfx)tst-leaks1-static.out
+       $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1-static.mtrace > $@; \
+       $(evaluate-test)
 
 tst-leaks1-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1.mtrace
+tst-leaks1-static-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1-static.mtrace
 
 $(objpfx)tst-addr1: $(libdl)
 
 $(objpfx)tst-thrlock: $(libdl) $(shared-thread-library)
+$(objpfx)tst-dlopen-aout: $(libdl) $(shared-thread-library)
 
 CFLAGS-ifuncmain1pic.c += $(pic-ccflag)
 CFLAGS-ifuncmain1picstatic.c += $(pic-ccflag)
@@ -1162,16 +1153,18 @@ $(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
 
 $(objpfx)tst-unique4: $(objpfx)tst-unique4lib.so
 
-$(objpfx)tst-initorder.out: $(objpfx)tst-initorder
-       $(elf-objpfx)${rtld-installed-name} \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $< > $@
-       cmp $@ tst-initorder.exp > /dev/null
+$(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
+       cmp $^ > $@; \
+       $(evaluate-test)
 
 $(objpfx)tst-initorder2: $(objpfx)tst-initorder2a.so $(objpfx)tst-initorder2d.so $(objpfx)tst-initorder2c.so
 $(objpfx)tst-initorder2a.so: $(objpfx)tst-initorder2b.so
 $(objpfx)tst-initorder2b.so: $(objpfx)tst-initorder2c.so
 $(objpfx)tst-initorder2c.so: $(objpfx)tst-initorder2d.so
+LDFLAGS-tst-initorder2 = $(no-as-needed)
+LDFLAGS-tst-initorder2a.so = $(no-as-needed)
+LDFLAGS-tst-initorder2b.so = $(no-as-needed)
+LDFLAGS-tst-initorder2c.so = $(no-as-needed)
 define o-iterator-doit
 $(objpfx)tst-initorder2$o.os: tst-initorder2.c; \
 $$(compile-command.c) -DNAME=\"$o\"
@@ -1179,21 +1172,25 @@ endef
 object-suffixes-left := a b c d
 include $(o-iterator)
 
-$(objpfx)tst-initorder2.out: $(objpfx)tst-initorder2
-       $(elf-objpfx)${rtld-installed-name} \
-         --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
-         $< > $@
-       cmp $@ tst-initorder2.exp > /dev/null
-
-ifeq (yes,$(config-cflags-avx))
-AVX-CFLAGS=-mavx
-ifeq (yes,$(config-cflags-novzeroupper))
-AVX-CFLAGS+=-mno-vzeroupper
-endif
-CFLAGS-tst-audit4.c += $(AVX-CFLAGS)
-CFLAGS-tst-auditmod4a.c += $(AVX-CFLAGS)
-CFLAGS-tst-auditmod4b.c += $(AVX-CFLAGS)
-CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS)
-CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS)
-CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
-endif
+$(objpfx)tst-initorder2-cmp.out: tst-initorder2.exp $(objpfx)tst-initorder2.out
+       cmp $^ > $@; \
+       $(evaluate-test)
+
+$(objpfx)tst-relsort1: $(libdl)
+$(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
+$(objpfx)tst-relsort1mod2.so: $(libm)
+$(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
+                          $(objpfx)tst-relsort1mod2.so
+
+$(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
+       $(test-wrapper-env) \
+       LD_TRACE_LOADED_OBJECTS=1 \
+       LD_DEBUG=unused \
+       LD_PRELOAD= \
+       $(rtld-prefix) \
+         $< > $@; \
+       $(evaluate-test)
+
+$(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
+       cmp $< /dev/null > $@; \
+       $(evaluate-test)