1# Copyright (C) 1995-2022 Free Software Foundation, Inc.
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# Lesser General Public License for more details.
13
14# You should have received a copy of the GNU Lesser General Public
15# License along with the GNU C Library; if not, see
16# <https://www.gnu.org/licenses/>.
17
18# Makefile for elf subdirectory of GNU C Library.
19
20subdir		:= elf
21
22include ../Makeconfig
23
24headers = \
25  bits/elfclass.h \
26  bits/link.h \
27  bits/link_lavcurrent.h \
28  elf.h \
29  link.h \
30  # headers
31
32routines = \
33  $(all-dl-routines) \
34  dl-addr \
35  dl-addr-obj \
36  dl-early_allocate \
37  dl-error \
38  dl-iteratephdr \
39  dl-libc \
40  dl-origin \
41  dl-profstub \
42  dl-reloc-static-pie \
43  dl-support \
44  dl-sym \
45  dl-sysdep \
46  enbl-secure \
47  libc-dl_find_object \
48  libc_early_init \
49  rtld_static_init \
50  # routines
51
52# The core dynamic linking functions are in libc for the static and
53# profiled libraries.
54dl-routines = \
55  dl-call-libc-early-init \
56  dl-close \
57  dl-debug \
58  dl-debug-symbols \
59  dl-deps \
60  dl-exception \
61  dl-execstack \
62  dl-find_object \
63  dl-fini \
64  dl-init \
65  dl-load \
66  dl-lookup \
67  dl-lookup-direct \
68  dl-minimal-malloc \
69  dl-misc \
70  dl-object \
71  dl-open \
72  dl-origin \
73  dl-printf \
74  dl-profile \
75  dl-reloc \
76  dl-runtime \
77  dl-scope \
78  dl-setup_hash \
79  dl-sort-maps \
80  dl-thread_gscope_wait \
81  dl-tls \
82  dl-tls_init_tp \
83  dl-trampoline \
84  dl-version \
85  dl-write \
86  # dl-routines
87
88ifeq (yes,$(use-ldconfig))
89dl-routines += dl-cache
90endif
91
92ifneq (no,$(have-tunables))
93dl-routines += dl-tunables
94tunables-type = $(addprefix TUNABLES_FRONTEND_,$(have-tunables))
95CPPFLAGS-dl-tunables.c += -DTUNABLES_FRONTEND=$(tunables-type)
96
97ifeq (yesyes,$(build-shared)$(run-built-tests))
98tests-special += $(objpfx)list-tunables.out
99endif
100
101# Make sure that the compiler does not insert any library calls in tunables
102# code paths.
103ifeq (yes,$(have-loop-to-function))
104CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns
105endif
106endif
107
108all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
109# But they are absent from the shared libc, because that code is in ld.so.
110elide-routines.os = \
111  $(all-dl-routines) \
112  dl-early_allocate \
113  dl-exception \
114  dl-origin \
115  dl-reloc-static-pie \
116  dl-support \
117  dl-sysdep \
118  enbl-secure \
119  rtld_static_init \
120  thread_gscope_wait \
121  # elide-routines.os
122
123# These object files are only included in the dynamically-linked libc.
124shared-only-routines = libc-dl_find_object
125
126# ld.so uses those routines, plus some special stuff for being the program
127# interpreter and operating independent of libc.
128rtld-routines = \
129  $(all-dl-routines) \
130  dl-audit \
131  dl-compat \
132  dl-diagnostics \
133  dl-diagnostics-cpu \
134  dl-diagnostics-kernel \
135  dl-environ \
136  dl-error-minimal \
137  dl-hwcaps \
138  dl-hwcaps-subdirs \
139  dl-hwcaps_split \
140  dl-libc_freeres \
141  dl-minimal \
142  dl-mutex \
143  dl-sysdep \
144  dl-usage \
145  rtld \
146  # rtld-routines
147
148all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
149
150CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
151CFLAGS-dl-lookup.c += -fexceptions -fasynchronous-unwind-tables
152CFLAGS-dl-iteratephdr.c += $(uses-callbacks)
153
154# Called during static library initialization, so turn stack-protection
155# off for non-shared builds.
156CFLAGS-dl-minimal-malloc.o = $(no-stack-protector)
157CFLAGS-dl-minimal-malloc.op = $(no-stack-protector)
158
159# On targets without __builtin_memset, rtld.c uses a hand-coded loop
160# in _dl_start.  Make sure this isn't turned into a call to regular memset.
161ifeq (yes,$(have-loop-to-function))
162CFLAGS-rtld.c += -fno-tree-loop-distribute-patterns
163endif
164
165ifeq (yes,$(have-loop-to-function))
166# Likewise, during static library startup, memset is not yet available.
167CFLAGS-dl-support.c = -fno-tree-loop-distribute-patterns
168endif
169
170# Compile rtld itself without stack protection.
171# Also compile all routines in the static library that are elided from
172# the shared libc because they are in libc.a in the same way.
173
174CFLAGS-.o += $(call elide-stack-protector,.o,$(elide-routines.os))
175CFLAGS-.op += $(call elide-stack-protector,.op,$(elide-routines.os))
176CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines))
177
178# Add the requested compiler flags to the early startup code.
179CFLAGS-dl-printf.os += $(rtld-early-cflags)
180CFLAGS-dl-setup_hash.os += $(rtld-early-cflags)
181CFLAGS-dl-sysdep.os += $(rtld-early-cflags)
182CFLAGS-dl-tunables.os += $(rtld-early-cflags)
183CFLAGS-dl-write.os += $(rtld-early-cflags)
184CFLAGS-dl-writev.os += $(rtld-early-cflags)
185CFLAGS-rtld.os += $(rtld-early-cflags)
186
187ifeq ($(unwind-find-fde),yes)
188routines += unwind-dw2-fde-glibc
189shared-only-routines += unwind-dw2-fde-glibc
190endif
191
192before-compile  += $(objpfx)trusted-dirs.h
193generated	+= trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
194generated-dirs	+= for-renamed
195
196ifeq ($(build-shared),yes)
197ld-map		= $(common-objpfx)ld.map
198endif
199
200ifeq (yes,$(build-shared))
201extra-objs = \
202  $(all-rtld-routines:%=%.os) \
203  sofini.os \
204  interp.os \
205  # extra-objs
206generated += \
207  dl-allobjs.os \
208  ld.so ldd \
209  librtld.os \
210  # generated
211install-others	= $(inst_rtlddir)/$(rtld-installed-name) $(inst_bindir)/ld.so
212install-bin-script = ldd
213endif
214
215others		= sprof sln
216install-bin	= sprof
217others-static   = sln
218install-rootsbin = sln
219sln-modules	:= static-stubs
220extra-objs	+= $(sln-modules:=.o)
221
222ifeq (yes,$(use-ldconfig))
223ifeq (yes,$(build-shared))
224others-static	+= ldconfig
225others		+= ldconfig
226install-rootsbin += ldconfig
227
228ldconfig-modules := \
229  cache \
230  chroot_canon \
231  readlib \
232  static-stubs \
233  stringtable \
234  xmalloc \
235  xstrdup \
236  # ldconfig-modules
237extra-objs	+= $(ldconfig-modules:=.o)
238others-extras   = $(ldconfig-modules)
239endif
240endif
241
242# To find xmalloc.c and xstrdup.c
243vpath %.c ../locale/programs
244
245ifeq ($(build-shared),yes)
246extra-objs += sotruss-lib.os sotruss-lib.so
247install-others += $(inst_auditdir)/sotruss-lib.so
248install-bin-script += sotruss
249generated += sotruss
250libof-sotruss-lib = extramodules
251LDFLAGS-sotruss-lib.so += $(z-now-$(bind-now))
252$(objpfx)sotruss-lib.so: $(objpfx)sotruss-lib.os
253	$(build-module-asneeded)
254$(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
255	$(common-objpfx)libc_nonshared.a
256
257$(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
258	sed -e 's%@VERSION@%$(version)%g' \
259	    -e 's%@TEXTDOMAINDIR@%$(localedir)%g' \
260	    -e 's%@PREFIX@%$(prefix)%g' \
261	    -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
262	    -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
263	    < $< > $@.new
264	chmod 555 $@.new
265	mv -f $@.new $@
266$(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
267	$(do-install-program)
268endif
269
270tests-static-normal := \
271  tst-array1-static \
272  tst-array5-static \
273  tst-dl-iter-static \
274  tst-dst-static \
275  tst-env-setuid \
276  tst-env-setuid-tunables \
277  tst-getauxval-static \
278  tst-linkall-static \
279  tst-single_threaded-pthread-static \
280  tst-single_threaded-static \
281  tst-tls-allocation-failure-static \
282  tst-tlsalign-extern-static \
283  tst-tlsalign-static \
284  # tests-static-normal
285
286tests-static-internal := \
287  tst-dl_find_object-static \
288  tst-ptrguard1-static \
289  tst-stackguard1-static \
290  tst-tls1-static \
291  tst-tls1-static-non-pie \
292  # tests-static-internal
293
294CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o
295tst-tls1-static-non-pie-no-pie = yes
296
297tests-container := \
298  tst-ldconfig-bad-aux-cache \
299  tst-ldconfig-ld_so_conf-update \
300  # tests-container
301
302ifeq (no,$(build-hardcoded-path-in-tests))
303# This is an ld.so.cache test, and RPATH/RUNPATH in the executable
304# interferes with its test objectives.
305tests-container += tst-glibc-hwcaps-prepend-cache
306endif
307
308tests := \
309  tst-array1 \
310  tst-array2 \
311  tst-array3 \
312  tst-array4 \
313  tst-array5 \
314  tst-auxv \
315  tst-dl-hash \
316  tst-leaks1 \
317  tst-stringtable \
318  tst-tls9 \
319  # tests
320
321tests-internal := \
322  $(tests-static-internal) \
323  tst-tls1 \
324  # tests-internal
325
326tests-static := $(tests-static-normal) $(tests-static-internal)
327
328ifeq (yes,$(build-shared))
329tests-static += \
330  tst-single_threaded-static-dlopen \
331  tst-tls9-static \
332  # tests-static
333
334static-dlopen-environment = \
335  LD_LIBRARY_PATH=$(ld-library-path):$(common-objpfx)dlfcn
336tst-tls9-static-ENV = $(static-dlopen-environment)
337tst-single_threaded-static-dlopen-ENV = $(static-dlopen-environment)
338
339tests += \
340  argv0test \
341  constload1 \
342  dblload \
343  dblunload \
344  filter \
345  global \
346  initfirst \
347  lateglobal \
348  loadfail \
349  multiload \
350  next \
351  nodelete \
352  nodelete2 \
353  nodlopen \
354  nodlopen2 \
355  noload \
356  order \
357  order2 \
358  origtest \
359  preloadtest \
360  reldep \
361  reldep2 \
362  reldep3 \
363  reldep4 \
364  reldep5 \
365  reldep6 \
366  reldep7 \
367  reldep8 \
368  resolvfail \
369  restest1 \
370  restest2 \
371  tst-absolute-sym \
372  tst-absolute-zero \
373  tst-addr1 \
374  tst-align \
375  tst-align2 \
376  tst-align3 \
377  tst-audit1 \
378  tst-audit2 \
379  tst-audit8 \
380  tst-audit9 \
381  tst-audit11 \
382  tst-audit12 \
383  tst-audit13 \
384  tst-audit17 \
385  tst-audit18 \
386  tst-audit19b \
387  tst-audit20 \
388  tst-audit21 \
389  tst-audit22 \
390  tst-audit23 \
391  tst-audit24a \
392  tst-audit24b \
393  tst-audit24c \
394  tst-audit24d \
395  tst-audit25a \
396  tst-audit25b \
397  tst-audit28 \
398  tst-auditmany \
399  tst-auxobj \
400  tst-auxobj-dlopen \
401  tst-big-note \
402  tst-debug1 \
403  tst-deep1 \
404  tst-dl-is_dso \
405  tst-dlmodcount \
406  tst-dlmopen1 \
407  tst-dlmopen3 \
408  tst-dlmopen4 \
409  tst-dlmopen-dlerror \
410  tst-dlmopen-gethostbyname \
411  tst-dlopenfail \
412  tst-dlopenfail-2 \
413  tst-dlopenrpath \
414  tst-dlopen-self \
415  tst-dlopen-tlsmodid \
416  tst-dlsym-error \
417  tst-filterobj \
418  tst-filterobj-dlopen \
419  tst-glibc-hwcaps \
420  tst-glibc-hwcaps-mask \
421  tst-glibc-hwcaps-prepend \
422  tst-global1 \
423  tst-global2 \
424  tst-initfinilazyfail \
425  tst-initorder \
426  tst-initorder2 \
427  tst-latepthread \
428  tst-main1 \
429  tst-next-ver \
430  tst-nodelete2 \
431  tst-nodelete-dlclose \
432  tst-nodelete-opened \
433  tst-noload \
434  tst-null-argv \
435  tst-p_align1 \
436  tst-p_align2 \
437  tst-p_align3 \
438  tst-relsort1 \
439  tst-ro-dynamic \
440  tst-rtld-run-static \
441  tst-single_threaded \
442  tst-single_threaded-pthread \
443  tst-sonamemove-dlopen \
444  tst-sonamemove-link \
445  tst-thrlock \
446  tst-tls10 \
447  tst-tls11 \
448  tst-tls12 \
449  tst-tls13 \
450  tst-tls14 \
451  tst-tls15 \
452  tst-tls16 \
453  tst-tls17 \
454  tst-tls18 \
455  tst-tls19 \
456  tst-tls20 \
457  tst-tls21 \
458  tst-tls4 \
459  tst-tls5 \
460  tst-tlsalign \
461  tst-tlsalign-extern \
462  tst-tls-dlinfo \
463  tst-tls-ie \
464  tst-tls-ie-dlmopen \
465  tst-tls-manydynamic \
466  tst-unique1 \
467  tst-unique2 \
468  tst-unwind-ctor \
469  tst-unwind-main \
470  unload3 \
471  unload4 \
472  unload5 \
473  unload6 \
474  unload7 \
475  unload8 \
476  valgrind-test \
477  # tests
478tests-cxx = \
479  tst-dlopen-nodelete-reloc \
480  tst-nodelete \
481  tst-unique3 \
482  tst-unique4 \
483  # tests-cxx
484
485tests += $(if $(CXX),$(tests-cxx))
486
487tests-internal += \
488  circleload1 \
489  loadtest \
490  neededtest \
491  neededtest2 \
492  neededtest3 \
493  neededtest4 \
494  tst-audit19a \
495  tst-create_format1 \
496  tst-dl-hwcaps_split \
497  tst-dl_find_object \
498  tst-dl_find_object-threads \
499  tst-dlmopen2 \
500  tst-ptrguard1 \
501  tst-stackguard1 \
502  tst-tls-surplus \
503  tst-tls3 \
504  tst-tls6 \
505  tst-tls7 \
506  tst-tls8 \
507  unload \
508  unload2 \
509  # tests-internal
510
511tests-container += \
512  tst-dlopen-self-container \
513  tst-dlopen-tlsmodid-container \
514  tst-pldd \
515  tst-preload-pthread-libc \
516  # tests-container
517
518test-srcs = \
519  tst-pathopt \
520  # tests-srcs
521
522ifeq (yes,$(have-fpie))
523tests-pie += tst-align3
524endif
525selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
526
527ifneq ($(selinux-enabled),1)
528tests-execstack-yes = \
529  tst-execstack \
530  tst-execstack-needed \
531  tst-execstack-prog \
532  # tests-execstack-yes
533endif
534ifeq ($(have-depaudit),yes)
535tests += \
536  tst-audit14 \
537  tst-audit14a \
538  tst-audit15 \
539  tst-audit16 \
540  # tests
541ifeq ($(run-built-tests),yes)
542tests-special += \
543  $(objpfx)tst-audit14-cmp.out \
544  $(objpfx)tst-audit14a-cmp.out \
545  $(objpfx)tst-audit15-cmp.out \
546  $(objpfx)tst-audit16-cmp.out \
547  # tests-special
548endif
549endif
550ifeq ($(have-dt-relr),yes)
551tests += \
552  tst-relr \
553  tst-relr2 \
554  tst-relr3 \
555  tst-relr4 \
556# tests
557modules-names-dt-relr = \
558  tst-relr-mod2 \
559  tst-relr-mod3a \
560  tst-relr-mod3b \
561  tst-relr-mod4a \
562  tst-relr-mod4b \
563# modules-names-dt-relr
564modules-names += $(modules-names-dt-relr)
565# These shared libraries have special build rules.
566modules-names-nobuild += $(modules-names-dt-relr)
567ifeq ($(have-fpie),yes)
568tests += \
569  tst-relr-pie \
570# tests
571tests-pie += \
572  tst-relr-pie \
573# tests-pie
574tests-special += \
575  $(objpfx)check-tst-relr-pie.out \
576# tests-special
577endif
578CFLAGS-tst-relr-pie.c += $(pie-ccflag)
579LDFLAGS-tst-relr += -Wl,-z,pack-relative-relocs
580LDFLAGS-tst-relr-pie += -Wl,-z,pack-relative-relocs
581CFLAGS-tst-relr-mod2.c += $(no-stack-protector)
582CFLAGS-tst-relr-mod3a.c += $(no-stack-protector)
583CFLAGS-tst-relr-mod3b.c += $(no-stack-protector)
584CFLAGS-tst-relr-mod4a.c += $(no-stack-protector)
585CFLAGS-tst-relr-mod4b.c += $(no-stack-protector)
586endif
587endif
588
589tests-special += $(objpfx)tst-relro-ldso.out $(objpfx)tst-relro-libc.out
590$(objpfx)tst-relro-ldso.out: tst-relro-symbols.py $(..)/scripts/glibcelf.py \
591  $(objpfx)ld.so
592	$(PYTHON) tst-relro-symbols.py $(objpfx)ld.so \
593	  --required=_rtld_global_ro \
594	  > $@ 2>&1; $(evaluate-test)
595# The optional symbols are present in libc only if the architecture has
596# the GLIBC_2.0 symbol set in libc.
597$(objpfx)tst-relro-libc.out: tst-relro-symbols.py $(..)/scripts/glibcelf.py \
598  $(common-objpfx)libc.so
599	$(PYTHON) tst-relro-symbols.py $(common-objpfx)libc.so \
600	    --required=_IO_cookie_jumps \
601	    --required=_IO_file_jumps \
602	    --required=_IO_file_jumps_maybe_mmap \
603	    --required=_IO_file_jumps_mmap \
604	    --required=_IO_helper_jumps \
605	    --required=_IO_mem_jumps \
606	    --required=_IO_obstack_jumps \
607	    --required=_IO_proc_jumps \
608	    --required=_IO_str_chk_jumps \
609	    --required=_IO_str_jumps \
610	    --required=_IO_strn_jumps \
611	    --required=_IO_wfile_jumps \
612	    --required=_IO_wfile_jumps_maybe_mmap \
613	    --required=_IO_wfile_jumps_mmap \
614	    --required=_IO_wmem_jumps \
615	    --required=_IO_wstr_jumps \
616	    --required=_IO_wstrn_jumps \
617	    --optional=_IO_old_cookie_jumps \
618	    --optional=_IO_old_file_jumps \
619	    --optional=_IO_old_proc_jumps \
620	  > $@ 2>&1; $(evaluate-test)
621
622ifeq ($(run-built-tests),yes)
623tests-special += $(objpfx)tst-valgrind-smoke.out
624endif
625$(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)valgrind-test
626	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
627		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
628
629tests += $(tests-execstack-$(have-z-execstack))
630ifeq ($(run-built-tests),yes)
631tests-special += \
632  $(objpfx)noload-mem.out \
633  $(objpfx)tst-ldconfig-X.out \
634  $(objpfx)tst-leaks1-mem.out \
635  $(objpfx)tst-rtld-help.out \
636  # tests-special
637endif
638tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
639tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
640tlsmod17a-modules = $(addprefix tst-tlsmod17a, $(tlsmod17a-suffixes))
641tlsmod18a-modules = $(addprefix tst-tlsmod18a, $(tlsmod17a-suffixes))
642one-hundred = $(foreach x,0 1 2 3 4 5 6 7 8 9, \
643  0$x 1$x 2$x 3$x 4$x 5$x 6$x 7$x 8$x 9$x)
644tst-tls-many-dynamic-modules := \
645  $(foreach n,$(one-hundred),tst-tls-manydynamic$(n)mod)
646tst-tls-many-dynamic-modules-dep-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \
647					    14 15 16 17 18 19
648tst-tls-many-dynamic-modules-dep = \
649  $(foreach n,$(tst-tls-many-dynamic-modules-dep-suffixes),tst-tls-manydynamic$(n)mod-dep)
650tst-tls-many-dynamic-modules-dep-bad-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
651tst-tls-many-dynamic-modules-dep-bad = \
652  $(foreach n,$(tst-tls-many-dynamic-modules-dep-bad-suffixes),tst-tls-manydynamic$(n)mod-dep-bad)
653extra-test-objs += \
654  $(tlsmod17a-modules:=.os) \
655  $(tlsmod18a-modules:=.os) \
656  tst-tlsalign-vars.o \
657  # extra-test-objs
658test-extras += \
659  tst-tlsalign-vars \
660  tst-tlsmod17a \
661  tst-tlsmod18a \
662  # test-extras
663modules-names += \
664  circlemod1 \
665  circlemod1a \
666  circlemod2 \
667  circlemod2a \
668  circlemod3 \
669  circlemod3a \
670  constload2 \
671  constload3 \
672  dblloadmod1 \
673  dblloadmod2 \
674  dblloadmod3 \
675  dep1 \
676  dep2 \
677  dep3 \
678  dep4 \
679  failobj \
680  filtmod1 \
681  filtmod2 \
682  firstobj \
683  globalmod1 \
684  libmarkermod1-1 \
685  libmarkermod1-2 \
686  libmarkermod1-3 \
687  libmarkermod2-1 \
688  libmarkermod2-2 \
689  libmarkermod3-1 \
690  libmarkermod3-2 \
691  libmarkermod3-3 \
692  libmarkermod4-1 \
693  libmarkermod4-2 \
694  libmarkermod4-3 \
695  libmarkermod4-4 \
696  libmarkermod5-1 \
697  libmarkermod5-2 \
698  libmarkermod5-3 \
699  libmarkermod5-4 \
700  libmarkermod5-5 \
701  libtracemod1-1 \
702  libtracemod2-1 \
703  libtracemod3-1 \
704  libtracemod4-1 \
705  libtracemod5-1 \
706  ltglobmod1 \
707  ltglobmod2 \
708  neededobj1 \
709  neededobj2 \
710  neededobj3 \
711  neededobj4 \
712  neededobj5 \
713  neededobj6 \
714  nextmod1 \
715  nextmod2 \
716  nextmod3 \
717  nodel2mod1 \
718  nodel2mod2 \
719  nodel2mod3 \
720  nodelmod1 \
721  nodelmod2 \
722  nodelmod3 \
723  nodelmod4 \
724  nodlopenmod \
725  nodlopenmod2 \
726  order2mod1 \
727  order2mod2 \
728  order2mod3 \
729  order2mod4 \
730  pathoptobj \
731  reldep4mod1 \
732  reldep4mod2 \
733  reldep4mod3 \
734  reldep4mod4 \
735  reldep6mod0 \
736  reldep6mod1 \
737  reldep6mod2 \
738  reldep6mod3 \
739  reldep6mod4 \
740  reldep7mod1 \
741  reldep7mod2 \
742  reldep8mod1 \
743  reldep8mod2 \
744  reldep8mod3 \
745  reldep9mod1 \
746  reldep9mod2 \
747  reldep9mod3 \
748  reldepmod1 \
749  reldepmod2 \
750  reldepmod3 \
751  reldepmod4 \
752  reldepmod5 \
753  reldepmod6 \
754  testobj1 \
755  testobj1_1 \
756  testobj2 \
757  testobj3 \
758  testobj4 \
759  testobj5 \
760  testobj6 \
761  tst-absolute-sym-lib \
762  tst-absolute-zero-lib \
763  tst-alignmod \
764  tst-alignmod2 \
765  tst-alignmod3 \
766  tst-array2dep \
767  tst-array5dep \
768  tst-audit11mod1 \
769  tst-audit11mod2 \
770  tst-audit12mod1 \
771  tst-audit12mod2 \
772  tst-audit12mod3 \
773  tst-audit13mod1 \
774  tst-audit18mod \
775  tst-audit19bmod \
776  tst-audit23mod \
777  tst-audit24amod1 \
778  tst-audit24amod2 \
779  tst-audit24bmod1 \
780  tst-audit24bmod2 \
781  tst-audit24dmod1 \
782  tst-audit24dmod2 \
783  tst-audit24dmod3 \
784  tst-audit24dmod4 \
785  tst-audit25mod1 \
786  tst-audit25mod2 \
787  tst-audit25mod3 \
788  tst-audit25mod4 \
789  tst-auditlogmod-1 \
790  tst-auditlogmod-2 \
791  tst-auditlogmod-3 \
792  tst-auditmanymod1 \
793  tst-auditmanymod2 \
794  tst-auditmanymod3 \
795  tst-auditmanymod4 \
796  tst-auditmanymod5 \
797  tst-auditmanymod6 \
798  tst-auditmanymod7 \
799  tst-auditmanymod8 \
800  tst-auditmanymod9 \
801  tst-auditmod1 \
802  tst-auditmod9a \
803  tst-auditmod9b \
804  tst-auditmod11 \
805  tst-auditmod12 \
806  tst-auditmod18 \
807  tst-auditmod19a \
808  tst-auditmod19b \
809  tst-auditmod20 \
810  tst-auditmod21a \
811  tst-auditmod21b \
812  tst-auditmod22 \
813  tst-auditmod23 \
814  tst-auditmod24a \
815  tst-auditmod24b \
816  tst-auditmod24c \
817  tst-auditmod24d \
818  tst-auditmod25 \
819  tst-auditmod28 \
820  tst-auxvalmod \
821  tst-big-note-lib \
822  tst-deep1mod1 \
823  tst-deep1mod2 \
824  tst-deep1mod3 \
825  tst-dl_find_object-mod1 \
826  tst-dl_find_object-mod2 \
827  tst-dl_find_object-mod3 \
828  tst-dl_find_object-mod4 \
829  tst-dl_find_object-mod5 \
830  tst-dl_find_object-mod6 \
831  tst-dl_find_object-mod7 \
832  tst-dl_find_object-mod8 \
833  tst-dl_find_object-mod9 \
834  tst-dlmopen1mod \
835  tst-dlmopen-dlerror-mod \
836  tst-dlmopen-gethostbyname-mod \
837  tst-dlopenfaillinkmod \
838  tst-dlopenfailmod1 \
839  tst-dlopenfailmod2 \
840  tst-dlopenfailmod3 \
841  tst-dlopenfailnodelmod \
842  tst-dlopenrpathmod \
843  tst-filterobj-aux \
844  tst-filterobj-filtee \
845  tst-filterobj-flt \
846  tst-finilazyfailmod \
847  tst-globalmod2 \
848  tst-initlazyfailmod \
849  tst-initorder2a \
850  tst-initorder2b \
851  tst-initorder2c \
852  tst-initorder2d \
853  tst-initordera1 \
854  tst-initordera2 \
855  tst-initordera3 \
856  tst-initordera4 \
857  tst-initorderb1 \
858  tst-initorderb2 \
859  tst-latepthreadmod \
860  tst-ldconfig-ld-mod \
861  tst-main1mod \
862  tst-nodelete2mod \
863  tst-nodelete-dlclose-dso \
864  tst-nodelete-dlclose-plugin \
865  tst-nodelete-opened-lib \
866  tst-null-argv-lib \
867  tst-p_alignmod-base \
868  tst-p_alignmod3 \
869  tst-relsort1mod1 \
870  tst-relsort1mod2 \
871  tst-ro-dynamic-mod \
872  tst-single_threaded-mod1 \
873  tst-single_threaded-mod2 \
874  tst-single_threaded-mod3 \
875  tst-single_threaded-mod4 \
876  tst-sonamemove-linkmod1 \
877  tst-sonamemove-runmod1 \
878  tst-sonamemove-runmod2 \
879  tst-tls19mod1 \
880  tst-tls19mod2 \
881  tst-tls19mod3 \
882  tst-tls20mod-bad \
883  tst-tls21mod \
884  tst-tlsalign-lib \
885  tst-tls-ie-mod0 \
886  tst-tls-ie-mod1 \
887  tst-tls-ie-mod2 \
888  tst-tls-ie-mod3 \
889  tst-tls-ie-mod4 \
890  tst-tls-ie-mod5 \
891  tst-tls-ie-mod6 \
892  tst-tlsmod1 \
893  tst-tlsmod10 \
894  tst-tlsmod11 \
895  tst-tlsmod12 \
896  tst-tlsmod13 \
897  tst-tlsmod13a \
898  tst-tlsmod14a \
899  tst-tlsmod14b \
900  tst-tlsmod15a \
901  tst-tlsmod15b \
902  tst-tlsmod16a \
903  tst-tlsmod16b \
904  tst-tlsmod17b \
905  tst-tlsmod2 \
906  tst-tlsmod3 \
907  tst-tlsmod4 \
908  tst-tlsmod5 \
909  tst-tlsmod6 \
910  tst-tlsmod7 \
911  tst-tlsmod8 \
912  tst-tlsmod9 \
913  tst-unique1mod1 \
914  tst-unique1mod2 \
915  tst-unique2mod1 \
916  tst-unique2mod2 \
917  tst-unwind-ctor-lib \
918  unload2dep \
919  unload2mod \
920  unload3mod1 \
921  unload3mod2 \
922  unload3mod3 \
923  unload3mod4 \
924  unload4mod1 \
925  unload4mod2 \
926  unload4mod3 \
927  unload4mod4 \
928  unload6mod1 \
929  unload6mod2 \
930  unload6mod3 \
931  unload7mod1 \
932  unload7mod2 \
933  unload8mod1 \
934  unload8mod1x \
935  unload8mod2 \
936  unload8mod3 \
937  unloadmod \
938  vismod1 \
939  vismod2 \
940  vismod3 \
941# modules-names
942
943modules-names-cxx = \
944  tst-dlopen-nodelete-reloc-mod1 \
945  tst-dlopen-nodelete-reloc-mod10 \
946  tst-dlopen-nodelete-reloc-mod11 \
947  tst-dlopen-nodelete-reloc-mod12 \
948  tst-dlopen-nodelete-reloc-mod13 \
949  tst-dlopen-nodelete-reloc-mod14 \
950  tst-dlopen-nodelete-reloc-mod15 \
951  tst-dlopen-nodelete-reloc-mod16 \
952  tst-dlopen-nodelete-reloc-mod17 \
953  tst-dlopen-nodelete-reloc-mod2 \
954  tst-dlopen-nodelete-reloc-mod3 \
955  tst-dlopen-nodelete-reloc-mod4 \
956  tst-dlopen-nodelete-reloc-mod5 \
957  tst-dlopen-nodelete-reloc-mod6 \
958  tst-dlopen-nodelete-reloc-mod7 \
959  tst-dlopen-nodelete-reloc-mod8 \
960  tst-dlopen-nodelete-reloc-mod9 \
961  tst-nodelete-rtldmod \
962  tst-nodelete-uniquemod \
963  tst-nodelete-zmod \
964  tst-unique3lib \
965  tst-unique3lib2 \
966  tst-unique4lib \
967  # modules-names-cxx
968
969modules-names += \
970  $(if $(CXX),$(modules-names-cxx)) \
971  $(modules-execstack-$(have-z-execstack)) \
972  $(tlsmod17a-modules) \
973  $(tlsmod18a-modules) \
974  $(tst-tls-many-dynamic-modules) \
975  $(tst-tls-many-dynamic-modules-dep) \
976  $(tst-tls-many-dynamic-modules-dep-bad) \
977  # modules-names
978
979# Most modules build with _ISOMAC defined, but those filtered out
980# depend on internal headers.
981modules-names-tests = $(filter-out ifuncmod% tst-tlsmod%,\
982				   $(modules-names))
983
984# For +depfiles in Makerules.
985extra-test-objs += tst-auditmod17.os
986
987ifeq (yes,$(have-mtls-dialect-gnu2))
988tests += tst-gnu2-tls1
989modules-names += tst-gnu2-tls1mod
990$(objpfx)tst-gnu2-tls1: $(objpfx)tst-gnu2-tls1mod.so
991tst-gnu2-tls1mod.so-no-z-defs = yes
992CFLAGS-tst-gnu2-tls1mod.c += -mtls-dialect=gnu2
993
994tests += tst-audit-tlsdesc tst-audit-tlsdesc-dlopen
995modules-names += tst-audit-tlsdesc-mod1 tst-audit-tlsdesc-mod2 tst-auditmod-tlsdesc
996$(objpfx)tst-audit-tlsdesc: $(objpfx)tst-audit-tlsdesc-mod1.so \
997			    $(objpfx)tst-audit-tlsdesc-mod2.so \
998			    $(shared-thread-library)
999CFLAGS-tst-audit-tlsdesc-mod1.c += -mtls-dialect=gnu2
1000CFLAGS-tst-audit-tlsdesc-mod2.c += -mtls-dialect=gnu2
1001$(objpfx)tst-audit-tlsdesc-dlopen: $(shared-thread-library)
1002$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-audit-tlsdesc-mod1.so \
1003				       $(objpfx)tst-audit-tlsdesc-mod2.so
1004$(objpfx)tst-audit-tlsdesc-mod1.so: $(objpfx)tst-audit-tlsdesc-mod2.so
1005$(objpfx)tst-audit-tlsdesc.out: $(objpfx)tst-auditmod-tlsdesc.so
1006tst-audit-tlsdesc-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
1007$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-auditmod-tlsdesc.so
1008tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
1009endif
1010ifeq (yes,$(have-protected-data))
1011modules-names += tst-protected1moda tst-protected1modb
1012tests += tst-protected1a tst-protected1b
1013$(objpfx)tst-protected1a: $(addprefix $(objpfx),tst-protected1moda.so tst-protected1modb.so)
1014$(objpfx)tst-protected1b: $(addprefix $(objpfx),tst-protected1modb.so tst-protected1moda.so)
1015tst-protected1modb.so-no-z-defs = yes
1016# These tests fail with GCC versions prior to 5.1 and with some versions
1017# of binutils.  See https://sourceware.org/bugzilla/show_bug.cgi?id=17709
1018# and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 for details.
1019# Perhaps in future we can make these XFAILs conditional on some detection
1020# of compiler/linker behavior/version.
1021test-xfail-tst-protected1a = yes
1022test-xfail-tst-protected1b = yes
1023endif
1024ifeq (yesyes,$(have-fpie)$(build-shared))
1025modules-names += tst-piemod1
1026tests += tst-pie1 tst-pie2 tst-dlopen-pie tst-dlopen-tlsmodid-pie \
1027  tst-dlopen-self-pie
1028tests-pie += tst-pie1 tst-pie2 tst-dlopen-tlsmodid-pie tst-dlopen-self-pie
1029ifeq (yes,$(have-protected-data))
1030tests += vismain
1031tests-pie += vismain
1032CFLAGS-vismain.c += $(PIE-ccflag)
1033endif
1034endif
1035modules-execstack-yes = tst-execstack-mod
1036extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
1037
1038# filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
1039# rules.
1040modules-names-nobuild += \
1041  filtmod1 \
1042  tst-audit24bmod1 \
1043  tst-audit24bmod2 \
1044  tst-big-note-lib \
1045  tst-ro-dynamic-mod \
1046# modules-names-nobuild
1047
1048tests += $(tests-static)
1049
1050ifeq (yes,$(have-ifunc))
1051tests-ifuncstatic := \
1052  ifuncmain1static \
1053  ifuncmain1picstatic \
1054  ifuncmain2static \
1055  ifuncmain2picstatic \
1056  ifuncmain4static \
1057  ifuncmain4picstatic \
1058  ifuncmain5static \
1059  ifuncmain5picstatic \
1060  ifuncmain7static \
1061  ifuncmain7picstatic \
1062  # tests-ifuncstatic
1063ifeq (yes,$(have-gcc-ifunc))
1064tests-ifuncstatic += ifuncmain9static ifuncmain9picstatic
1065endif
1066tests-static += $(tests-ifuncstatic)
1067tests-internal += $(tests-ifuncstatic)
1068ifeq (yes,$(build-shared))
1069tests += \
1070  tst-ifunc-fault-bindnow \
1071  tst-ifunc-fault-lazy \
1072  # tests
1073# Note: sysdeps/x86_64/ifuncmain8.c uses ifuncmain8.
1074tests-internal += \
1075  ifuncmain1pic \
1076  ifuncmain1staticpic \
1077  ifuncmain1vis \
1078  ifuncmain1vispic \
1079  ifuncmain2 \
1080  ifuncmain2pic \
1081  ifuncmain3 \
1082  ifuncmain4 \
1083  ifuncmain5staticpic \
1084  ifuncmain7 \
1085  ifuncmain7pic \
1086  # tests-internal
1087ifeq (no,$(with-lld))
1088tests-internal += \
1089  ifuncmain1 \
1090  ifuncmain5 \
1091  ifuncmain5pic \
1092  # tests-internal
1093endif
1094ifeq (yes,$(have-gcc-ifunc))
1095tests-internal += \
1096  ifuncmain9 \
1097  ifuncmain9pic \
1098  # tests-internal
1099endif
1100ifunc-test-modules = \
1101  ifuncdep1 \
1102  ifuncdep1pic \
1103  ifuncdep2 \
1104  ifuncdep2pic \
1105  ifuncdep5 \
1106  ifuncdep5pic \
1107  # ifunc-test-modules
1108extra-test-objs += $(ifunc-test-modules:=.o)
1109test-internal-extras += $(ifunc-test-modules)
1110ifeq (yes,$(have-fpie))
1111ifunc-pie-tests = \
1112  ifuncmain1pie \
1113  ifuncmain1staticpie \
1114  ifuncmain1vispie \
1115  ifuncmain6pie \
1116  ifuncmain7pie \
1117  # ifunc-pie-tests
1118ifeq (yes,$(have-gcc-ifunc))
1119ifunc-pie-tests += ifuncmain9pie
1120endif
1121ifeq (no,$(with-lld))
1122ifunc-pie-tests += ifuncmain5pie
1123endif
1124ifeq (yes,$(have-textrel_ifunc))
1125ifunc-pie-tests += tst-ifunc-textrel
1126endif
1127tests-internal += $(ifunc-pie-tests)
1128tests-pie += $(ifunc-pie-tests)
1129endif
1130modules-names += \
1131  ifuncmod1 \
1132  ifuncmod3 \
1133  ifuncmod6 \
1134  # module-names
1135ifeq (no,$(with-lld))
1136modules-names += ifuncmod5
1137endif
1138endif
1139endif
1140
1141ifeq (yes,$(build-shared))
1142ifeq ($(run-built-tests),yes)
1143tests-special += \
1144  $(objpfx)argv0test.out \
1145  $(objpfx)tst-pathopt.out \
1146  $(objpfx)tst-rtld-help.out \
1147  $(objpfx)tst-rtld-load-self.out \
1148  $(objpfx)tst-rtld-preload.out \
1149  # tests-special
1150endif
1151tests-special += \
1152  $(objpfx)check-execstack.out \
1153  $(objpfx)check-initfini.out \
1154  $(objpfx)check-localplt.out \
1155  $(objpfx)check-textrel.out \
1156  $(objpfx)check-wx-segment.out \
1157  # tests-special
1158endif
1159
1160ifeq ($(run-built-tests),yes)
1161tests-special += \
1162  $(objpfx)order-cmp.out \
1163  $(objpfx)order2-cmp.out \
1164  $(objpfx)tst-array1-cmp.out \
1165  $(objpfx)tst-array1-static-cmp.out \
1166  $(objpfx)tst-array2-cmp.out \
1167  $(objpfx)tst-array3-cmp.out \
1168  $(objpfx)tst-array4-cmp.out \
1169  $(objpfx)tst-array5-cmp.out \
1170  $(objpfx)tst-array5-static-cmp.out \
1171  $(objpfx)tst-initorder-cmp.out \
1172  $(objpfx)tst-initorder2-cmp.out \
1173  $(objpfx)tst-unused-dep-cmp.out \
1174  $(objpfx)tst-unused-dep.out \
1175  $(objpfx)tst-trace1.out \
1176  $(objpfx)tst-trace2.out \
1177  $(objpfx)tst-trace3.out \
1178  $(objpfx)tst-trace4.out \
1179  $(objpfx)tst-trace5.out \
1180  # tests-special
1181endif
1182
1183ifndef avoid-generated
1184# DSO sorting tests:
1185# The dso-ordering-test.py script generates testcase source files in $(objpfx),
1186# creating a $(objpfx)<testcase-name>-dir for each testcase, and creates a
1187# Makefile fragment to be included.
1188define include_dsosort_tests
1189$(objpfx)$(1).generated-makefile: $(1)
1190	$(PYTHON) $(..)scripts/dso-ordering-test.py \
1191	--description-file $$< --objpfx $(objpfx) --output-makefile $$@T
1192	mv $$@T $$@
1193-include $(objpfx)$(1).generated-makefile
1194endef
1195endif
1196
1197postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
1198		       $(objpfx)/dso-sort-tests-2.generated-makefile
1199
1200# Generate from each testcase description file
1201ifeq (yes,$(have-tunables))
1202$(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
1203$(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
1204endif
1205
1206check-abi: $(objpfx)check-abi-ld.out \
1207	   $(objpfx)check-abi-version-libc.out
1208tests-special += \
1209  $(objpfx)check-abi-ld.out \
1210  $(objpfx)check-abi-version-libc.out \
1211# tests-special
1212update-abi: update-abi-ld
1213update-all-abi: update-all-abi-ld
1214
1215tests-special += $(objpfx)tst-glibcelf.out
1216$(objpfx)tst-glibcelf.out: tst-glibcelf.py elf.h $(..)/scripts/glibcelf.py \
1217  $(..)/scripts/glibcextract.py
1218	PYTHONPATH=$(..)scripts $(PYTHON) tst-glibcelf.py \
1219          --cc="$(CC) $(patsubst -DMODULE_NAME=%,-DMODULE_NAME=testsuite,$(CPPFLAGS))" \
1220	  < /dev/null > $@ 2>&1; $(evaluate-test)
1221
1222ifeq ($(run-built-tests),yes)
1223tests-special += $(objpfx)tst-tls-allocation-failure-static-patched.out
1224endif
1225
1226# The test requires shared _and_ PIE because the executable
1227# unit test driver must be able to link with the shared object
1228# that is going to eventually go into an installed DSO.
1229ifeq (yesyes,$(have-fpie)$(build-shared))
1230tests-internal += tst-_dl_addr_inside_object
1231tests-pie += tst-_dl_addr_inside_object
1232$(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os
1233CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag)
1234endif
1235
1236# We can only test static libcrypt use if libcrypt has been built,
1237# and either NSS crypto is not in use, or static NSS libraries are
1238# available.
1239ifeq ($(build-crypt),no)
1240CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=0
1241else
1242ifeq ($(nss-crypt),no)
1243CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=1
1244else
1245ifeq ($(static-nss-crypt),no)
1246CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=0
1247else
1248CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=1
1249endif
1250endif
1251endif
1252
1253include ../Rules
1254
1255ifeq (yes,$(build-shared))
1256# Make sure these things are built in the `make lib' pass so they can be used
1257# to run programs during the `make others' pass.
1258lib-noranlib: $(objpfx)$(rtld-installed-name) \
1259	      $(addprefix $(objpfx),$(extra-objs))
1260endif
1261
1262# Command to link into a larger single relocatable object.
1263reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
1264
1265$(objpfx)sotruss-lib.so: $(shlib-lds)
1266
1267$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
1268	$(reloc-link) -o $@ $^
1269
1270# Link together the dynamic linker into a single relocatable object.
1271# First we do a link against libc_pic.a just to get a link map,
1272# and discard the object produced by that link.  From the link map
1273# we can glean all the libc modules that need to go into the dynamic
1274# linker.  Then we do a recursive make that goes into all the subdirs
1275# those modules come from and builds special rtld-foo.os versions that
1276# are compiled with special flags, and puts these modules into rtld-libc.a
1277# for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.
1278
1279# These symbols need to be stubbed out during symbol discovery because
1280# their implementation is provided differently in rtld, and the symbol
1281# discovery mechanism is not compatible with the libc implementation
1282# when compiled for libc.
1283rtld-stubbed-symbols = \
1284  __GI___pthread_disable_asynccancel \
1285  __GI___pthread_enable_asynccancel \
1286  __pthread_disable_asynccancel \
1287  __pthread_enable_asynccancel \
1288  calloc \
1289  free \
1290  malloc \
1291  realloc \
1292  # rtld-stubbed-symbols
1293
1294ifeq ($(have-ssp),yes)
1295# rtld is not built with the stack protector, so these references will
1296# go away in the rebuilds.
1297rtld-stubbed-symbols += __stack_chk_fail __stack_chk_fail_local
1298endif
1299
1300$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
1301	@-rm -f $@T
1302	for symbol in $(rtld-stubbed-symbols); do \
1303		echo ".globl $$symbol"; \
1304		echo "$$symbol:"; \
1305	done | $(CC) -o $@T.o $(ASFLAGS) -c -x assembler -
1306	$(reloc-link) -o $@.o $@T.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
1307	rm -f %@T.o $@.o
1308	mv -f $@T $@
1309
1310# For lld, skip preceding addresses and values before matching the archive and the member.
1311$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
1312	LC_ALL=C \
1313	sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
1314	    $< | \
1315	while read lib file; do \
1316	  case $$lib in \
1317	  libc_pic.a) \
1318	    LC_ALL=C grep -F -l /$$file \
1319		  $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
1320	    LC_ALL=C \
1321	    sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
1322	    ;; \
1323	  */*.a) \
1324	    echo rtld-$${lib%%/*} += $$file ;; \
1325	  *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
1326	  esac; \
1327	done > $@T
1328	echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
1329			     | LC_ALL=C sort -u` >> $@T
1330	mv -f $@T $@
1331
1332$(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
1333	$(MAKE) -f $< -f rtld-Rules
1334
1335$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
1336	$(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
1337		  -Wl,-Map,$@.map
1338
1339generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
1340
1341z-now-yes = -Wl,-z,now
1342
1343$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
1344# Link into a temporary file so that we don't touch $@ at all
1345# if the sanity check below fails.
1346	$(LINK.o) -nostdlib -nostartfiles -shared -o $@.new		\
1347		  $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))	\
1348		  $(dt-relr-ldflag) \
1349		  $(filter-out $(map-file),$^) $(load-map-file)		\
1350		  -Wl,-soname=$(rtld-installed-name)
1351	$(call after-link,$@.new)
1352	$(READELF) -s $@.new \
1353	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
1354	mv -f $@.new $@
1355
1356ifeq (yes,$(build-shared))
1357# interp.c exists just to get the runtime linker path into libc.so.
1358$(objpfx)interp.os: $(common-objpfx)runtime-linker.h
1359endif
1360
1361ifneq (ld.so,$(rtld-installed-name))
1362# Make sure ld.so.1 exists in the build directory so we can link
1363# against it.
1364$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
1365	$(make-link)
1366generated += $(rtld-installed-name)
1367endif
1368
1369# Build a file mentioning all trustworthy directories to look for shared
1370# libraries when using LD_LIBRARY_PATH in a setuid program.  The user can
1371# add directories to the list by defining $(user-defined-trusted-dirs)
1372# before starting make.
1373$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
1374$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1375	$(make-target-directory)
1376	echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))"    \
1377	| $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
1378	echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
1379	$(move-if-change) ${@:st=T} ${@:st=h}
1380	touch $@
1381CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
1382
1383ifeq (yes,$(build-shared))
1384$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force)
1385	$(make-target-directory)
1386	$(do-install-program)
1387
1388# Creates the relative /usr/bin/ld.so symbolic link.
1389$(inst_bindir)/ld.so: $(inst_rtlddir)/$(rtld-installed-name)
1390	$(make-target-directory)
1391	$(make-link)
1392
1393# Special target called by parent to install just the dynamic linker.
1394.PHONY: ldso_install
1395ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
1396endif # $(build-shared)
1397
1398
1399# Workarounds for ${exec_prefix} expansion in configure variables.
1400# config.status cannot be used directly for processing ldd.bash.in or
1401# expanding variables such as sysconfdir because the expansion
1402# contains the literal string ${exec_prefix}, which is not valid in C
1403# headers or installed shell scripts.
1404
1405ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
1406	      -e 's%@VERSION@%$(version)%g' \
1407	      -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
1408	      -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
1409	      -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
1410
1411ifeq ($(ldd-rewrite-script),no)
1412define gen-ldd
1413LC_ALL=C sed $(ldd-rewrite) < $< > $@.new
1414endef
1415else
1416define gen-ldd
1417LC_ALL=C sed $(ldd-rewrite) < $< \
1418| LC_ALL=C sed -f $(patsubst $(..)/%,/%,$(..)$(ldd-rewrite-script)) > $@.new
1419endef
1420endif
1421
1422$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
1423	      $(common-objpfx)config.make
1424	$(gen-ldd)
1425	chmod 555 $@.new
1426	mv -f $@.new $@
1427
1428$(objpfx)sln: $(sln-modules:%=$(objpfx)%.o)
1429
1430$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
1431
1432SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
1433CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
1434		    -D'SLIBDIR="$(slibdir)"'
1435libof-ldconfig = ldconfig
1436CFLAGS-dl-cache.c += $(SYSCONF-FLAGS)
1437CFLAGS-cache.c += $(SYSCONF-FLAGS)
1438CFLAGS-rtld.c += $(SYSCONF-FLAGS)
1439CFLAGS-dl-usage.c += $(SYSCONF-FLAGS) \
1440  -D'RTLD="$(rtlddir)/$(rtld-installed-name)"'
1441CFLAGS-dl-diagnostics.c += $(SYSCONF-FLAGS) \
1442  -D'PREFIX="$(prefix)"' \
1443  -D'RTLD="$(rtlddir)/$(rtld-installed-name)"'
1444
1445cpp-srcs-left := $(all-rtld-routines:=.os)
1446lib := rtld
1447include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
1448
1449test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
1450generated += $(addsuffix .so,$(strip $(modules-names)))
1451
1452$(objpfx)testobj1_1.so: $(objpfx)testobj1.so
1453$(objpfx)testobj2.so: $(objpfx)testobj1.so
1454$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so
1455$(objpfx)failobj.so: $(objpfx)testobj6.so
1456$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
1457$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
1458$(objpfx)dep4.so: $(objpfx)dep3.so
1459$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
1460$(objpfx)neededobj2.so: $(objpfx)neededobj1.so
1461$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so
1462$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
1463			$(objpfx)neededobj3.so
1464$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
1465$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
1466$(objpfx)firstobj.so: $(shared-thread-library)
1467$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
1468$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
1469$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
1470$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
1471$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
1472$(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
1473$(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
1474$(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
1475$(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
1476$(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
1477$(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
1478$(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
1479$(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
1480$(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
1481$(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
1482# For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
1483$(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
1484$(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
1485$(objpfx)tst-tls19mod1.so: $(objpfx)tst-tls19mod2.so $(objpfx)tst-tls19mod3.so
1486$(objpfx)tst-tls19mod3.so: $(objpfx)ld.so
1487$(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
1488$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
1489$(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
1490$(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
1491$(objpfx)unload3mod1.so: $(objpfx)unload3mod3.so
1492$(objpfx)unload3mod2.so: $(objpfx)unload3mod3.so
1493$(objpfx)unload3mod3.so: $(objpfx)unload3mod4.so
1494$(objpfx)unload4mod1.so: $(objpfx)unload4mod2.so $(objpfx)unload4mod3.so
1495$(objpfx)unload4mod2.so: $(objpfx)unload4mod4.so $(objpfx)unload4mod3.so
1496$(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
1497$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
1498$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
1499$(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
1500$(objpfx)tst-initorderb2.so: $(objpfx)tst-initorderb1.so $(objpfx)tst-initordera2.so
1501$(objpfx)tst-initordera3.so: $(objpfx)tst-initorderb2.so $(objpfx)tst-initorderb1.so
1502$(objpfx)tst-initordera4.so: $(objpfx)tst-initordera3.so
1503$(objpfx)tst-initorder: $(objpfx)tst-initordera4.so $(objpfx)tst-initordera1.so $(objpfx)tst-initorderb2.so
1504$(objpfx)tst-null-argv: $(objpfx)tst-null-argv-lib.so
1505$(objpfx)tst-tlsalign: $(objpfx)tst-tlsalign-lib.so
1506$(objpfx)tst-nodelete-opened.out: $(objpfx)tst-nodelete-opened-lib.so
1507
1508$(objpfx)tst-tlsalign-extern: $(objpfx)tst-tlsalign-vars.o
1509$(objpfx)tst-tlsalign-extern-static: $(objpfx)tst-tlsalign-vars.o
1510
1511tst-null-argv-ENV = LD_DEBUG=all LD_DEBUG_OUTPUT=$(objpfx)tst-null-argv.debug.out
1512LDFLAGS-nodel2mod3.so = -Wl,--no-as-needed
1513LDFLAGS-reldepmod5.so = -Wl,--no-as-needed
1514LDFLAGS-reldep6mod1.so = -Wl,--no-as-needed
1515LDFLAGS-reldep6mod4.so = -Wl,--no-as-needed
1516LDFLAGS-reldep8mod3.so = -Wl,--no-as-needed
1517LDFLAGS-unload4mod1.so = -Wl,--no-as-needed
1518LDFLAGS-unload4mod2.so = -Wl,--no-as-needed
1519LDFLAGS-tst-initorder = -Wl,--no-as-needed
1520LDFLAGS-tst-initordera2.so = -Wl,--no-as-needed
1521LDFLAGS-tst-initordera3.so = -Wl,--no-as-needed
1522LDFLAGS-tst-initordera4.so = -Wl,--no-as-needed
1523LDFLAGS-tst-initorderb2.so = -Wl,--no-as-needed
1524LDFLAGS-tst-tlsmod5.so = -nostdlib -Wl,--no-as-needed
1525LDFLAGS-tst-tlsmod6.so = -nostdlib -Wl,--no-as-needed
1526
1527testobj1.so-no-z-defs = yes
1528testobj3.so-no-z-defs = yes
1529testobj4.so-no-z-defs = yes
1530testobj5.so-no-z-defs = yes
1531testobj6.so-no-z-defs = yes
1532failobj.so-no-z-defs = yes
1533constload2.so-no-z-defs = yes
1534constload3.so-no-z-defs = yes
1535nodelmod1.so-no-z-defs = yes
1536nodelmod2.so-no-z-defs = yes
1537nodelmod4.so-no-z-defs = yes
1538nodel2mod2.so-no-z-defs = yes
1539reldepmod2.so-no-z-defs = yes
1540reldepmod3.so-no-z-defs = yes
1541reldepmod4.so-no-z-defs = yes
1542reldep4mod4.so-no-z-defs = yes
1543reldep4mod2.so-no-z-defs = yes
1544ltglobmod2.so-no-z-defs = yes
1545dblloadmod3.so-no-z-defs = yes
1546tst-tlsmod1.so-no-z-defs = yes
1547tst-tlsmod2.so-no-z-defs = yes
1548tst-tlsmod3.so-no-z-defs = yes
1549tst-tlsmod4.so-no-z-defs = yes
1550tst-tlsmod7.so-no-z-defs = yes
1551tst-tlsmod8.so-no-z-defs = yes
1552tst-tlsmod9.so-no-z-defs = yes
1553tst-tlsmod10.so-no-z-defs = yes
1554tst-tlsmod12.so-no-z-defs = yes
1555tst-tlsmod14a.so-no-z-defs = yes
1556tst-tlsmod14b.so-no-z-defs = yes
1557tst-tlsmod15a.so-no-z-defs = yes
1558tst-tlsmod16b.so-no-z-defs = yes
1559circlemod2.so-no-z-defs = yes
1560circlemod3.so-no-z-defs = yes
1561circlemod3a.so-no-z-defs = yes
1562reldep8mod2.so-no-z-defs = yes
1563reldep9mod1.so-no-z-defs = yes
1564unload3mod4.so-no-z-defs = yes
1565unload4mod1.so-no-z-defs = yes
1566ifuncmod1.so-no-z-defs = yes
1567ifuncmod5.so-no-z-defs = yes
1568ifuncmod6.so-no-z-defs = yes
1569tst-auditmod9a.so-no-z-defs = yes
1570tst-auditmod9b.so-no-z-defs = yes
1571tst-nodelete-uniquemod.so-no-z-defs = yes
1572tst-nodelete-rtldmod.so-no-z-defs = yes
1573tst-nodelete-zmod.so-no-z-defs = yes
1574tst-nodelete2mod.so-no-z-defs = yes
1575
1576ifeq ($(build-shared),yes)
1577# Build all the modules even when not actually running test programs.
1578tests: $(test-modules)
1579endif
1580
1581LDFLAGS-loadtest = -rdynamic
1582
1583$(objpfx)loadtest.out: $(test-modules)
1584
1585$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
1586			 $(objpfx)neededobj3.so
1587
1588$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
1589			  $(objpfx)neededobj3.so
1590
1591$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
1592			  $(objpfx)neededobj3.so $(objpfx)neededobj4.so
1593
1594$(objpfx)neededtest4: $(objpfx)neededobj1.so
1595$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
1596
1597$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so
1598LDFLAGS-restest1 = -rdynamic
1599
1600LDFLAGS-restest2 = -rdynamic
1601
1602$(objpfx)restest1.out: $(test-modules)
1603
1604preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
1605$(objpfx)preloadtest: $(objpfx)testobj6.so
1606LDFLAGS-preloadtest = -rdynamic
1607$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
1608preloadtest-ENV = \
1609  LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1610
1611LDFLAGS-loadfail = -rdynamic
1612
1613$(objpfx)loadfail.out: $(objpfx)failobj.so $(objpfx)testobj1.so \
1614		       $(objpfx)testobj2.so $(objpfx)testobj3.so \
1615		       $(objpfx)testobj4.so $(objpfx)testobj5.so
1616
1617LDFLAGS-multiload = -rdynamic
1618CFLAGS-multiload.c += -DOBJDIR=\"$(elf-objpfx)\"
1619
1620$(objpfx)multiload.out: $(objpfx)testobj1.so
1621
1622LDFLAGS-origtest = -rdynamic
1623$(objpfx)origtest.out: $(objpfx)testobj1.so
1624
1625ifeq ($(have-thread-library),yes)
1626$(objpfx)resolvfail: $(shared-thread-library)
1627endif
1628
1629$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
1630
1631$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
1632			  $(objpfx)circlemod1a.so
1633
1634$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
1635$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
1636$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
1637$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
1638
1639$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
1640
1641$(objpfx)order-cmp.out: $(objpfx)order.out
1642	(echo "0123456789" | cmp $< -) > $@; \
1643	$(evaluate-test)
1644
1645$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
1646$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
1647vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
1648
1649$(objpfx)noload: $(objpfx)testobj1.so
1650LDFLAGS-noload = -rdynamic -Wl,--no-as-needed
1651$(objpfx)noload.out: $(objpfx)testobj5.so
1652
1653$(objpfx)noload-mem.out: $(objpfx)noload.out
1654	$(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@; \
1655	$(evaluate-test)
1656noload-ENV = MALLOC_TRACE=$(objpfx)noload.mtrace \
1657	     LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
1658
1659LDFLAGS-nodelete = -rdynamic
1660LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
1661LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
1662$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
1663		       $(objpfx)nodelmod3.so
1664
1665LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
1666$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
1667
1668$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
1669$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
1670
1671$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
1672	$(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
1673		  $(dt-relr-ldflag) \
1674		  -L$(subst :, -L,$(rpath-link)) \
1675		  -Wl,-rpath-link=$(rpath-link) \
1676		  $< -Wl,-F,$(objpfx)filtmod2.so
1677$(objpfx)filter: $(objpfx)filtmod1.so
1678
1679# This does not link against libc.
1680CFLAGS-filtmod1.c += $(no-stack-protector)
1681
1682$(objpfx)unload.out: $(objpfx)unloadmod.so
1683
1684$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
1685
1686$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
1687
1688$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
1689
1690$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
1691
1692$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so
1693LDFLAGS-next = -Wl,--no-as-needed
1694
1695$(objpfx)tst-next-ver: $(objpfx)nextmod3.so
1696LDFLAGS-tst-next-ver = -Wl,--no-as-needed
1697
1698$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
1699
1700$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
1701
1702$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
1703			  $(objpfx)pathoptobj.so
1704	$(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
1705		 '$(run-program-env)'; \
1706	$(evaluate-test)
1707
1708$(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
1709	$(SHELL) $^ '$(test-wrapper)' '$(test-wrapper-env)' > $@; \
1710	$(evaluate-test)
1711
1712tst-rtld-preload-OBJS = $(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1713$(objpfx)tst-rtld-preload.out: tst-rtld-preload.sh $(objpfx)ld.so \
1714			       $(objpfx)preloadtest \
1715			       $(preloadtest-preloads:%=$(objpfx)%.so)
1716	$(SHELL) $< $(objpfx)ld.so $(objpfx)preloadtest \
1717		    '$(test-wrapper-env)' '$(run_program_env)' \
1718		    '$(rpath-link)' '$(tst-rtld-preload-OBJS)' > $@; \
1719	$(evaluate-test)
1720
1721$(objpfx)initfirst.out: $(objpfx)firstobj.so
1722
1723$(objpfx)global: $(objpfx)globalmod1.so
1724$(objpfx)global.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
1725
1726$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
1727
1728$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
1729
1730$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod6.so
1731
1732$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
1733
1734$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
1735
1736$(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
1737
1738LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
1739$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
1740
1741$(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
1742
1743$(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
1744
1745$(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
1746
1747$(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
1748
1749$(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
1750
1751$(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
1752
1753$(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
1754
1755$(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
1756
1757$(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so $(objpfx)tst-tlsmod7.so
1758
1759$(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so $(objpfx)tst-tlsmod9.so
1760
1761$(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so $(objpfx)tst-tlsmod11.so
1762
1763$(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
1764
1765$(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so
1766$(objpfx)tst-tls14.out: $(objpfx)tst-tlsmod14b.so
1767
1768$(objpfx)tst-tls15.out: $(objpfx)tst-tlsmod15a.so $(objpfx)tst-tlsmod15b.so
1769
1770$(objpfx)tst-tls-dlinfo.out: $(objpfx)tst-tlsmod2.so
1771
1772
1773
1774$(objpfx)tst-tls16.out: $(objpfx)tst-tlsmod16a.so $(objpfx)tst-tlsmod16b.so
1775
1776$(objpfx)tst-tls17.out: $(objpfx)tst-tlsmod17b.so
1777$(patsubst %,$(objpfx)%.os,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.os: tst-tlsmod17a.c
1778	$(compile-command.c) -DN=$*
1779$(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.so: $(objpfx)ld.so
1780$(objpfx)tst-tlsmod17b.so: $(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules))
1781
1782$(objpfx)tst-tls18.out: $(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules))
1783$(patsubst %,$(objpfx)%.os,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.os : tst-tlsmod18a.c
1784	$(compile-command.c) -DN=$*
1785$(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.so: $(objpfx)ld.so
1786
1787$(objpfx)tst-tls19.out: $(objpfx)tst-tls19mod1.so
1788
1789CFLAGS-tst-align.c += $(stack-align-test-flags)
1790CFLAGS-tst-align2.c += $(stack-align-test-flags)
1791CFLAGS-tst-alignmod.c += $(stack-align-test-flags)
1792CFLAGS-tst-alignmod2.c += $(stack-align-test-flags)
1793$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
1794$(objpfx)tst-align2: $(objpfx)tst-alignmod2.so
1795$(objpfx)tst-align3: $(objpfx)tst-alignmod3.so
1796ifeq (yes,$(have-fpie))
1797CFLAGS-tst-align3.c += $(PIE-ccflag)
1798endif
1799LDFLAGS-tst-align3 += -Wl,-z,max-page-size=0x200000
1800LDFLAGS-tst-alignmod3.so += -Wl,-z,max-page-size=0x200000
1801$(objpfx)tst-alignmod3.so: $(libsupport)
1802
1803$(objpfx)unload3.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
1804		      $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
1805
1806$(objpfx)unload4.out: $(objpfx)unload4mod1.so $(objpfx)unload4mod3.so
1807
1808$(objpfx)unload5.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
1809		      $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
1810
1811$(objpfx)unload6.out: $(objpfx)unload6mod1.so $(objpfx)unload6mod2.so \
1812		      $(objpfx)unload6mod3.so
1813
1814$(objpfx)unload7.out: $(objpfx)unload7mod1.so $(objpfx)unload7mod2.so
1815unload7-ENV = MALLOC_PERTURB_=85
1816
1817$(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
1818
1819$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
1820
1821ifeq ($(have-z-execstack),yes)
1822$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
1823CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
1824LDFLAGS-tst-execstack = -Wl,-z,noexecstack
1825LDFLAGS-tst-execstack-mod.so = -Wl,-z,execstack
1826
1827$(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
1828LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
1829
1830LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
1831CFLAGS-tst-execstack-prog.c += -Wno-trampolines
1832CFLAGS-tst-execstack-mod.c += -Wno-trampolines
1833endif
1834
1835LDFLAGS-tst-array2 = -Wl,--no-as-needed
1836LDFLAGS-tst-array5 = -Wl,--no-as-needed
1837
1838$(objpfx)tst-array1-cmp.out: tst-array1.exp $(objpfx)tst-array1.out
1839	cmp $^ > $@; \
1840	$(evaluate-test)
1841
1842$(objpfx)tst-array1-static-cmp.out: tst-array1.exp \
1843				    $(objpfx)tst-array1-static.out
1844	cmp $^ > $@; \
1845	$(evaluate-test)
1846
1847$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
1848$(objpfx)tst-array2-cmp.out: tst-array2.exp $(objpfx)tst-array2.out
1849	cmp $^ > $@; \
1850	$(evaluate-test)
1851
1852$(objpfx)tst-array3-cmp.out: tst-array1.exp $(objpfx)tst-array3.out
1853	cmp $^ > $@; \
1854	$(evaluate-test)
1855
1856$(objpfx)tst-array4.out: $(objpfx)tst-array2dep.so
1857$(objpfx)tst-array4-cmp.out: tst-array4.exp $(objpfx)tst-array4.out
1858	cmp $^ > $@; \
1859	$(evaluate-test)
1860
1861$(objpfx)tst-array5: $(objpfx)tst-array5dep.so
1862$(objpfx)tst-array5-cmp.out: tst-array5.exp $(objpfx)tst-array5.out
1863	cmp $^ > $@; \
1864	$(evaluate-test)
1865
1866$(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
1867				$(objpfx)tst-array5-static.out
1868	cmp $^ > $@; \
1869	$(evaluate-test)
1870
1871CFLAGS-tst-pie1.c += $(pie-ccflag)
1872CFLAGS-tst-pie2.c += $(pie-ccflag)
1873
1874$(objpfx)tst-piemod1.so: $(libsupport)
1875$(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
1876$(objpfx)tst-dlopen-pie.out: $(objpfx)tst-pie1
1877
1878ifeq (yes,$(build-shared))
1879# NB: Please keep cet-built-dso in sysdeps/x86/Makefile in sync with
1880# all-built-dso here.
1881all-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
1882		 $(filter-out $(common-objpfx)linkobj/libc.so, \
1883			      $(sort $(wildcard $(addprefix $(common-objpfx), \
1884							    */lib*.so \
1885							    iconvdata/*.so))))
1886
1887$(all-built-dso:=.dyn): %.dyn: %
1888	@rm -f $@T
1889	LC_ALL=C $(READELF) -W -d $< > $@T
1890	test -s $@T
1891	mv -f $@T $@
1892common-generated += $(all-built-dso:$(common-objpfx)%=%.dyn)
1893
1894$(objpfx)check-textrel.out: $(..)scripts/check-textrel.awk \
1895			    $(all-built-dso:=.dyn)
1896	LC_ALL=C $(AWK) -f $^ > $@; \
1897	$(evaluate-test)
1898generated += check-textrel.out
1899
1900$(objpfx)execstack-default: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
1901	$(make-target-directory)
1902	{ echo '#include <elf.h>'; \
1903	  echo '#include <stackinfo.h>'; \
1904	  echo '#if (DEFAULT_STACK_PERMS & PF_X) == 0'; \
1905	  echo '@@@execstack-no@@@'; \
1906	  echo '#else'; \
1907	  echo '@@@execstack-yes@@@'; \
1908	  echo '#endif'; } | \
1909	$(CC) $(CFLAGS) $(CPPFLAGS) -E -x c-header - | \
1910	sed -n -e 's/^@@@\(.*\)@@@/\1/p' > $@T
1911	mv -f $@T $@
1912generated += execstack-default
1913
1914$(all-built-dso:=.phdr): %.phdr: %
1915	@rm -f $@T
1916	LC_ALL=C $(READELF) -W -l $< > $@T
1917	test -s $@T
1918	mv -f $@T $@
1919common-generated += $(all-built-dso:$(common-objpfx)%=%.phdr)
1920
1921$(objpfx)check-execstack.out: $(..)scripts/check-execstack.awk \
1922			      $(objpfx)execstack-default \
1923			      $(all-built-dso:=.phdr)
1924	LC_ALL=C $(AWK) -v "xfail=$(check-execstack-xfail)" -f $^ > $@; \
1925	$(evaluate-test)
1926generated += check-execstack.out
1927
1928$(objpfx)check-wx-segment.out: $(..)scripts/check-wx-segment.py \
1929			      $(all-built-dso:=.phdr)
1930	$(PYTHON) $^ --xfail="$(check-wx-segment-xfail)" > $@; \
1931	$(evaluate-test)
1932generated += check-wx-segment.out
1933
1934$(objpfx)tst-dlmodcount.out: $(test-modules)
1935
1936$(all-built-dso:=.jmprel): %.jmprel: % Makefile
1937	@rm -f $@T
1938	LC_ALL=C $(READELF) -W -S -d -r $< > $@T
1939	test -s $@T
1940	mv -f $@T $@
1941common-generated += $(all-built-dso:$(common-objpfx)%=%.jmprel)
1942
1943localplt-built-dso := $(addprefix $(common-objpfx),\
1944				  libc.so \
1945				  elf/ld.so \
1946				  math/libm.so \
1947				  dlfcn/libdl.so \
1948				  resolv/libresolv.so \
1949		       )
1950ifeq ($(build-mathvec),yes)
1951localplt-built-dso += $(addprefix $(common-objpfx), mathvec/libmvec.so)
1952endif
1953ifeq ($(have-thread-library),yes)
1954localplt-built-dso += $(filter-out %_nonshared.a, $(shared-thread-library))
1955endif
1956ifeq ($(build-crypt),yes)
1957localplt-built-dso += $(addprefix $(common-objpfx), crypt/libcrypt.so)
1958endif
1959ifneq ($(pthread-in-libc),yes)
1960localplt-built-dso += $(addprefix $(common-objpfx), rt/librt.so)
1961endif
1962
1963vpath localplt.data $(+sysdep_dirs)
1964
1965$(objpfx)check-localplt.out: $(..)scripts/check-localplt.awk \
1966			     $(..)scripts/localplt.awk \
1967			     $(localplt-built-dso:=.jmprel) \
1968			     localplt.data
1969	LC_ALL=C $(AWK) -f $(filter-out $< %localplt.data,$^) | \
1970	  LC_ALL=C $(AWK) -f $< $(filter %localplt.data,$^) - \
1971	  > $@; \
1972	$(evaluate-test)
1973endif
1974
1975$(all-built-dso:=.dynsym): %.dynsym: %
1976	@rm -f $@T
1977	LC_ALL=C $(READELF) -W --dyn-syms $< > $@T
1978	test -s $@T
1979	mv -f $@T $@
1980common-generated += $(all-built-dso:$(common-objpfx)%=%.dynsym)
1981
1982$(objpfx)check-initfini.out: $(..)scripts/check-initfini.awk \
1983			    $(all-built-dso:=.dynsym)
1984	LC_ALL=C $(AWK) -f $^ > $@; \
1985	$(evaluate-test)
1986generated += check-initfini.out
1987
1988$(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so
1989CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
1990LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir
1991$(objpfx)tst-dlopenrpath.out: $(objpfx)firstobj.so
1992
1993$(objpfx)tst-deep1mod2.so: $(objpfx)tst-deep1mod3.so
1994$(objpfx)tst-deep1: $(objpfx)tst-deep1mod1.so
1995$(objpfx)tst-deep1.out: $(objpfx)tst-deep1mod2.so
1996LDFLAGS-tst-deep1 += -rdynamic
1997tst-deep1mod3.so-no-z-defs = yes
1998
1999$(objpfx)tst-dlmopen1.out: $(objpfx)tst-dlmopen1mod.so
2000
2001$(objpfx)tst-dlmopen2.out: $(objpfx)tst-dlmopen1mod.so
2002
2003$(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so
2004
2005$(objpfx)tst-dlmopen4.out: $(objpfx)tst-dlmopen1mod.so
2006
2007$(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so
2008tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
2009
2010$(objpfx)tst-audit2.out: $(objpfx)tst-auditmod1.so $(objpfx)tst-auditmod9b.so
2011# Prevent GCC-5 from translating a malloc/memset pair into calloc
2012CFLAGS-tst-audit2.c += -fno-builtin
2013tst-audit2-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
2014
2015$(objpfx)tst-audit9.out: $(objpfx)tst-auditmod9a.so $(objpfx)tst-auditmod9b.so
2016tst-audit9-ENV = LD_AUDIT=$(objpfx)tst-auditmod9a.so
2017
2018$(objpfx)tst-audit8: $(libm)
2019$(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so
2020tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
2021
2022$(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
2023
2024$(objpfx)tst-global2: $(objpfx)tst-globalmod2.so
2025$(objpfx)tst-global2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
2026LDFLAGS-tst-global2 = -Wl,--enable-new-dtags
2027LDFLAGS-tst-globalmod2.so = -Wl,--enable-new-dtags
2028
2029$(objpfx)order2.out: $(objpfx)order2mod1.so $(objpfx)order2mod2.so
2030$(objpfx)order2-cmp.out: $(objpfx)order2.out
2031	(echo "12345" | cmp $< -) > $@; \
2032	$(evaluate-test)
2033$(objpfx)order2mod1.so: $(objpfx)order2mod4.so
2034$(objpfx)order2mod4.so: $(objpfx)order2mod3.so
2035$(objpfx)order2mod2.so: $(objpfx)order2mod3.so
2036order2mod2.so-no-z-defs = yes
2037LDFLAGS-order2mod1.so = -Wl,--no-as-needed
2038LDFLAGS-order2mod2.so = -Wl,--no-as-needed
2039
2040tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
2041tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
2042
2043tst-ptrguard1-ARGS = --command "$(host-test-program-cmd) --child"
2044# When built statically, the pointer guard interface uses
2045# __pointer_chk_guard_local.
2046CFLAGS-tst-ptrguard1-static.c += -DPTRGUARD_LOCAL
2047tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
2048
2049$(objpfx)tst-leaks1-mem.out: $(objpfx)tst-leaks1.out
2050	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@; \
2051	$(evaluate-test)
2052
2053tst-leaks1-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1.mtrace \
2054		 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
2055
2056$(objpfx)tst-thrlock: $(shared-thread-library)
2057$(objpfx)tst-thrlock.out: $(libm)
2058$(objpfx)tst-noload.out: $(libm)
2059
2060tst-tst-dlopen-tlsmodid-no-pie = yes
2061$(objpfx)tst-dlopen-tlsmodid: $(shared-thread-library)
2062$(objpfx)tst-dlopen-tlsmodid.out: $(objpfx)tst-dlopen-self
2063CFLAGS-tst-dlopen-tlsmodid-pie.c += $(pie-ccflag)
2064$(objpfx)tst-dlopen-tlsmodid-pie: $(shared-thread-library)
2065$(objpfx)tst-dlopen-tlsmodid-pie.out: $(objpfx)tst-dlopen-self-pie
2066$(objpfx)tst-dlopen-tlsmodid-container: $(shared-thread-library)
2067LDFLAGS-tst-dlopen-tlsmodid-container += -Wl,-rpath,\$$ORIGIN
2068
2069tst-tst-dlopen-self-no-pie = yes
2070CFLAGS-tst-dlopen-self-pie.c += $(pie-ccflag)
2071LDFLAGS-tst-dlopen-self-container += -Wl,-rpath,\$$ORIGIN
2072
2073CFLAGS-ifuncmain1pic.c += $(pic-ccflag)
2074CFLAGS-ifuncmain1picstatic.c += $(pic-ccflag)
2075CFLAGS-ifuncmain1staticpic.c += $(pic-ccflag)
2076CFLAGS-ifuncdep1pic.c += $(pic-ccflag)
2077CFLAGS-ifuncmain1vispic.c += $(pic-ccflag)
2078CFLAGS-ifuncmain2pic.c += $(pic-ccflag)
2079CFLAGS-ifuncmain2picstatic.c += $(pic-ccflag)
2080CFLAGS-ifuncdep2pic.c += $(pic-ccflag)
2081CFLAGS-ifuncmain4picstatic.c += $(pic-ccflag)
2082CFLAGS-ifuncmain5pic.c += $(pic-ccflag)
2083CFLAGS-ifuncmain5picstatic.c += $(pic-ccflag)
2084CFLAGS-ifuncmain5staticpic.c += $(pic-ccflag)
2085CFLAGS-ifuncdep5pic.c += $(pic-ccflag)
2086CFLAGS-ifuncmain7pic.c += $(pic-ccflag)
2087CFLAGS-ifuncmain7picstatic.c += $(pic-ccflag)
2088CFLAGS-ifuncmain9pic.c += $(pic-ccflag)
2089CFLAGS-ifuncmain9picstatic.c += $(pic-ccflag)
2090
2091LDFLAGS-ifuncmain3 = -Wl,-export-dynamic
2092
2093CFLAGS-ifuncmain1pie.c += $(pie-ccflag)
2094CFLAGS-ifuncmain1vispie.c += $(pie-ccflag)
2095CFLAGS-ifuncmain1staticpie.c += $(pie-ccflag)
2096CFLAGS-ifuncmain5pie.c += $(pie-ccflag)
2097CFLAGS-ifuncmain6pie.c += $(pie-ccflag)
2098CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
2099CFLAGS-ifuncmain9pie.c += $(pie-ccflag)
2100CFLAGS-tst-ifunc-textrel.c += $(pic-ccflag)
2101
2102LDFLAGS-ifuncmain6pie = -Wl,-z,lazy
2103
2104$(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so
2105$(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o
2106$(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so
2107$(objpfx)ifuncmain5pie: $(objpfx)ifuncmod5.so
2108$(objpfx)ifuncmain6pie: $(objpfx)ifuncmod6.so
2109
2110$(objpfx)ifuncmain1: $(addprefix $(objpfx),ifuncmod1.so)
2111$(objpfx)ifuncmain1pic: $(addprefix $(objpfx),ifuncmod1.so)
2112$(objpfx)ifuncmain1staticpic: $(addprefix $(objpfx),ifuncdep1pic.o)
2113$(objpfx)ifuncmain1static: $(addprefix $(objpfx),ifuncdep1.o)
2114$(objpfx)ifuncmain1picstatic: $(addprefix $(objpfx),ifuncdep1pic.o)
2115$(objpfx)ifuncmain1vis: $(addprefix $(objpfx),ifuncmod1.so)
2116$(objpfx)ifuncmain1vispic: $(addprefix $(objpfx),ifuncmod1.so)
2117$(objpfx)ifuncmain2: $(addprefix $(objpfx),ifuncdep2.o)
2118$(objpfx)ifuncmain2pic: $(addprefix $(objpfx),ifuncdep2pic.o)
2119$(objpfx)ifuncmain2static: $(addprefix $(objpfx),ifuncdep2.o)
2120$(objpfx)ifuncmain2picstatic: $(addprefix $(objpfx),ifuncdep2pic.o)
2121
2122$(objpfx)ifuncmain3.out: $(objpfx)ifuncmod3.so
2123
2124$(objpfx)ifuncmain5: $(addprefix $(objpfx),ifuncmod5.so)
2125$(objpfx)ifuncmain5pic: $(addprefix $(objpfx),ifuncmod5.so)
2126$(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
2127$(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
2128$(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
2129
2130LDFLAGS-tst-ifunc-fault-lazy = -Wl,-z,lazy
2131LDFLAGS-tst-ifunc-fault-bindnow = -Wl,-z,now
2132define tst-ifunc-fault-script
2133( $(test-wrapper) $(rtld-prefix) --verify $^ \
2134  && $(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 $(rtld-prefix) $^ \
2135  && $(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 LD_DEBUG=unused \
2136			 $(rtld-prefix) $^ \
2137) > $@; $(evaluate-test)
2138endef
2139$(objpfx)tst-ifunc-fault-lazy.out: $(objpfx)tst-ifunc-fault-lazy $(objpfx)ld.so
2140	$(tst-ifunc-fault-script)
2141$(objpfx)tst-ifunc-fault-bindnow.out: $(objpfx)tst-ifunc-fault-bindnow \
2142   $(objpfx)ld.so
2143	$(tst-ifunc-fault-script)
2144
2145$(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
2146			  $(objpfx)tst-unique1mod2.so
2147
2148$(objpfx)tst-unique2: $(objpfx)tst-unique2mod1.so
2149$(objpfx)tst-unique2.out: $(objpfx)tst-unique2mod2.so
2150
2151$(objpfx)tst-unique3: $(objpfx)tst-unique3lib.so
2152$(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
2153
2154$(objpfx)tst-unique4: $(objpfx)tst-unique4lib.so
2155
2156$(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
2157			   $(objpfx)tst-nodelete-rtldmod.so \
2158			   $(objpfx)tst-nodelete-zmod.so
2159
2160LDFLAGS-tst-nodelete = -rdynamic
2161LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
2162
2163$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
2164
2165LDFLAGS-tst-nodelete2 = -rdynamic
2166
2167$(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
2168	cmp $^ > $@; \
2169	$(evaluate-test)
2170
2171$(objpfx)tst-initorder2: $(objpfx)tst-initorder2a.so $(objpfx)tst-initorder2d.so $(objpfx)tst-initorder2c.so
2172$(objpfx)tst-initorder2a.so: $(objpfx)tst-initorder2b.so
2173$(objpfx)tst-initorder2b.so: $(objpfx)tst-initorder2c.so
2174$(objpfx)tst-initorder2c.so: $(objpfx)tst-initorder2d.so
2175LDFLAGS-tst-initorder2 = -Wl,--no-as-needed
2176LDFLAGS-tst-initorder2a.so = -Wl,--no-as-needed
2177LDFLAGS-tst-initorder2b.so = -Wl,--no-as-needed
2178LDFLAGS-tst-initorder2c.so = -Wl,--no-as-needed
2179define o-iterator-doit
2180$(objpfx)tst-initorder2$o.os: tst-initorder2.c; \
2181$$(compile-command.c) -DNAME=\"$o\"
2182endef
2183object-suffixes-left := a b c d
2184include $(o-iterator)
2185
2186$(objpfx)tst-initorder2-cmp.out: tst-initorder2.exp $(objpfx)tst-initorder2.out
2187	cmp $^ > $@; \
2188	$(evaluate-test)
2189
2190$(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
2191$(objpfx)tst-relsort1mod2.so: $(libm)
2192$(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
2193			   $(objpfx)tst-relsort1mod2.so
2194
2195$(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
2196	$(test-wrapper-env) \
2197	LD_TRACE_LOADED_OBJECTS=1 \
2198	LD_DEBUG=unused \
2199	LD_PRELOAD= \
2200	$(rtld-prefix) \
2201	  $< > $@; \
2202	$(evaluate-test)
2203
2204$(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
2205	cmp $< /dev/null > $@; \
2206	$(evaluate-test)
2207
2208$(objpfx)tst-audit11.out: $(objpfx)tst-auditmod11.so $(objpfx)tst-audit11mod1.so
2209tst-audit11-ENV = LD_AUDIT=$(objpfx)tst-auditmod11.so
2210$(objpfx)tst-audit11mod1.so: $(objpfx)tst-audit11mod2.so
2211LDFLAGS-tst-audit11mod2.so = -Wl,--version-script=tst-audit11mod2.map,-soname,tst-audit11mod2.so
2212
2213$(objpfx)tst-audit12.out: $(objpfx)tst-auditmod12.so $(objpfx)tst-audit12mod1.so $(objpfx)tst-audit12mod3.so
2214tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so
2215$(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
2216LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
2217
2218$(objpfx)tst-audit13.out: $(objpfx)tst-audit13mod1.so
2219LDFLAGS-tst-audit13mod1.so = -Wl,-z,lazy
2220tst-audit13-ENV = LD_AUDIT=$(objpfx)tst-audit13mod1.so
2221
2222$(objpfx)tst-auditmany.out: $(objpfx)tst-auditmanymod1.so \
2223  $(objpfx)tst-auditmanymod2.so $(objpfx)tst-auditmanymod3.so \
2224  $(objpfx)tst-auditmanymod4.so $(objpfx)tst-auditmanymod5.so \
2225  $(objpfx)tst-auditmanymod6.so $(objpfx)tst-auditmanymod7.so \
2226  $(objpfx)tst-auditmanymod8.so	$(objpfx)tst-auditmanymod9.so
2227tst-auditmany-ENV = \
2228  LD_AUDIT=tst-auditmanymod1.so:tst-auditmanymod2.so:tst-auditmanymod3.so:tst-auditmanymod4.so:tst-auditmanymod5.so:tst-auditmanymod6.so:tst-auditmanymod7.so:tst-auditmanymod8.so:tst-auditmanymod9.so
2229
2230LDFLAGS-tst-audit14 = -Wl,--audit=tst-auditlogmod-1.so,--disable-new-dtags
2231$(objpfx)tst-auditlogmod-1.so: $(libsupport)
2232$(objpfx)tst-audit14.out: $(objpfx)tst-auditlogmod-1.so
2233LDFLAGS-tst-audit14a = -Wl,--audit=tst-auditlogmod-1.so,--enable-new-dtags
2234$(objpfx)tst-audit14a.out: $(objpfx)tst-auditlogmod-1.so
2235LDFLAGS-tst-audit15 = \
2236  -Wl,--audit=tst-auditlogmod-1.so,--depaudit=tst-auditlogmod-2.so
2237$(objpfx)tst-auditlogmod-2.so: $(libsupport)
2238$(objpfx)tst-audit15.out: \
2239  $(objpfx)tst-auditlogmod-1.so $(objpfx)tst-auditlogmod-2.so
2240LDFLAGS-tst-audit16 = \
2241  -Wl,--audit=tst-auditlogmod-1.so:tst-auditlogmod-2.so \
2242  -Wl,--depaudit=tst-auditlogmod-3.so
2243$(objpfx)tst-auditlogmod-3.so: $(libsupport)
2244$(objpfx)tst-audit16.out: \
2245  $(objpfx)tst-auditlogmod-1.so $(objpfx)tst-auditlogmod-2.so \
2246  $(objpfx)tst-auditlogmod-3.so
2247$(objpfx)tst-audit17.out: $(objpfx)tst-auditmod17.so
2248# The test check if a audit library without libc.so on DT_NEEDED works as
2249# intended, so it uses an explicit link rule.
2250$(objpfx)tst-auditmod17.so: $(objpfx)tst-auditmod17.os
2251	$(CC) -nostdlib -nostartfiles -shared -o $@.new \
2252	$(filter-out $(map-file),$^)
2253	$(call after-link,$@.new)
2254	mv -f $@.new $@
2255CFLAGS-.os += $(call elide-stack-protector,.os,tst-auditmod17)
2256tst-audit17-ENV = LD_AUDIT=$(objpfx)tst-auditmod17.so
2257
2258$(objpfx)tst-audit14-cmp.out: tst-audit14.exp $(objpfx)tst-audit14.out
2259	cmp $^ > $@; \
2260	$(evaluate-test)
2261$(objpfx)tst-audit14a-cmp.out: tst-audit14.exp $(objpfx)tst-audit14a.out
2262	cmp $^ > $@; \
2263	$(evaluate-test)
2264$(objpfx)tst-audit15-cmp.out: tst-audit15.exp $(objpfx)tst-audit15.out
2265	cmp $^ > $@; \
2266	$(evaluate-test)
2267$(objpfx)tst-audit16-cmp.out: tst-audit16.exp $(objpfx)tst-audit16.out
2268	cmp $^ > $@; \
2269	$(evaluate-test)
2270
2271$(objpfx)tst-audit18.out: $(objpfx)tst-auditmod18.so \
2272			  $(objpfx)tst-audit18mod.so
2273tst-audit18-ARGS = -- $(host-test-program-cmd)
2274
2275$(objpfx)tst-audit19a.out: $(objpfx)tst-auditmod19a.so
2276tst-audit19a-ENV = LD_AUDIT=$(objpfx)tst-auditmod19a.so
2277
2278$(objpfx)tst-audit19b.out: $(objpfx)tst-auditmod19b.so
2279$(objpfx)tst-audit19b: $(objpfx)tst-audit19bmod.so
2280tst-audit19b-ARGS = -- $(host-test-program-cmd)
2281
2282$(objpfx)tst-audit20.out: $(objpfx)tst-auditmod20.so
2283tst-audit20-ENV = LD_AUDIT=$(objpfx)tst-auditmod20.so
2284
2285$(objpfx)tst-audit21: $(shared-thread-library)
2286$(objpfx)tst-audit21.out: $(objpfx)tst-auditmod21a.so
2287$(objpfx)tst-auditmod21a.so: $(objpfx)tst-auditmod21b.so
2288tst-audit21-ENV = LD_AUDIT=$(objpfx)tst-auditmod21a.so
2289
2290$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
2291tst-audit22-ARGS = -- $(host-test-program-cmd)
2292
2293$(objpfx)tst-audit23.out: $(objpfx)tst-auditmod23.so \
2294			  $(objpfx)tst-audit23mod.so
2295tst-audit23-ARGS = -- $(host-test-program-cmd)
2296
2297$(objpfx)tst-audit24a.out: $(objpfx)tst-auditmod24a.so
2298$(objpfx)tst-audit24a: $(objpfx)tst-audit24amod1.so \
2299		       $(objpfx)tst-audit24amod2.so
2300tst-audit24a-ENV = LD_AUDIT=$(objpfx)tst-auditmod24a.so
2301LDFLAGS-tst-audit24a = -Wl,-z,now
2302
2303$(objpfx)tst-audit24b.out: $(objpfx)tst-auditmod24b.so
2304$(objpfx)tst-audit24b: $(objpfx)tst-audit24bmod1.so \
2305		       $(objpfx)tst-audit24bmod2.so
2306$(objpfx)tst-audit24bmod1: $(objpfx)tst-audit24bmod2.so
2307# The test checks if a library without .gnu.version correctly calls the
2308# audit callbacks.  So it uses an explicit link rule to avoid linking
2309# against libc.so.
2310$(objpfx)tst-audit24bmod1.so: $(objpfx)tst-audit24bmod1.os
2311	$(CC) -nostdlib -nostartfiles -shared -o $@.new $(objpfx)tst-audit24bmod1.os \
2312	  -Wl,-z,now
2313	$(call after-link,$@.new)
2314	mv -f $@.new $@
2315CFLAGS-.os += $(call elide-stack-protector,.os,tst-audit24bmod1)
2316$(objpfx)tst-audit24bmod2.so: $(objpfx)tst-audit24bmod2.os
2317	$(CC) -nostdlib -nostartfiles -shared -o $@.new $(objpfx)tst-audit24bmod2.os
2318	$(call after-link,$@.new)
2319	mv -f $@.new $@
2320CFLAGS-.os += $(call elide-stack-protector,.os,tst-audit24bmod2)
2321tst-audit24b-ENV = LD_AUDIT=$(objpfx)tst-auditmod24b.so
2322LDFLAGS-tst-audit24b = -Wl,-z,now
2323
2324# Same as tst-audit24a, but tests LD_BIND_NOW
2325$(objpfx)tst-audit24c.out: $(objpfx)tst-auditmod24c.so
2326$(objpfx)tst-audit24c: $(objpfx)tst-audit24amod1.so \
2327		       $(objpfx)tst-audit24amod2.so
2328tst-audit24c-ENV = LD_BIND_NOW=1 LD_AUDIT=$(objpfx)tst-auditmod24c.so
2329LDFLAGS-tst-audit24c = -Wl,-z,lazy
2330
2331$(objpfx)tst-audit24d.out: $(objpfx)tst-auditmod24d.so
2332$(objpfx)tst-audit24d: $(objpfx)tst-audit24dmod1.so \
2333		       $(objpfx)tst-audit24dmod2.so
2334$(objpfx)tst-audit24dmod1.so: $(objpfx)tst-audit24dmod3.so
2335LDFLAGS-tst-audit24dmod1.so = -Wl,-z,now
2336$(objpfx)tst-audit24dmod2.so: $(objpfx)tst-audit24dmod4.so
2337LDFLAGS-tst-audit24dmod2.so = -Wl,-z,lazy
2338tst-audit24d-ENV = LD_AUDIT=$(objpfx)tst-auditmod24d.so
2339LDFLAGS-tst-audit24d = -Wl,-z,lazy
2340
2341$(objpfx)tst-audit25a.out: $(objpfx)tst-auditmod25.so
2342$(objpfx)tst-audit25a: $(objpfx)tst-audit25mod1.so \
2343		       $(objpfx)tst-audit25mod2.so \
2344		       $(objpfx)tst-audit25mod3.so \
2345		       $(objpfx)tst-audit25mod4.so
2346LDFLAGS-tst-audit25a = -Wl,-z,lazy
2347$(objpfx)tst-audit25mod1.so: $(objpfx)tst-audit25mod3.so
2348LDFLAGS-tst-audit25mod1.so = -Wl,-z,now
2349$(objpfx)tst-audit25mod2.so: $(objpfx)tst-audit25mod4.so
2350LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy
2351tst-audit25a-ARGS = -- $(host-test-program-cmd)
2352
2353$(objpfx)tst-audit25b.out: $(objpfx)tst-auditmod25.so
2354$(objpfx)tst-audit25b: $(objpfx)tst-audit25mod1.so \
2355		       $(objpfx)tst-audit25mod2.so \
2356		       $(objpfx)tst-audit25mod3.so \
2357		       $(objpfx)tst-audit25mod4.so
2358LDFLAGS-tst-audit25b = -Wl,-z,now
2359tst-audit25b-ARGS = -- $(host-test-program-cmd)
2360
2361$(objpfx)tst-audit28.out: $(objpfx)tst-auditmod28.so
2362$(objpfx)tst-auditmod28.so: $(libsupport)
2363tst-audit28-ENV = LD_AUDIT=$(objpfx)tst-auditmod28.so
2364
2365# tst-sonamemove links against an older implementation of the library.
2366LDFLAGS-tst-sonamemove-linkmod1.so = \
2367  -Wl,--version-script=tst-sonamemove-linkmod1.map \
2368  -Wl,-soname,tst-sonamemove-runmod1.so
2369LDFLAGS-tst-sonamemove-runmod1.so = -Wl,--no-as-needed \
2370  -Wl,--version-script=tst-sonamemove-runmod1.map \
2371  -Wl,-soname,tst-sonamemove-runmod1.so
2372LDFLAGS-tst-sonamemove-runmod2.so = \
2373  -Wl,--version-script=tst-sonamemove-runmod2.map \
2374  -Wl,-soname,tst-sonamemove-runmod2.so
2375$(objpfx)tst-sonamemove-runmod1.so: $(objpfx)tst-sonamemove-runmod2.so
2376# Link against the link module, but depend on the run-time modules
2377# for execution.
2378$(objpfx)tst-sonamemove-link: $(objpfx)tst-sonamemove-linkmod1.so
2379$(objpfx)tst-sonamemove-link.out: \
2380  $(objpfx)tst-sonamemove-runmod1.so \
2381  $(objpfx)tst-sonamemove-runmod2.so
2382$(objpfx)tst-sonamemove-dlopen.out: \
2383  $(objpfx)tst-sonamemove-runmod1.so \
2384  $(objpfx)tst-sonamemove-runmod2.so
2385
2386$(objpfx)tst-dlmopen-dlerror-mod.so: $(libsupport)
2387$(objpfx)tst-dlmopen-dlerror.out: $(objpfx)tst-dlmopen-dlerror-mod.so
2388
2389# Override -z defs, so that we can reference an undefined symbol.
2390# Force lazy binding for the same reason.
2391LDFLAGS-tst-latepthreadmod.so = \
2392  -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all
2393# Do not optimize sibling calls as the test relies on a JMP_SLOT relocation for
2394# function this_function_is_not_defined.
2395CFLAGS-tst-latepthreadmod.c += -fno-optimize-sibling-calls
2396$(objpfx)tst-latepthreadmod.so: $(shared-thread-library)
2397$(objpfx)tst-latepthread.out: $(objpfx)tst-latepthreadmod.so
2398
2399# The test modules are parameterized by preprocessor macros.
2400$(patsubst %,$(objpfx)%.os,$(tst-tls-many-dynamic-modules)): \
2401  $(objpfx)tst-tls-manydynamic%mod.os : tst-tls-manydynamicmod.c
2402	$(compile-command.c) \
2403	  -DNAME=tls_global_$* -DSETTER=set_value_$* -DGETTER=get_value_$*
2404$(objpfx)tst-tls-manydynamic: $(shared-thread-library)
2405$(objpfx)tst-tls-manydynamic.out: \
2406  $(patsubst %,$(objpfx)%.so,$(tst-tls-many-dynamic-modules))
2407
2408$(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig
2409	$(SHELL) $< '$(common-objpfx)' '$(test-wrapper-env)' \
2410		 '$(run-program-env)' > $@; \
2411	$(evaluate-test)
2412
2413# Test static linking of all the libraries we can possibly link
2414# together.  Note that in some configurations this may be less than the
2415# complete list of libraries we build but we try to maxmimize this list.
2416ifeq ($(pthread-in-libc),no)
2417$(objpfx)tst-linkall-static: \
2418  $(common-objpfx)resolv/libanl.a
2419endif
2420$(objpfx)tst-linkall-static: \
2421  $(common-objpfx)math/libm.a \
2422  $(common-objpfx)resolv/libresolv.a \
2423  $(common-objpfx)login/libutil.a \
2424  $(common-objpfx)rt/librt.a \
2425  $(static-thread-library)
2426
2427ifeq ($(build-crypt),yes)
2428# If we are using NSS crypto and we have the ability to link statically
2429# then we include libcrypt.a, otherwise we leave out libcrypt.a and
2430# link as much as we can into the tst-linkall-static test.  This assumes
2431# that linking with libcrypt.a does everything required to include the
2432# static NSS crypto library.
2433ifeq (yesyes,$(nss-crypt)$(static-nss-crypt))
2434$(objpfx)tst-linkall-static: \
2435  $(common-objpfx)crypt/libcrypt.a
2436endif
2437# If we are not using NSS crypto then we always have the ability to link
2438# with libcrypt.a.
2439ifeq (no,$(nss-crypt))
2440$(objpfx)tst-linkall-static: \
2441  $(common-objpfx)crypt/libcrypt.a
2442endif
2443endif
2444
2445LDFLAGS-nextmod3.so = -Wl,--version-script=nextmod3.map
2446
2447# The application depends on the DSO, and the DSO loads the plugin.
2448# The plugin also depends on the DSO. This creates the circular
2449# dependency via dlopen that we're testing to make sure works.
2450$(objpfx)tst-nodelete-dlclose-plugin.so: $(objpfx)tst-nodelete-dlclose-dso.so
2451$(objpfx)tst-nodelete-dlclose: $(objpfx)tst-nodelete-dlclose-dso.so
2452$(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \
2453				   $(objpfx)tst-nodelete-dlclose-plugin.so
2454
2455tst-env-setuid-ENV = MALLOC_CHECK_=2 MALLOC_MMAP_THRESHOLD_=4096 \
2456		     LD_HWCAP_MASK=0x1
2457
2458$(objpfx)tst-debug1.out: $(objpfx)tst-debug1mod1.so
2459
2460$(objpfx)tst-debug1mod1.so: $(objpfx)testobj1.so
2461	$(OBJCOPY) --only-keep-debug $< $@
2462
2463$(objpfx)tst-main1: $(objpfx)tst-main1mod.so
2464CRT-tst-main1 := $(csu-objpfx)crt1.o
2465tst-main1-no-pie = yes
2466LDLIBS-tst-main1 = $(libsupport)
2467tst-main1mod.so-no-z-defs = yes
2468
2469LDLIBS-tst-absolute-sym-lib.so = tst-absolute-sym-lib.lds
2470$(objpfx)tst-absolute-sym-lib.so: $(LDLIBS-tst-absolute-sym-lib.so)
2471$(objpfx)tst-absolute-sym: $(objpfx)tst-absolute-sym-lib.so
2472
2473LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
2474$(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
2475$(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
2476
2477$(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
2478# Avoid creating an ABI tag note, which may come before the
2479# artificial, large note in tst-big-note-lib.o and invalidate the
2480# test.
2481$(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o
2482	$(LINK.o) -shared -o $@ $(LDFLAGS.so) $(dt-relr-ldflag) $<
2483
2484$(objpfx)tst-unwind-ctor: $(objpfx)tst-unwind-ctor-lib.so
2485
2486CFLAGS-tst-unwind-main.c += -funwind-tables -DUSE_PTHREADS=0
2487
2488$(objpfx)tst-initfinilazyfail.out: \
2489  $(objpfx)tst-initlazyfailmod.so $(objpfx)tst-finilazyfailmod.so
2490# Override -z defs, so that we can reference an undefined symbol.
2491# Force lazy binding for the same reason.
2492LDFLAGS-tst-initlazyfailmod.so = \
2493  -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all
2494LDFLAGS-tst-finilazyfailmod.so = \
2495  -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all
2496
2497$(objpfx)tst-dlopenfail.out: \
2498  $(objpfx)tst-dlopenfailmod1.so $(objpfx)tst-dlopenfailmod2.so
2499# Order matters here.  tst-dlopenfaillinkmod.so's soname ensures a
2500# run-time loader failure.  --as-needed breaks this test because
2501# nothing actually references tst-dlopenfailmod2.so (with its soname
2502# tst-dlopenfail-missingmod.so).
2503LDFLAGS-tst-dlopenfailmod1.so = -Wl,--no-as-needed
2504$(objpfx)tst-dlopenfailmod1.so: \
2505  $(shared-thread-library) $(objpfx)tst-dlopenfaillinkmod.so
2506LDFLAGS-tst-dlopenfaillinkmod.so = -Wl,-soname,tst-dlopenfail-missingmod.so
2507$(objpfx)tst-dlopenfailmod2.so: $(objpfx)tst-dlopenfailnodelmod.so
2508$(objpfx)tst-dlopenfail-2.out: \
2509  $(objpfx)tst-dlopenfailmod1.so $(objpfx)tst-dlopenfailmod2.so \
2510  $(objpfx)tst-dlopenfailmod3.so
2511# tst-dlopenfailnodelmod.so emulates how libpthread was linked.
2512$(objpfx)tst-dlopenfailnodelmod.so: $(libsupport)
2513LDFLAGS-tst-dlopenfailnodelmod.so = \
2514  -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
2515# tst-dlopenfail should export the libsupport symbols, so that
2516# tst-dlopenfailnodelmod.so uses them for error reporting.
2517LDFLAGS-tst-dlopenfail = -Wl,-E
2518
2519$(objpfx)tst-dlopen-nodelete-reloc.out: \
2520  $(objpfx)tst-dlopen-nodelete-reloc-mod1.so \
2521  $(objpfx)tst-dlopen-nodelete-reloc-mod2.so \
2522  $(objpfx)tst-dlopen-nodelete-reloc-mod3.so \
2523  $(objpfx)tst-dlopen-nodelete-reloc-mod4.so \
2524  $(objpfx)tst-dlopen-nodelete-reloc-mod5.so \
2525  $(objpfx)tst-dlopen-nodelete-reloc-mod6.so \
2526  $(objpfx)tst-dlopen-nodelete-reloc-mod7.so \
2527  $(objpfx)tst-dlopen-nodelete-reloc-mod8.so \
2528  $(objpfx)tst-dlopen-nodelete-reloc-mod9.so \
2529  $(objpfx)tst-dlopen-nodelete-reloc-mod10.so \
2530  $(objpfx)tst-dlopen-nodelete-reloc-mod11.so \
2531  $(objpfx)tst-dlopen-nodelete-reloc-mod12.so \
2532  $(objpfx)tst-dlopen-nodelete-reloc-mod13.so \
2533  $(objpfx)tst-dlopen-nodelete-reloc-mod14.so \
2534  $(objpfx)tst-dlopen-nodelete-reloc-mod15.so \
2535  $(objpfx)tst-dlopen-nodelete-reloc-mod16.so \
2536  $(objpfx)tst-dlopen-nodelete-reloc-mod17.so
2537tst-dlopen-nodelete-reloc-mod2.so-no-z-defs = yes
2538LDFLAGS-tst-dlopen-nodelete-reloc-mod2.so = -Wl,-z,nodelete
2539$(objpfx)tst-dlopen-nodelete-reloc-mod4.so: \
2540  $(objpfx)tst-dlopen-nodelete-reloc-mod3.so
2541LDFLAGS-tst-dlopen-nodelete-reloc-mod4.so = -Wl,--no-as-needed
2542$(objpfx)tst-dlopen-nodelete-reloc-mod5.so: \
2543  $(objpfx)tst-dlopen-nodelete-reloc-mod4.so
2544LDFLAGS-tst-dlopen-nodelete-reloc-mod5.so = -Wl,-z,nodelete,--no-as-needed
2545tst-dlopen-nodelete-reloc-mod5.so-no-z-defs = yes
2546tst-dlopen-nodelete-reloc-mod7.so-no-z-defs = yes
2547tst-dlopen-nodelete-reloc-mod11.so-no-z-defs = yes
2548$(objpfx)tst-dlopen-nodelete-reloc-mod13.so: \
2549  $(objpfx)tst-dlopen-nodelete-reloc-mod12.so
2550$(objpfx)tst-dlopen-nodelete-reloc-mod15.so: \
2551  $(objpfx)tst-dlopen-nodelete-reloc-mod14.so
2552tst-dlopen-nodelete-reloc-mod16.so-no-z-defs = yes
2553$(objpfx)tst-dlopen-nodelete-reloc-mod16.so: \
2554  $(objpfx)tst-dlopen-nodelete-reloc-mod15.so
2555LDFLAGS-tst-dlopen-nodelete-reloc-mod16.so = -Wl,--no-as-needed
2556$(objpfx)tst-dlopen-nodelete-reloc-mod17.so: \
2557  $(objpfx)tst-dlopen-nodelete-reloc-mod15.so \
2558  $(objpfx)tst-dlopen-nodelete-reloc-mod16.so
2559LDFLAGS-tst-dlopen-nodelete-reloc-mod17.so = -Wl,--no-as-needed
2560
2561$(objpfx)tst-ldconfig-ld_so_conf-update.out: $(objpfx)tst-ldconfig-ld-mod.so
2562
2563LDFLAGS-tst-filterobj-flt.so = -Wl,--filter=$(objpfx)tst-filterobj-filtee.so
2564$(objpfx)tst-filterobj: $(objpfx)tst-filterobj-flt.so
2565$(objpfx)tst-filterobj.out: $(objpfx)tst-filterobj-filtee.so
2566$(objpfx)tst-filterobj-dlopen.out: $(objpfx)tst-filterobj-filtee.so
2567
2568LDFLAGS-tst-filterobj-aux.so = -Wl,--auxiliary=$(objpfx)tst-filterobj-filtee.so
2569$(objpfx)tst-auxobj: $(objpfx)tst-filterobj-aux.so
2570$(objpfx)tst-auxobj.out: $(objpfx)tst-filterobj-filtee.so
2571$(objpfx)tst-auxobj-dlopen.out: $(objpfx)tst-filterobj-filtee.so
2572
2573$(objpfx)tst-single_threaded: $(objpfx)tst-single_threaded-mod1.so
2574$(objpfx)tst-single_threaded.out: \
2575  $(objpfx)tst-single_threaded-mod2.so $(objpfx)tst-single_threaded-mod3.so
2576$(objpfx)tst-single_threaded-static-dlopen: \
2577  $(objpfx)tst-single_threaded-mod1.o
2578$(objpfx)tst-single_threaded-static-dlopen.out: \
2579  $(objpfx)tst-single_threaded-mod2.so
2580$(objpfx)tst-single_threaded-pthread: \
2581  $(objpfx)tst-single_threaded-mod1.so $(shared-thread-library)
2582$(objpfx)tst-single_threaded-pthread.out: \
2583  $(objpfx)tst-single_threaded-mod2.so $(objpfx)tst-single_threaded-mod3.so \
2584  $(objpfx)tst-single_threaded-mod4.so
2585$(objpfx)tst-single_threaded-pthread-static: $(static-thread-library)
2586
2587$(objpfx)tst-tls-ie: $(shared-thread-library)
2588$(objpfx)tst-tls-ie.out: \
2589  $(objpfx)tst-tls-ie-mod0.so \
2590  $(objpfx)tst-tls-ie-mod1.so \
2591  $(objpfx)tst-tls-ie-mod2.so \
2592  $(objpfx)tst-tls-ie-mod3.so \
2593  $(objpfx)tst-tls-ie-mod4.so \
2594  $(objpfx)tst-tls-ie-mod5.so \
2595  $(objpfx)tst-tls-ie-mod6.so
2596
2597$(objpfx)tst-tls-ie-dlmopen: $(shared-thread-library)
2598$(objpfx)tst-tls-ie-dlmopen.out: \
2599  $(objpfx)tst-tls-ie-mod0.so \
2600  $(objpfx)tst-tls-ie-mod1.so \
2601  $(objpfx)tst-tls-ie-mod2.so \
2602  $(objpfx)tst-tls-ie-mod3.so \
2603  $(objpfx)tst-tls-ie-mod4.so \
2604  $(objpfx)tst-tls-ie-mod5.so \
2605  $(objpfx)tst-tls-ie-mod6.so
2606
2607$(objpfx)argv0test.out: tst-rtld-argv0.sh $(objpfx)ld.so \
2608			$(objpfx)argv0test
2609	$(SHELL) $< $(objpfx)ld.so $(objpfx)argv0test \
2610            '$(test-wrapper-env)' '$(run_program_env)' \
2611            '$(rpath-link)' 'test-argv0' > $@; \
2612    $(evaluate-test)
2613
2614# A list containing the name of the most likely searched subdirectory
2615# of the glibc-hwcaps directory, for each supported architecture (in
2616# other words, the oldest hardware level recognized by the
2617# glibc-hwcaps mechanism for this architecture).  Used to obtain test
2618# coverage for some glibc-hwcaps tests for the widest possible range
2619# of systems.
2620glibc-hwcaps-first-subdirs-for-tests = power9 x86-64-v2 z13
2621
2622# The test modules are parameterized by preprocessor macros.
2623LDFLAGS-libmarkermod1-1.so += -Wl,-soname,libmarkermod1.so
2624LDFLAGS-libmarkermod2-1.so += -Wl,-soname,libmarkermod2.so
2625LDFLAGS-libmarkermod3-1.so += -Wl,-soname,libmarkermod3.so
2626LDFLAGS-libmarkermod4-1.so += -Wl,-soname,libmarkermod4.so
2627LDFLAGS-libmarkermod5-1.so += -Wl,-soname,libmarkermod5.so
2628$(objpfx)libmarkermod%.os : markermodMARKER-VALUE.c
2629	$(compile-command.c) \
2630	  -DMARKER=marker$(firstword $(subst -, ,$*)) \
2631	  -DVALUE=$(lastword $(subst -, ,$*))
2632$(objpfx)libmarkermod1.so: $(objpfx)libmarkermod1-1.so
2633	cp $< $@
2634$(objpfx)libmarkermod2.so: $(objpfx)libmarkermod2-1.so
2635	cp $< $@
2636$(objpfx)libmarkermod3.so: $(objpfx)libmarkermod3-1.so
2637	cp $< $@
2638$(objpfx)libmarkermod4.so: $(objpfx)libmarkermod4-1.so
2639	cp $< $@
2640$(objpfx)libmarkermod5.so: $(objpfx)libmarkermod5-1.so
2641	cp $< $@
2642
2643# tst-glibc-hwcaps-prepend checks that --glibc-hwcaps-prepend is
2644# preferred over auto-detected subdirectories.
2645$(objpfx)tst-glibc-hwcaps-prepend: $(objpfx)libmarkermod1-1.so
2646$(objpfx)glibc-hwcaps/prepend-markermod1/libmarkermod1.so: \
2647  $(objpfx)libmarkermod1-2.so
2648	$(make-target-directory)
2649	cp $< $@
2650$(objpfx)glibc-hwcaps/%/libmarkermod1.so: $(objpfx)libmarkermod1-3.so
2651	$(make-target-directory)
2652	cp $< $@
2653$(objpfx)tst-glibc-hwcaps-prepend.out: \
2654  $(objpfx)tst-glibc-hwcaps-prepend $(objpfx)libmarkermod1.so \
2655  $(patsubst %,$(objpfx)glibc-hwcaps/%/libmarkermod1.so,prepend-markermod1 \
2656    $(glibc-hwcaps-first-subdirs-for-tests))
2657	$(test-wrapper) $(rtld-prefix) \
2658	  --glibc-hwcaps-prepend prepend-markermod1 \
2659	  $< > $@; \
2660	$(evaluate-test)
2661
2662# Like tst-glibc-hwcaps-prepend, but uses a container and loads the
2663# library via ld.so.cache.  Test setup is contained in the test
2664# itself.
2665$(objpfx)tst-glibc-hwcaps-prepend-cache.out: \
2666  $(objpfx)tst-glibc-hwcaps-prepend-cache $(objpfx)libmarkermod1-1.so \
2667  $(objpfx)libmarkermod1-2.so $(objpfx)libmarkermod1-3.so
2668
2669# tst-glibc-hwcaps-mask checks that --glibc-hwcaps-mask can be used to
2670# suppress all auto-detected subdirectories.
2671$(objpfx)tst-glibc-hwcaps-mask: $(objpfx)libmarkermod1-1.so
2672$(objpfx)tst-glibc-hwcaps-mask.out: \
2673  $(objpfx)tst-glibc-hwcaps-mask $(objpfx)libmarkermod1.so \
2674  $(patsubst %,$(objpfx)glibc-hwcaps/%/libmarkermod1.so,\
2675    $(glibc-hwcaps-first-subdirs-for-tests))
2676	$(test-wrapper) $(rtld-prefix) \
2677	  --glibc-hwcaps-mask does-not-exist \
2678	  $< > $@; \
2679	$(evaluate-test)
2680
2681# Generic dependency for sysdeps implementation of
2682# tst-glibc-hwcaps-cache.
2683$(objpfx)tst-glibc-hwcaps-cache.out: $(objpfx)tst-glibc-hwcaps
2684
2685$(objpfx)list-tunables.out: tst-rtld-list-tunables.sh $(objpfx)ld.so
2686	$(SHELL) $< $(objpfx)ld.so '$(test-wrapper-env)' \
2687	    '$(run_program_env)' > $(objpfx)/tst-rtld-list-tunables.out
2688	cmp tst-rtld-list-tunables.exp \
2689	    $(objpfx)/tst-rtld-list-tunables.out > $@; \
2690	$(evaluate-test)
2691
2692tst-dst-static-ENV = LD_LIBRARY_PATH='$$ORIGIN'
2693
2694$(objpfx)tst-rtld-help.out: $(objpfx)ld.so
2695	$(test-wrapper) $(rtld-prefix) --help > $@; \
2696	status=$$?; \
2697	echo "info: ld.so exit status: $$status" >> $@; \
2698	if ! grep -q 'Legacy HWCAP subdirectories under library search path directories' $@; then \
2699	  echo "error: missing subdirectory pattern" >> $@; \
2700	  if test $$status -eq 0; then \
2701	    status=1; \
2702	  fi; \
2703	fi; \
2704	(exit $$status); \
2705	$(evaluate-test)
2706
2707# Reuses tst-tls-many-dynamic-modules
2708$(patsubst %,$(objpfx)%.os,$(tst-tls-many-dynamic-modules-dep)): \
2709  $(objpfx)tst-tls-manydynamic%mod-dep.os : tst-tls-manydynamicmod.c
2710	$(compile-command.c) \
2711	  -DNAME=tls_global_$* -DSETTER=set_value_$* -DGETTER=get_value_$*
2712$(patsubst %,$(objpfx)%.os,$(tst-tls-many-dynamic-modules-dep-bad)): \
2713  $(objpfx)tst-tls-manydynamic%mod-dep-bad.os : tst-tls-manydynamicmod.c
2714	$(compile-command.c) \
2715	  -DNAME=tls_global_$* -DSETTER=set_value_$* -DGETTER=get_value_$*
2716tst-tls20mod-bad.so-no-z-defs = yes
2717# Single dependency.
2718$(objpfx)tst-tls-manydynamic0mod-dep.so: $(objpfx)tst-tls-manydynamic1mod-dep.so
2719# Double dependencies.
2720$(objpfx)tst-tls-manydynamic2mod-dep.so: $(objpfx)tst-tls-manydynamic3mod-dep.so \
2721					 $(objpfx)tst-tls-manydynamic4mod-dep.so
2722# Double dependencies with each dependency depent of another module.
2723$(objpfx)tst-tls-manydynamic5mod-dep.so: $(objpfx)tst-tls-manydynamic6mod-dep.so \
2724					 $(objpfx)tst-tls-manydynamic7mod-dep.so
2725$(objpfx)tst-tls-manydynamic6mod-dep.so: $(objpfx)tst-tls-manydynamic8mod-dep.so
2726$(objpfx)tst-tls-manydynamic7mod-dep.so: $(objpfx)tst-tls-manydynamic8mod-dep.so
2727# Long chain with one double dependency in the middle
2728$(objpfx)tst-tls-manydynamic9mod-dep.so: $(objpfx)tst-tls-manydynamic10mod-dep.so \
2729					 $(objpfx)tst-tls-manydynamic11mod-dep.so
2730$(objpfx)tst-tls-manydynamic10mod-dep.so: $(objpfx)tst-tls-manydynamic12mod-dep.so
2731$(objpfx)tst-tls-manydynamic12mod-dep.so: $(objpfx)tst-tls-manydynamic13mod-dep.so
2732# Long chain with two double depedencies in the middle
2733$(objpfx)tst-tls-manydynamic14mod-dep.so: $(objpfx)tst-tls-manydynamic15mod-dep.so
2734$(objpfx)tst-tls-manydynamic15mod-dep.so: $(objpfx)tst-tls-manydynamic16mod-dep.so \
2735					  $(objpfx)tst-tls-manydynamic17mod-dep.so
2736$(objpfx)tst-tls-manydynamic16mod-dep.so: $(objpfx)tst-tls-manydynamic18mod-dep.so \
2737					  $(objpfx)tst-tls-manydynamic19mod-dep.so
2738# Same but with an invalid module.
2739# Single dependency.
2740$(objpfx)tst-tls-manydynamic0mod-dep-bad.so: $(objpfx)tst-tls20mod-bad.so
2741LDFLAGS-tst-tls-manydynamic0mod-dep-bad.so = -Wl,--no-as-needed
2742# Double dependencies.
2743$(objpfx)tst-tls-manydynamic1mod-dep-bad.so: $(objpfx)tst-tls-manydynamic2mod-dep-bad.so \
2744					     $(objpfx)tst-tls20mod-bad.so
2745LDFLAGS-tst-tls-manydynamic1mod-dep-bad.so = -Wl,--no-as-needed
2746# Double dependencies with each dependency depent of another module.
2747$(objpfx)tst-tls-manydynamic3mod-dep-bad.so: $(objpfx)tst-tls-manydynamic4mod-dep-bad.so \
2748					     $(objpfx)tst-tls-manydynamic5mod-dep-bad.so
2749LDFLAGS-tst-tls-manydynamic3mod-dep-bad.so = -Wl,--no-as-needed
2750$(objpfx)tst-tls-manydynamic4mod-dep-bad.so: $(objpfx)tst-tls20mod-bad.so
2751LDFLAGS-tst-tls-manydynamic4mod-dep-bad.so = -Wl,--no-as-needed
2752$(objpfx)tst-tls-manydynamic5mod-dep-bad.so: $(objpfx)tst-tls20mod-bad.so
2753LDFLAGS-tst-tls-manydynamic5mod-dep-bad.so = -Wl,--no-as-needed
2754# Long chain with one double dependency in the middle
2755$(objpfx)tst-tls-manydynamic6mod-dep-bad.so: $(objpfx)tst-tls-manydynamic7mod-dep-bad.so \
2756					     $(objpfx)tst-tls-manydynamic8mod-dep-bad.so
2757LDFLAGS-tst-tls-manydynamic6mod-dep-bad.so = -Wl,--no-as-needed
2758$(objpfx)tst-tls-manydynamic7mod-dep-bad.so: $(objpfx)tst-tls-manydynamic9mod-dep-bad.so
2759LDFLAGS-tst-tls-manydynamic7mod-dep-bad.so = -Wl,--no-as-needed
2760$(objpfx)tst-tls-manydynamic9mod-dep-bad.so: $(objpfx)tst-tls20mod-bad.so
2761LDFLAGS-tst-tls-manydynamic9mod-dep-bad.so = -Wl,--no-as-needed
2762# Long chain with two double depedencies in the middle
2763$(objpfx)tst-tls-manydynamic10mod-dep-bad.so: $(objpfx)tst-tls-manydynamic11mod-dep-bad.so
2764LDFLAGS-tst-tls-manydynamic10mod-dep-bad.so = -Wl,--no-as-needed
2765$(objpfx)tst-tls-manydynamic11mod-dep-bad.so: $(objpfx)tst-tls-manydynamic12mod-dep-bad.so \
2766					      $(objpfx)tst-tls-manydynamic13mod-dep-bad.so
2767LDFLAGS-tst-tls-manydynamic11mod-dep-bad.so = -Wl,--no-as-needed
2768$(objpfx)tst-tls-manydynamic12mod-dep-bad.so: $(objpfx)tst-tls-manydynamic14mod-dep-bad.so \
2769					      $(objpfx)tst-tls20mod-bad.so
2770LDFLAGS-tst-tls-manydynamic12mod-dep-bad.so = -Wl,--no-as-needed
2771$(objpfx)tst-tls20: $(shared-thread-library)
2772$(objpfx)tst-tls20.out: $(objpfx)tst-tls20mod-bad.so \
2773			$(tst-tls-many-dynamic-modules:%=$(objpfx)%.so) \
2774			$(tst-tls-many-dynamic-modules-dep:%=$(objpfx)%.so) \
2775			$(tst-tls-many-dynamic-modules-dep-bad:%=$(objpfx)%.so) \
2776
2777# Reuses tst-tls-many-dynamic-modules
2778$(objpfx)tst-tls21: $(shared-thread-library)
2779$(objpfx)tst-tls21.out: $(objpfx)tst-tls21mod.so
2780$(objpfx)tst-tls21mod.so: $(tst-tls-many-dynamic-modules:%=$(objpfx)%.so)
2781
2782$(objpfx)tst-getauxval-static.out: $(objpfx)tst-auxvalmod.so
2783tst-getauxval-static-ENV = LD_LIBRARY_PATH=$(objpfx):$(common-objpfx)
2784
2785$(objpfx)tst-dlmopen-gethostbyname.out: $(objpfx)tst-dlmopen-gethostbyname-mod.so
2786
2787$(objpfx)tst-ro-dynamic: $(objpfx)tst-ro-dynamic-mod.so
2788$(objpfx)tst-ro-dynamic-mod.so: $(objpfx)tst-ro-dynamic-mod.os \
2789  tst-ro-dynamic-mod.map
2790	$(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
2791		$(dt-relr-ldflag) \
2792		-Wl,--script=tst-ro-dynamic-mod.map \
2793		$(objpfx)tst-ro-dynamic-mod.os
2794
2795$(objpfx)tst-rtld-run-static.out: $(objpfx)/ldconfig
2796
2797$(objpfx)tst-dl_find_object.out: \
2798  $(objpfx)tst-dl_find_object-mod1.so $(objpfx)tst-dl_find_object-mod2.so
2799$(objpfx)tst-dl_find_object-static.out: \
2800  $(objpfx)tst-dl_find_object-mod1.so $(objpfx)tst-dl_find_object-mod2.so
2801tst-dl_find_object-static-ENV = $(static-dlopen-environment)
2802CFLAGS-tst-dl_find_object.c += -funwind-tables
2803CFLAGS-tst-dl_find_object-static.c += -funwind-tables
2804LDFLAGS-tst-dl_find_object-static += -Wl,--eh-frame-hdr
2805CFLAGS-tst-dl_find_object-mod1.c += -funwind-tables
2806CFLAGS-tst-dl_find_object-mod2.c += -funwind-tables
2807LDFLAGS-tst-dl_find_object-mod2.so += -Wl,--enable-new-dtags,-z,nodelete
2808$(objpfx)tst-dl_find_object-threads: $(shared-thread-library)
2809CFLAGS-tst-dl_find_object-threads.c += -funwind-tables
2810$(objpfx)tst-dl_find_object-threads.out: \
2811  $(objpfx)tst-dl_find_object-mod1.so \
2812  $(objpfx)tst-dl_find_object-mod2.so \
2813  $(objpfx)tst-dl_find_object-mod3.so \
2814  $(objpfx)tst-dl_find_object-mod4.so \
2815  $(objpfx)tst-dl_find_object-mod5.so \
2816  $(objpfx)tst-dl_find_object-mod6.so \
2817  $(objpfx)tst-dl_find_object-mod7.so \
2818  $(objpfx)tst-dl_find_object-mod8.so \
2819  $(objpfx)tst-dl_find_object-mod9.so
2820CFLAGS-tst-dl_find_object-mod3.c += -funwind-tables
2821CFLAGS-tst-dl_find_object-mod4.c += -funwind-tables
2822CFLAGS-tst-dl_find_object-mod5.c += -funwind-tables
2823CFLAGS-tst-dl_find_object-mod6.c += -funwind-tables
2824CFLAGS-tst-dl_find_object-mod7.c += -funwind-tables
2825CFLAGS-tst-dl_find_object-mod8.c += -funwind-tables
2826CFLAGS-tst-dl_find_object-mod9.c += -funwind-tables
2827
2828$(objpfx)tst-p_alignmod-base.so: $(libsupport)
2829LDFLAGS-tst-p_alignmod-base.so += -Wl,-z,max-page-size=0x200000
2830
2831$(objpfx)tst-p_align1: $(objpfx)tst-p_alignmod1.so
2832
2833# Make a copy of tst-p_alignmod-base.so and lower p_align of the first
2834# PT_LOAD segment.
2835$(objpfx)tst-p_alignmod1.so: $(objpfx)tst-p_alignmod-base.so
2836	rm -f $@
2837	cp $(objpfx)tst-p_alignmod-base.so $@
2838	$(PYTHON) $(..)scripts/tst-elf-edit.py -a half $@
2839
2840$(objpfx)tst-p_align2: $(objpfx)tst-p_alignmod2.so
2841
2842# Make a copy of tst-p_alignmod-base.so and update p_align of the first
2843# PT_LOAD segment.
2844$(objpfx)tst-p_alignmod2.so: $(objpfx)tst-p_alignmod-base.so
2845	rm -f $@
2846	cp $(objpfx)tst-p_alignmod-base.so $@
2847	$(PYTHON) $(..)scripts/tst-elf-edit.py -a 1 $@
2848
2849LDFLAGS-tst-p_alignmod3.so += -Wl,-z,max-page-size=0x100,-z,common-page-size=0x100
2850
2851$(objpfx)tst-p_align3: $(objpfx)tst-p_alignmod3.so
2852$(objpfx)tst-p_align3.out: tst-p_align3.sh $(objpfx)tst-p_align3
2853	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
2854	$(evaluate-test)
2855
2856$(objpfx)check-abi-version-libc.out: $(common-objpfx)libc.so
2857	LC_ALL=C $(READELF) -V -W $< \
2858		| sed -ne '/.gnu.version_d/, /.gnu.version_r/ p' \
2859		| grep GLIBC_ABI_DT_RELR > $@; \
2860	$(evaluate-test)
2861
2862$(objpfx)check-tst-relr-pie.out: $(objpfx)tst-relr-pie
2863	LC_ALL=C $(OBJDUMP) -p $< \
2864		| sed -ne '/required from libc.so/,$$ p' \
2865		| grep GLIBC_ABI_DT_RELR > $@; \
2866	$(evaluate-test)
2867
2868# The test checks if a DT_RELR shared library without DT_NEEDED works as
2869# intended, so it uses an explicit link rule.
2870$(objpfx)tst-relr2: $(objpfx)tst-relr-mod2.so
2871$(objpfx)tst-relr-mod2.so: $(objpfx)tst-relr-mod2.os
2872	$(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \
2873	$(LDFLAGS-soname-fname) \
2874	-shared -o $@.new $(filter-out $(map-file),$^)
2875	$(call after-link,$@.new)
2876	mv -f $@.new $@
2877
2878# The test checks if a DT_RELR shared library without DT_VERNEED works as
2879# intended, so it uses an explicit link rule.
2880$(objpfx)tst-relr3: $(objpfx)tst-relr-mod3a.so
2881$(objpfx)tst-relr-mod3b.so: $(objpfx)tst-relr-mod3b.os
2882	$(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \
2883	$(LDFLAGS-soname-fname) \
2884	-shared -o $@.new $(filter-out $(map-file),$^)
2885	$(call after-link,$@.new)
2886	mv -f $@.new $@
2887
2888$(objpfx)tst-relr-mod3a.so: $(objpfx)tst-relr-mod3a.os \
2889  $(objpfx)tst-relr-mod3b.so
2890	$(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \
2891	$(LDFLAGS-soname-fname) \
2892	-shared -o $@.new $(filter-out $(map-file),$^)
2893	$(call after-link,$@.new)
2894	mv -f $@.new $@
2895
2896# The test checks if a DT_RELR shared library without libc.so on DT_NEEDED
2897# works as intended, so it uses an explicit link rule.
2898$(objpfx)tst-relr4: $(objpfx)tst-relr-mod4a.so
2899$(objpfx)tst-relr-mod4b.so: $(objpfx)tst-relr-mod4b.os
2900	$(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \
2901	$(LDFLAGS-soname-fname) \
2902	-Wl,--version-script=tst-relr-mod4b.map \
2903	-shared -o $@.new $(filter-out $(map-file),$^)
2904	$(call after-link,$@.new)
2905	mv -f $@.new $@
2906
2907$(objpfx)tst-relr-mod4a.so: $(objpfx)tst-relr-mod4a.os \
2908  $(objpfx)tst-relr-mod4b.so
2909	$(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \
2910	$(LDFLAGS-soname-fname) \
2911	-shared -o $@.new $(filter-out $(map-file),$^)
2912	$(call after-link,$@.new)
2913	mv -f $@.new $@
2914
2915LDFLAGS-libtracemod1-1.so += -Wl,-soname,libtracemod1.so
2916LDFLAGS-libtracemod2-1.so += -Wl,-soname,libtracemod2.so
2917LDFLAGS-libtracemod3-1.so += -Wl,-soname,libtracemod3.so
2918LDFLAGS-libtracemod4-1.so += -Wl,-soname,libtracemod4.so
2919LDFLAGS-libtracemod5-1.so += -Wl,-soname,libtracemod5.so
2920
2921$(objpfx)libtracemod1-1.so: $(objpfx)libtracemod2-1.so \
2922			    $(objpfx)libtracemod3-1.so
2923$(objpfx)libtracemod2-1.so: $(objpfx)libtracemod4-1.so \
2924			    $(objpfx)libtracemod5-1.so
2925
2926define libtracemod-x
2927$(objpfx)libtracemod$(1)/libtracemod$(1).so: $(objpfx)libtracemod$(1)-1.so
2928	$$(make-target-directory)
2929	cp $$< $$@
2930endef
2931libtracemod-suffixes = 1 2 3 4 5
2932$(foreach i,$(libtracemod-suffixes), $(eval $(call libtracemod-x,$(i))))
2933
2934define tst-trace-skeleton
2935$(objpfx)tst-trace$(1).out: $(objpfx)libtracemod1/libtracemod1.so \
2936			    $(objpfx)libtracemod2/libtracemod2.so \
2937			    $(objpfx)libtracemod3/libtracemod3.so \
2938			    $(objpfx)libtracemod4/libtracemod4.so \
2939			    $(objpfx)libtracemod5/libtracemod5.so \
2940			    $(..)scripts/tst-ld-trace.py \
2941			    tst-trace$(1).exp
2942	${ $(PYTHON) $(..)scripts/tst-ld-trace.py \
2943	    "$(test-wrapper-env) $(elf-objpfx)$(rtld-installed-name) \
2944	    --library-path $(common-objpfx):$(strip $(2)) \
2945	    $(objpfx)libtracemod1/libtracemod1.so" tst-trace$(1).exp \
2946	} > $$@; $$(evaluate-test)
2947endef
2948
2949$(eval $(call tst-trace-skeleton,1,))
2950$(eval $(call tst-trace-skeleton,2,\
2951	$(objpfx)libtracemod2))
2952$(eval $(call tst-trace-skeleton,3,\
2953	$(objpfx)libtracemod2:$(objpfx)libtracemod3))
2954$(eval $(call tst-trace-skeleton,4,\
2955	$(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4))
2956$(eval $(call tst-trace-skeleton,5,\
2957	$(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4:$(objpfx)libtracemod5))
2958
2959$(objpfx)tst-tls-allocation-failure-static-patched: \
2960  $(objpfx)tst-tls-allocation-failure-static $(..)scripts/tst-elf-edit.py
2961	cp $< $@
2962	$(PYTHON) $(..)scripts/tst-elf-edit.py --maximize-tls-size $@
2963
2964$(objpfx)tst-tls-allocation-failure-static-patched.out: \
2965  $(objpfx)tst-tls-allocation-failure-static-patched
2966	$< > $@ 2>&1; echo "status: $$?" >> $@
2967	grep -q '^Fatal glibc error: Cannot allocate TLS block$$' $@ \
2968	  && grep -q '^status: 127$$' $@; \
2969	  $(evaluate-test)
2970