blob: 63a535502c15e32eb4f21feaefa3cbf5be6d8afa [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# Copyright (C) 1995-2016 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# <http://www.gnu.org/licenses/>.
17
18# Makefile for elf subdirectory of GNU C Library.
19
20subdir := elf
21
22include ../Makeconfig
23
24headers = elf.h bits/elfclass.h link.h bits/link.h
25routines = $(all-dl-routines) dl-support dl-iteratephdr \
26 dl-addr enbl-secure dl-profstub \
27 dl-origin dl-libc dl-sym dl-tsd dl-sysdep
28
29# The core dynamic linking functions are in libc for the static and
30# profiled libraries.
31dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
32 runtime error init fini debug misc \
33 version profile conflict tls origin scope \
34 execstack caller open close trampoline)
35ifeq (yes,$(use-ldconfig))
36dl-routines += dl-cache
37endif
38all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
39# But they are absent from the shared libc, because that code is in ld.so.
40elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
41 dl-sysdep
42shared-only-routines += dl-caller
43
44# ld.so uses those routines, plus some special stuff for being the program
45# interpreter and operating independent of libc.
46rtld-routines = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal
47all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
48
49CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
50CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
51CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
52
53ifeq ($(unwind-find-fde),yes)
54routines += unwind-dw2-fde-glibc
55shared-only-routines += unwind-dw2-fde-glibc
56endif
57
58before-compile += $(objpfx)trusted-dirs.h
59generated += trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
60generated-dirs += for-renamed
61
62ifeq ($(build-shared),yes)
63ld-map = $(common-objpfx)ld.map
64endif
65
66ifeq (yes,$(build-shared))
67extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
68generated += librtld.os dl-allobjs.os ld.so ldd
69install-others = $(inst_rtlddir)/$(rtld-installed-name)
70install-bin-script = ldd
71endif
72
73others = sprof sln
74install-bin = sprof
75others-static = sln
76install-rootsbin = sln
77sln-modules := static-stubs
78extra-objs += $(sln-modules:=.o)
79
80ifeq (yes,$(use-ldconfig))
81ifeq (yes,$(build-shared))
82others-static += ldconfig
83others += ldconfig
84install-rootsbin += ldconfig
85
86ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon static-stubs
87extra-objs += $(ldconfig-modules:=.o)
88endif
89endif
90
91# To find xmalloc.c and xstrdup.c
92vpath %.c ../locale/programs
93
94ifeq ($(build-shared),yes)
95extra-objs += sotruss-lib.os sotruss-lib.so
96install-others += $(inst_auditdir)/sotruss-lib.so
97install-bin-script += sotruss
98generated += sotruss
99libof-sotruss-lib = extramodules
100$(objpfx)sotruss-lib.so: $(objpfx)sotruss-lib.os
101 $(build-module-asneeded)
102$(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
103 $(common-objpfx)libc_nonshared.a
104
105$(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
106 sed -e 's%@BASH@%$(BASH)%g' \
107 -e 's%@VERSION@%$(version)%g' \
108 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g' \
109 -e 's%@PREFIX@%$(prefix)%g' \
110 -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
111 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
112 < $< > $@.new
113 chmod 555 $@.new
114 mv -f $@.new $@
115$(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
116 $(do-install-program)
117endif
118
119tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
120 tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
121 tst-auxv
122tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
123 tst-leaks1-static tst-array1-static tst-array5-static \
124 tst-ptrguard1-static tst-dl-iter-static \
125 tst-tlsalign-static tst-tlsalign-extern-static
126ifeq (yes,$(build-shared))
127tests-static += tst-tls9-static
128tst-tls9-static-ENV = \
129 LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
130endif
131tests += $(tests-static)
132ifeq (yes,$(build-shared))
133tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
134 constload1 order noload filter unload \
135 reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
136 nodlopen nodlopen2 neededtest neededtest2 \
137 neededtest3 neededtest4 unload2 lateglobal initfirst global \
138 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
139 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
140 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \
141 tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \
142 tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \
143 tst-dlmodcount tst-dlopenrpath tst-deep1 \
144 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
145 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
146 tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
147 tst-stackguard1 tst-addr1 tst-thrlock \
148 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
149 tst-nodelete) \
150 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
151 tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
152 tst-nodelete2 tst-audit11 tst-audit12
153# reldep9
154ifeq ($(build-hardcoded-path-in-tests),yes)
155tests += tst-dlopen-aout
156LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
157endif
158test-srcs = tst-pathopt
159selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
160ifneq ($(selinux-enabled),1)
161tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
162endif
163endif
164ifeq ($(run-built-tests),yes)
165tests-special += $(objpfx)tst-leaks1-mem.out \
166 $(objpfx)tst-leaks1-static-mem.out $(objpfx)noload-mem.out
167endif
168tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
169tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
170tlsmod17a-modules = $(addprefix tst-tlsmod17a, $(tlsmod17a-suffixes))
171tlsmod18a-modules = $(addprefix tst-tlsmod18a, $(tlsmod17a-suffixes))
172extra-test-objs += $(tlsmod17a-modules:=.os) $(tlsmod18a-modules:=.os)
173test-extras += tst-tlsmod17a tst-tlsmod18a
174modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
175 testobj1_1 failobj constload2 constload3 unloadmod \
176 dep1 dep2 dep3 dep4 vismod1 vismod2 vismod3 \
177 nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
178 nodel2mod1 nodel2mod2 nodel2mod3 \
179 nodlopenmod nodlopenmod2 filtmod1 filtmod2 \
180 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
181 reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
182 neededobj1 neededobj2 neededobj3 neededobj4 \
183 neededobj5 neededobj6 firstobj globalmod1 \
184 unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
185 dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
186 reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
187 reldep7mod1 reldep7mod2 \
188 tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
189 tst-tlsmod5 tst-tlsmod6 tst-tlsmod7 tst-tlsmod8 \
190 tst-tlsmod9 tst-tlsmod10 tst-tlsmod11 tst-tlsmod12 \
191 tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \
192 tst-tlsmod15a tst-tlsmod15b tst-tlsmod16a tst-tlsmod16b \
193 $(tlsmod17a-modules) tst-tlsmod17b $(tlsmod18a-modules) \
194 tst-tls19mod1 tst-tls19mod2 tst-tls19mod3 \
195 circlemod1 circlemod1a circlemod2 circlemod2a \
196 circlemod3 circlemod3a \
197 reldep8mod1 reldep8mod2 reldep8mod3 \
198 reldep9mod1 reldep9mod2 reldep9mod3 \
199 tst-alignmod tst-alignmod2 \
200 $(modules-execstack-$(have-z-execstack)) \
201 tst-dlopenrpathmod tst-deep1mod1 tst-deep1mod2 tst-deep1mod3 \
202 tst-dlmopen1mod tst-auditmod1 \
203 unload3mod1 unload3mod2 unload3mod3 unload3mod4 \
204 unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
205 unload6mod1 unload6mod2 unload6mod3 \
206 unload7mod1 unload7mod2 \
207 unload8mod1 unload8mod1x unload8mod2 unload8mod3 \
208 order2mod1 order2mod2 order2mod3 order2mod4 \
209 tst-unique1mod1 tst-unique1mod2 \
210 tst-unique2mod1 tst-unique2mod2 \
211 tst-auditmod9a tst-auditmod9b \
212 $(if $(CXX),tst-unique3lib tst-unique3lib2 tst-unique4lib \
213 tst-nodelete-uniquemod tst-nodelete-rtldmod \
214 tst-nodelete-zmod) \
215 tst-initordera1 tst-initorderb1 \
216 tst-initordera2 tst-initorderb2 \
217 tst-initordera3 tst-initordera4 \
218 tst-initorder2a tst-initorder2b tst-initorder2c \
219 tst-initorder2d \
220 tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
221 tst-array5dep tst-null-argv-lib \
222 tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod \
223 tst-audit11mod1 tst-audit11mod2 tst-auditmod11 \
224 tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12
225ifeq (yes,$(have-protected-data))
226modules-names += tst-protected1moda tst-protected1modb
227tests += tst-protected1a tst-protected1b
228$(objpfx)tst-protected1a: $(addprefix $(objpfx),tst-protected1moda.so tst-protected1modb.so)
229$(objpfx)tst-protected1b: $(addprefix $(objpfx),tst-protected1modb.so tst-protected1moda.so)
230tst-protected1modb.so-no-z-defs = yes
231# These tests fail with GCC versions prior to 5.1 and with some versions
232# of binutils. See https://sourceware.org/bugzilla/show_bug.cgi?id=17709
233# and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 for details.
234# Perhaps in future we can make these XFAILs conditional on some detection
235# of compiler/linker behavior/version.
236test-xfail-tst-protected1a = yes
237test-xfail-tst-protected1b = yes
238endif
239ifeq (yesyes,$(have-fpie)$(build-shared))
240modules-names += tst-piemod1
241tests += tst-pie1 tst-pie2
242tests-pie += tst-pie1 tst-pie2
243tests += vismain
244tests-pie += vismain
245CFLAGS-vismain.c = $(PIE-ccflag)
246endif
247modules-execstack-yes = tst-execstack-mod
248extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
249# We need this variable to be sure the test modules get the right CPPFLAGS.
250test-extras += $(modules-names)
251
252# filtmod1.so has a special rule
253modules-names-nobuild := filtmod1
254
255ifneq (no,$(multi-arch))
256tests-static += ifuncmain1static ifuncmain1picstatic \
257 ifuncmain2static ifuncmain2picstatic \
258 ifuncmain4static ifuncmain4picstatic \
259 ifuncmain5static ifuncmain5picstatic \
260 ifuncmain7static ifuncmain7picstatic
261
262ifeq (yes,$(build-shared))
263tests += ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
264 ifuncmain1staticpic \
265 ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4 \
266 ifuncmain5 ifuncmain5pic ifuncmain5staticpic \
267 ifuncmain7 ifuncmain7pic
268ifunc-test-modules = ifuncdep1 ifuncdep1pic ifuncdep2 ifuncdep2pic \
269 ifuncdep5 ifuncdep5pic
270extra-test-objs += $(ifunc-test-modules:=.o)
271test-extras += $(ifunc-test-modules)
272ifeq (yes,$(have-fpie))
273ifunc-pie-tests = ifuncmain1pie ifuncmain1vispie ifuncmain1staticpie \
274 ifuncmain5pie ifuncmain6pie ifuncmain7pie
275tests += $(ifunc-pie-tests)
276tests-pie += $(ifunc-pie-tests)
277endif
278modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
279endif
280endif
281
282ifeq (yes,$(build-shared))
283ifeq ($(run-built-tests),yes)
284tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out
285endif
286tests-special += $(objpfx)check-textrel.out $(objpfx)check-execstack.out \
287 $(objpfx)check-localplt.out
288endif
289
290ifeq ($(run-built-tests),yes)
291tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
292 $(objpfx)tst-array1-static-cmp.out \
293 $(objpfx)tst-array2-cmp.out $(objpfx)tst-array3-cmp.out \
294 $(objpfx)tst-array4-cmp.out $(objpfx)tst-array5-cmp.out \
295 $(objpfx)tst-array5-static-cmp.out $(objpfx)order2-cmp.out \
296 $(objpfx)tst-initorder-cmp.out \
297 $(objpfx)tst-initorder2-cmp.out $(objpfx)tst-unused-dep.out \
298 $(objpfx)tst-unused-dep-cmp.out
299endif
300
301check-abi: $(objpfx)check-abi-ld.out
302tests-special += $(objpfx)check-abi-ld.out
303update-abi: update-abi-ld
304update-all-abi: update-all-abi-ld
305
306ifeq ($(have-glob-dat-reloc),yes)
307tests += tst-prelink
308ifeq ($(run-built-tests),yes)
309tests-special += $(objpfx)tst-prelink-cmp.out
310endif
311endif
312
313include ../Rules
314
315ifeq (yes,$(build-shared))
316# Make sure these things are built in the `make lib' pass so they can be used
317# to run programs during the `make others' pass.
318lib-noranlib: $(objpfx)$(rtld-installed-name) \
319 $(addprefix $(objpfx),$(extra-objs))
320endif
321
322# Command to link into a larger single relocatable object.
323reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
324
325$(objpfx)sotruss-lib.so: $(shlib-lds)
326
327$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
328 $(reloc-link) -o $@ $^
329
330# Link together the dynamic linker into a single relocatable object.
331# First we do a link against libc_pic.a just to get a link map,
332# and discard the object produced by that link. From the link map
333# we can glean all the libc modules that need to go into the dynamic
334# linker. Then we do a recursive make that goes into all the subdirs
335# those modules come from and builds special rtld-foo.os versions that
336# are compiled with special flags, and puts these modules into rtld-libc.a
337# for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
338
339$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
340 @-rm -f $@T
341 $(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
342 rm -f $@.o
343 mv -f $@T $@
344
345$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
346 LC_ALL=C \
347 sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
348 $< | \
349 while read lib file; do \
350 case $$lib in \
351 libc_pic.a) \
352 LC_ALL=C fgrep -l /$$file \
353 $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
354 LC_ALL=C \
355 sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
356 ;; \
357 */*.a) \
358 echo rtld-$${lib%%/*} += $$file ;; \
359 *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
360 esac; \
361 done > $@T
362 echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
363 | LC_ALL=C sort -u` >> $@T
364 mv -f $@T $@
365
366$(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
367 $(MAKE) -f $< -f rtld-Rules
368
369$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
370 $(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
371 -Wl,-Map,$@.map
372
373generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
374
375z-now-yes = -Wl,-z,now
376
377$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
378# Link into a temporary file so that we don't touch $@ at all
379# if the sanity check below fails.
380 $(LINK.o) -nostdlib -nostartfiles -shared -o $@.new \
381 $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
382 $(filter-out $(map-file),$^) $(load-map-file) \
383 -Wl,-soname=$(rtld-installed-name) \
384 -Wl,-defsym=_begin=0
385 $(call after-link,$@.new)
386 $(READELF) -s $@.new \
387 | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
388 mv -f $@.new $@
389
390ifeq (yes,$(build-shared))
391# interp.c exists just to get the runtime linker path into libc.so.
392$(objpfx)interp.os: $(common-objpfx)runtime-linker.h
393endif
394
395ifneq (ld.so,$(rtld-installed-name))
396# Make sure ld.so.1 exists in the build directory so we can link
397# against it.
398$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
399 $(make-link)
400generated += $(rtld-installed-name)
401endif
402
403# Build a file mentioning all trustworthy directories to look for shared
404# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
405# add directories to the list by defining $(user-defined-trusted-dirs)
406# before starting make.
407$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
408$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
409 $(make-target-directory)
410 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
411 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
412 echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
413 $(move-if-change) ${@:st=T} ${@:st=h}
414 touch $@
415CPPFLAGS-dl-load.c = -I$(objpfx). -I$(csu-objpfx).
416
417ifeq (yes,$(build-shared))
418$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
419 $(make-target-directory)
420 $(do-install-program)
421
422$(inst_rtlddir)/$(rtld-installed-name): \
423 $(inst_slibdir)/$(rtld-version-installed-name) \
424 $(inst_slibdir)/libc-$(version).so
425 $(make-target-directory)
426 $(make-shlib-link)
427
428# Special target called by parent to install just the dynamic linker.
429.PHONY: ldso_install
430ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
431endif
432
433
434ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
435 -e 's%@VERSION@%$(version)%g' \
436 -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
437 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
438 -e 's%@BASH@%$(BASH)%g' \
439 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
440
441ifeq ($(ldd-rewrite-script),no)
442define gen-ldd
443LC_ALL=C sed $(ldd-rewrite) < $< > $@.new
444endef
445else
446define gen-ldd
447LC_ALL=C sed $(ldd-rewrite) < $< \
448| LC_ALL=C sed -f $(patsubst $(..)/%,/%,$(..)$(ldd-rewrite-script)) > $@.new
449endef
450endif
451
452$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
453 $(common-objpfx)config.make
454 $(gen-ldd)
455 chmod 555 $@.new
456 mv -f $@.new $@
457
458$(objpfx)sprof: $(libdl)
459
460$(objpfx)sln: $(sln-modules:%=$(objpfx)%.o)
461
462$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
463
464SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
465CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
466 -D'SLIBDIR="$(slibdir)"'
467libof-ldconfig = ldconfig
468CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
469CFLAGS-cache.c = $(SYSCONF-FLAGS)
470CFLAGS-rtld.c = $(SYSCONF-FLAGS)
471
472cpp-srcs-left := $(all-rtld-routines:=.os)
473lib := rtld
474include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
475
476test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
477generated += $(addsuffix .so,$(strip $(modules-names)))
478
479$(objpfx)testobj1.so: $(libdl)
480$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
481$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
482$(objpfx)testobj3.so: $(libdl)
483$(objpfx)testobj4.so: $(libdl)
484$(objpfx)testobj5.so: $(libdl)
485$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
486$(objpfx)failobj.so: $(objpfx)testobj6.so
487$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
488$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
489$(objpfx)dep4.so: $(objpfx)dep3.so
490$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
491$(objpfx)nextmod1.so: $(libdl)
492$(objpfx)neededobj1.so: $(libdl)
493$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
494$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
495$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
496 $(objpfx)neededobj3.so $(libdl)
497$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
498$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
499$(objpfx)ltglobmod2.so: $(libdl)
500$(objpfx)firstobj.so: $(shared-thread-library)
501$(objpfx)globalmod1.so: $(libdl)
502$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
503$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
504$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
505$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
506$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
507$(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
508$(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
509$(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
510$(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
511$(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
512$(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
513$(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
514$(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
515$(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
516$(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
517# For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
518$(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
519$(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
520$(objpfx)tst-tls19mod1.so: $(objpfx)tst-tls19mod2.so $(objpfx)tst-tls19mod3.so
521$(objpfx)tst-tls19mod3.so: $(objpfx)ld.so
522$(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
523$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
524$(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
525$(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
526$(objpfx)unload3mod1.so: $(objpfx)unload3mod3.so
527$(objpfx)unload3mod2.so: $(objpfx)unload3mod3.so
528$(objpfx)unload3mod3.so: $(objpfx)unload3mod4.so
529$(objpfx)unload4mod1.so: $(objpfx)unload4mod2.so $(objpfx)unload4mod3.so
530$(objpfx)unload4mod2.so: $(objpfx)unload4mod4.so $(objpfx)unload4mod3.so
531$(objpfx)unload6mod1.so: $(libdl)
532$(objpfx)unload6mod2.so: $(libdl)
533$(objpfx)unload6mod3.so: $(libdl)
534$(objpfx)unload7mod1.so: $(libdl)
535$(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
536$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
537$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
538$(objpfx)unload8mod3.so: $(libdl)
539$(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
540$(objpfx)tst-initorderb2.so: $(objpfx)tst-initorderb1.so $(objpfx)tst-initordera2.so
541$(objpfx)tst-initordera3.so: $(objpfx)tst-initorderb2.so $(objpfx)tst-initorderb1.so
542$(objpfx)tst-initordera4.so: $(objpfx)tst-initordera3.so
543$(objpfx)tst-initorder: $(objpfx)tst-initordera4.so $(objpfx)tst-initordera1.so $(objpfx)tst-initorderb2.so
544$(objpfx)tst-null-argv: $(objpfx)tst-null-argv-lib.so
545$(objpfx)tst-tlsalign: $(objpfx)tst-tlsalign-lib.so
546$(objpfx)tst-nodelete-opened.out: $(objpfx)tst-nodelete-opened-lib.so
547$(objpfx)tst-nodelete-opened: $(libdl)
548
549$(objpfx)tst-tlsalign-extern: $(objpfx)tst-tlsalign-vars.o
550$(objpfx)tst-tlsalign-extern-static: $(objpfx)tst-tlsalign-vars.o
551
552tst-null-argv-ENV = LD_DEBUG=all LD_DEBUG_OUTPUT=$(objpfx)tst-null-argv.debug.out
553LDFLAGS-nodel2mod3.so = $(no-as-needed)
554LDFLAGS-reldepmod5.so = $(no-as-needed)
555LDFLAGS-reldep6mod1.so = $(no-as-needed)
556LDFLAGS-reldep6mod4.so = $(no-as-needed)
557LDFLAGS-reldep8mod3.so = $(no-as-needed)
558LDFLAGS-unload4mod1.so = $(no-as-needed)
559LDFLAGS-unload4mod2.so = $(no-as-needed)
560LDFLAGS-tst-initorder = $(no-as-needed)
561LDFLAGS-tst-initordera2.so = $(no-as-needed)
562LDFLAGS-tst-initordera3.so = $(no-as-needed)
563LDFLAGS-tst-initordera4.so = $(no-as-needed)
564LDFLAGS-tst-initorderb2.so = $(no-as-needed)
565LDFLAGS-tst-tlsmod5.so = -nostdlib $(no-as-needed)
566LDFLAGS-tst-tlsmod6.so = -nostdlib $(no-as-needed)
567
568testobj1.so-no-z-defs = yes
569testobj3.so-no-z-defs = yes
570testobj4.so-no-z-defs = yes
571testobj5.so-no-z-defs = yes
572testobj6.so-no-z-defs = yes
573failobj.so-no-z-defs = yes
574constload2.so-no-z-defs = yes
575constload3.so-no-z-defs = yes
576nodelmod1.so-no-z-defs = yes
577nodelmod2.so-no-z-defs = yes
578nodelmod4.so-no-z-defs = yes
579nodel2mod2.so-no-z-defs = yes
580reldepmod2.so-no-z-defs = yes
581reldepmod3.so-no-z-defs = yes
582reldepmod4.so-no-z-defs = yes
583reldep4mod4.so-no-z-defs = yes
584reldep4mod2.so-no-z-defs = yes
585ltglobmod2.so-no-z-defs = yes
586dblloadmod3.so-no-z-defs = yes
587tst-tlsmod1.so-no-z-defs = yes
588tst-tlsmod2.so-no-z-defs = yes
589tst-tlsmod3.so-no-z-defs = yes
590tst-tlsmod4.so-no-z-defs = yes
591tst-tlsmod7.so-no-z-defs = yes
592tst-tlsmod8.so-no-z-defs = yes
593tst-tlsmod9.so-no-z-defs = yes
594tst-tlsmod10.so-no-z-defs = yes
595tst-tlsmod12.so-no-z-defs = yes
596tst-tlsmod14a.so-no-z-defs = yes
597tst-tlsmod14b.so-no-z-defs = yes
598tst-tlsmod15a.so-no-z-defs = yes
599tst-tlsmod16b.so-no-z-defs = yes
600circlemod2.so-no-z-defs = yes
601circlemod3.so-no-z-defs = yes
602circlemod3a.so-no-z-defs = yes
603reldep8mod2.so-no-z-defs = yes
604reldep9mod1.so-no-z-defs = yes
605unload3mod4.so-no-z-defs = yes
606unload4mod1.so-no-z-defs = yes
607ifuncmod1.so-no-z-defs = yes
608ifuncmod5.so-no-z-defs = yes
609ifuncmod6.so-no-z-defs = yes
610tst-auditmod9a.so-no-z-defs = yes
611tst-auditmod9b.so-no-z-defs = yes
612tst-nodelete-uniquemod.so-no-z-defs = yes
613tst-nodelete-rtldmod.so-no-z-defs = yes
614tst-nodelete-zmod.so-no-z-defs = yes
615tst-nodelete2mod.so-no-z-defs = yes
616
617ifeq ($(build-shared),yes)
618# Build all the modules even when not actually running test programs.
619tests: $(test-modules)
620endif
621
622$(objpfx)loadtest: $(libdl)
623LDFLAGS-loadtest = -rdynamic
624
625$(objpfx)loadtest.out: $(test-modules)
626
627$(objpfx)neededtest: $(libdl)
628$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
629 $(objpfx)neededobj3.so
630
631$(objpfx)neededtest2: $(libdl)
632$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
633 $(objpfx)neededobj3.so
634
635$(objpfx)neededtest3: $(libdl)
636$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
637 $(objpfx)neededobj3.so $(objpfx)neededobj4.so
638
639$(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
640$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
641
642$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
643LDFLAGS-restest1 = -rdynamic
644
645$(objpfx)restest2: $(libdl)
646LDFLAGS-restest2 = -rdynamic
647
648$(objpfx)restest1.out: $(test-modules)
649
650preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
651$(objpfx)preloadtest: $(objpfx)testobj6.so
652LDFLAGS-preloadtest = -rdynamic
653$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
654preloadtest-ENV = \
655 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
656
657$(objpfx)loadfail: $(libdl)
658LDFLAGS-loadfail = -rdynamic
659
660$(objpfx)loadfail.out: $(objpfx)failobj.so
661
662$(objpfx)multiload: $(libdl)
663LDFLAGS-multiload = -rdynamic
664CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
665
666$(objpfx)multiload.out: $(objpfx)testobj1.so
667
668$(objpfx)origtest: $(libdl)
669LDFLAGS-origtest = -rdynamic
670$(objpfx)origtest.out: $(objpfx)testobj1.so
671
672ifeq ($(have-thread-library),yes)
673$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
674else
675$(objpfx)resolvfail: $(libdl)
676endif
677
678$(objpfx)constload1: $(libdl)
679$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
680
681$(objpfx)circleload1: $(libdl)
682$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
683 $(objpfx)circlemod1a.so
684
685$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
686$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
687$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
688$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
689
690$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
691
692$(objpfx)order-cmp.out: $(objpfx)order.out
693 (echo "0123456789" | cmp $< -) > $@; \
694 $(evaluate-test)
695
696$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
697$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
698vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
699
700$(objpfx)noload: $(objpfx)testobj1.so $(libdl)
701LDFLAGS-noload = -rdynamic $(no-as-needed)
702$(objpfx)noload.out: $(objpfx)testobj5.so
703
704$(objpfx)noload-mem.out: $(objpfx)noload.out
705 $(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@; \
706 $(evaluate-test)
707noload-ENV = MALLOC_TRACE=$(objpfx)noload.mtrace
708
709LDFLAGS-nodelete = -rdynamic
710LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
711LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
712$(objpfx)nodelete: $(libdl)
713$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
714 $(objpfx)nodelmod3.so
715
716LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
717$(objpfx)nodlopen: $(libdl)
718$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
719
720$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
721$(objpfx)nodlopen2: $(libdl)
722$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
723
724$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
725 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
726 -L$(subst :, -L,$(rpath-link)) \
727 -Wl,-rpath-link=$(rpath-link) \
728 $< -Wl,-F,$(objpfx)filtmod2.so
729$(objpfx)filter: $(objpfx)filtmod1.so
730
731$(objpfx)unload: $(libdl)
732$(objpfx)unload.out: $(objpfx)unloadmod.so
733
734$(objpfx)reldep: $(libdl)
735$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
736
737$(objpfx)reldep2: $(libdl)
738$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
739
740$(objpfx)reldep3: $(libdl)
741$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
742
743$(objpfx)reldep4: $(libdl)
744$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
745
746$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
747LDFLAGS-next = $(no-as-needed)
748
749$(objpfx)unload2: $(libdl)
750$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
751
752$(objpfx)lateglobal: $(libdl)
753$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
754
755$(objpfx)tst-pathopt: $(libdl)
756$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
757 $(objpfx)pathoptobj.so
758 $(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
759 '$(run-program-env)'; \
760 $(evaluate-test)
761
762$(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
763 $(SHELL) $^ '$(test-wrapper)' '$(test-wrapper-env)' > $@; \
764 $(evaluate-test)
765
766$(objpfx)initfirst: $(libdl)
767$(objpfx)initfirst.out: $(objpfx)firstobj.so
768
769$(objpfx)global: $(objpfx)globalmod1.so
770$(objpfx)global.out: $(objpfx)reldepmod1.so
771
772$(objpfx)dblload: $(libdl)
773$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
774
775$(objpfx)dblunload: $(libdl)
776$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
777
778$(objpfx)reldep5: $(libdl)
779$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod6.so
780
781$(objpfx)reldep6: $(libdl)
782$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
783
784$(objpfx)reldep7: $(libdl)
785$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
786
787$(objpfx)reldep8: $(libdl)
788$(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
789
790LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
791$(objpfx)nodelete2: $(libdl)
792$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
793
794$(objpfx)reldep9: $(libdl)
795$(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
796
797$(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
798
799$(objpfx)tst-tls4: $(libdl)
800$(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
801
802$(objpfx)tst-tls5: $(libdl)
803$(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
804
805$(objpfx)tst-tls6: $(libdl)
806$(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
807
808$(objpfx)tst-tls7: $(libdl)
809$(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
810
811$(objpfx)tst-tls8: $(libdl)
812$(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
813
814$(objpfx)tst-tls9: $(libdl)
815$(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
816
817$(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so $(objpfx)tst-tlsmod7.so
818
819$(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so $(objpfx)tst-tlsmod9.so
820
821$(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so $(objpfx)tst-tlsmod11.so
822
823$(objpfx)tst-tls13: $(libdl)
824$(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
825
826$(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl)
827$(objpfx)tst-tls14.out: $(objpfx)tst-tlsmod14b.so
828
829$(objpfx)tst-tls15: $(libdl)
830$(objpfx)tst-tls15.out: $(objpfx)tst-tlsmod15a.so $(objpfx)tst-tlsmod15b.so
831
832$(objpfx)tst-tls-dlinfo: $(libdl)
833$(objpfx)tst-tls-dlinfo.out: $(objpfx)tst-tlsmod2.so
834
835
836
837$(objpfx)tst-tls16: $(libdl)
838$(objpfx)tst-tls16.out: $(objpfx)tst-tlsmod16a.so $(objpfx)tst-tlsmod16b.so
839
840$(objpfx)tst-tls17: $(libdl)
841$(objpfx)tst-tls17.out: $(objpfx)tst-tlsmod17b.so
842$(patsubst %,$(objpfx)%.os,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.os: tst-tlsmod17a.c
843 $(compile-command.c) -DN=$*
844$(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.so: $(objpfx)ld.so
845$(objpfx)tst-tlsmod17b.so: $(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules))
846
847$(objpfx)tst-tls18: $(libdl)
848$(objpfx)tst-tls18.out: $(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules))
849$(patsubst %,$(objpfx)%.os,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.os : tst-tlsmod18a.c
850 $(compile-command.c) -DN=$*
851$(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.so: $(objpfx)ld.so
852
853$(objpfx)tst-tls19: $(libdl)
854$(objpfx)tst-tls19.out: $(objpfx)tst-tls19mod1.so
855
856CFLAGS-tst-align.c = $(stack-align-test-flags)
857CFLAGS-tst-align2.c = $(stack-align-test-flags)
858CFLAGS-tst-alignmod.c = $(stack-align-test-flags)
859CFLAGS-tst-alignmod2.c = $(stack-align-test-flags)
860$(objpfx)tst-align: $(libdl)
861$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
862$(objpfx)tst-align2: $(objpfx)tst-alignmod2.so
863
864$(objpfx)unload3: $(libdl)
865$(objpfx)unload3.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
866 $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
867
868$(objpfx)unload4: $(libdl)
869$(objpfx)unload4.out: $(objpfx)unload4mod1.so $(objpfx)unload4mod3.so
870
871$(objpfx)unload5: $(libdl)
872$(objpfx)unload5.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
873 $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
874
875$(objpfx)unload6: $(libdl)
876$(objpfx)unload6.out: $(objpfx)unload6mod1.so $(objpfx)unload6mod2.so \
877 $(objpfx)unload6mod3.so
878
879$(objpfx)unload7: $(libdl)
880$(objpfx)unload7.out: $(objpfx)unload7mod1.so $(objpfx)unload7mod2.so
881unload7-ENV = MALLOC_PERTURB_=85
882
883$(objpfx)unload8: $(libdl)
884$(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
885
886ifdef libdl
887$(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
888$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
889endif
890
891ifeq ($(have-z-execstack),yes)
892$(objpfx)tst-execstack: $(libdl)
893$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
894CPPFLAGS-tst-execstack.c = -DUSE_PTHREADS=0
895LDFLAGS-tst-execstack = -Wl,-z,noexecstack
896LDFLAGS-tst-execstack-mod = -Wl,-z,execstack
897
898$(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
899LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
900
901LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
902CFLAGS-tst-execstack-prog.c += -Wno-trampolines
903CFLAGS-tst-execstack-mod.c += -Wno-trampolines
904endif
905
906LDFLAGS-tst-array2 = $(no-as-needed)
907LDFLAGS-tst-array5 = $(no-as-needed)
908
909$(objpfx)tst-array1-cmp.out: tst-array1.exp $(objpfx)tst-array1.out
910 cmp $^ > $@; \
911 $(evaluate-test)
912
913$(objpfx)tst-array1-static-cmp.out: tst-array1.exp \
914 $(objpfx)tst-array1-static.out
915 cmp $^ > $@; \
916 $(evaluate-test)
917
918$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
919$(objpfx)tst-array2-cmp.out: tst-array2.exp $(objpfx)tst-array2.out
920 cmp $^ > $@; \
921 $(evaluate-test)
922
923$(objpfx)tst-array3-cmp.out: tst-array1.exp $(objpfx)tst-array3.out
924 cmp $^ > $@; \
925 $(evaluate-test)
926
927$(objpfx)tst-array4: $(libdl)
928$(objpfx)tst-array4.out: $(objpfx)tst-array2dep.so
929$(objpfx)tst-array4-cmp.out: tst-array4.exp $(objpfx)tst-array4.out
930 cmp $^ > $@; \
931 $(evaluate-test)
932
933$(objpfx)tst-array5: $(objpfx)tst-array5dep.so
934$(objpfx)tst-array5-cmp.out: tst-array5.exp $(objpfx)tst-array5.out
935 cmp $^ > $@; \
936 $(evaluate-test)
937
938$(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
939 $(objpfx)tst-array5-static.out
940 cmp $^ > $@; \
941 $(evaluate-test)
942
943CFLAGS-tst-pie1.c += $(pie-ccflag)
944CFLAGS-tst-pie2.c += $(pie-ccflag)
945
946$(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
947
948ifeq (yes,$(build-shared))
949all-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
950 $(filter-out $(common-objpfx)linkobj/libc.so, \
951 $(sort $(wildcard $(addprefix $(common-objpfx), \
952 */lib*.so \
953 iconvdata/*.so))))
954
955$(all-built-dso:=.dyn): %.dyn: %
956 @rm -f $@T
957 LC_ALL=C $(READELF) -W -d $< > $@T
958 test -s $@T
959 mv -f $@T $@
960common-generated += $(all-built-dso:$(common-objpfx)%=%.dyn)
961
962$(objpfx)check-textrel.out: $(..)scripts/check-textrel.awk \
963 $(all-built-dso:=.dyn)
964 LC_ALL=C $(AWK) -f $^ > $@; \
965 $(evaluate-test)
966generated += check-textrel.out
967
968$(objpfx)execstack-default: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
969 $(make-target-directory)
970 { echo '#include <elf.h>'; \
971 echo '#include <stackinfo.h>'; \
972 echo '#if (DEFAULT_STACK_PERMS & PF_X) == 0'; \
973 echo '@@@execstack-no@@@'; \
974 echo '#else'; \
975 echo '@@@execstack-yes@@@'; \
976 echo '#endif'; } | \
977 $(CC) $(CFLAGS) $(CPPFLAGS) -E -x c-header - | \
978 sed -n -e 's/^@@@\(.*\)@@@/\1/p' > $@T
979 mv -f $@T $@
980generated += execstack-default
981
982$(all-built-dso:=.phdr): %.phdr: %
983 @rm -f $@T
984 LC_ALL=C $(READELF) -W -l $< > $@T
985 test -s $@T
986 mv -f $@T $@
987common-generated += $(all-built-dso:$(common-objpfx)%=%.phdr)
988
989$(objpfx)check-execstack.out: $(..)scripts/check-execstack.awk \
990 $(objpfx)execstack-default \
991 $(all-built-dso:=.phdr)
992 LC_ALL=C $(AWK) -f $^ > $@; \
993 $(evaluate-test)
994generated += check-execstack.out
995
996$(objpfx)tst-dlmodcount: $(libdl)
997$(objpfx)tst-dlmodcount.out: $(test-modules)
998
999$(all-built-dso:=.jmprel): %.jmprel: % Makefile
1000 @rm -f $@T
1001 LC_ALL=C $(READELF) -W -S -d -r $< > $@T
1002 test -s $@T
1003 mv -f $@T $@
1004common-generated += $(all-built-dso:$(common-objpfx)%=%.jmprel)
1005
1006localplt-built-dso := $(addprefix $(common-objpfx),\
1007 libc.so \
1008 elf/ld.so \
1009 math/libm.so \
1010 rt/librt.so \
1011 dlfcn/libdl.so \
1012 resolv/libresolv.so \
1013 crypt/libcrypt.so \
1014 )
1015ifeq ($(build-mathvec),yes)
1016localplt-built-dso += $(addprefix $(common-objpfx), mathvec/libmvec.so)
1017endif
1018ifeq ($(have-thread-library),yes)
1019localplt-built-dso += $(filter-out %_nonshared.a, $(shared-thread-library))
1020endif
1021
1022vpath localplt.data $(+sysdep_dirs)
1023
1024$(objpfx)check-localplt.out: $(..)scripts/check-localplt.awk \
1025 $(..)scripts/localplt.awk \
1026 $(localplt-built-dso:=.jmprel) \
1027 localplt.data
1028 LC_ALL=C $(AWK) -f $(filter-out $< %localplt.data,$^) | \
1029 LC_ALL=C $(AWK) -f $< $(filter %localplt.data,$^) - \
1030 > $@; \
1031 $(evaluate-test)
1032endif
1033
1034$(objpfx)tst-dlopenrpathmod.so: $(libdl)
1035$(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so $(libdl)
1036CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
1037LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir
1038$(objpfx)tst-dlopenrpath.out: $(objpfx)firstobj.so
1039
1040$(objpfx)tst-deep1mod2.so: $(objpfx)tst-deep1mod3.so
1041$(objpfx)tst-deep1: $(libdl) $(objpfx)tst-deep1mod1.so
1042$(objpfx)tst-deep1.out: $(objpfx)tst-deep1mod2.so
1043LDFLAGS-tst-deep1 += -rdynamic
1044tst-deep1mod3.so-no-z-defs = yes
1045
1046$(objpfx)tst-dlmopen1mod.so: $(libdl)
1047$(objpfx)tst-dlmopen1: $(libdl)
1048$(objpfx)tst-dlmopen1.out: $(objpfx)tst-dlmopen1mod.so
1049
1050$(objpfx)tst-dlmopen2: $(libdl)
1051$(objpfx)tst-dlmopen2.out: $(objpfx)tst-dlmopen1mod.so
1052
1053$(objpfx)tst-dlmopen3: $(libdl)
1054$(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so
1055
1056$(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so
1057tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1058
1059$(objpfx)tst-audit2: $(libdl)
1060$(objpfx)tst-audit2.out: $(objpfx)tst-auditmod1.so $(objpfx)tst-auditmod9b.so
1061# Prevent GCC-5 from translating a malloc/memset pair into calloc
1062CFLAGS-tst-audit2.c += -fno-builtin
1063tst-audit2-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1064
1065$(objpfx)tst-audit9: $(libdl)
1066$(objpfx)tst-audit9.out: $(objpfx)tst-auditmod9a.so $(objpfx)tst-auditmod9b.so
1067tst-audit9-ENV = LD_AUDIT=$(objpfx)tst-auditmod9a.so
1068
1069$(objpfx)tst-audit8: $(libm)
1070$(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so
1071tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1072
1073$(objpfx)tst-global1: $(libdl)
1074$(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
1075
1076$(objpfx)order2: $(libdl)
1077$(objpfx)order2.out: $(objpfx)order2mod1.so $(objpfx)order2mod2.so
1078$(objpfx)order2-cmp.out: $(objpfx)order2.out
1079 (echo "12345" | cmp $< -) > $@; \
1080 $(evaluate-test)
1081$(objpfx)order2mod1.so: $(objpfx)order2mod4.so
1082$(objpfx)order2mod4.so: $(objpfx)order2mod3.so
1083$(objpfx)order2mod2.so: $(objpfx)order2mod3.so
1084order2mod2.so-no-z-defs = yes
1085LDFLAGS-order2mod1.so = $(no-as-needed)
1086LDFLAGS-order2mod2.so = $(no-as-needed)
1087
1088tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
1089tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
1090
1091tst-ptrguard1-ARGS = --command "$(host-test-program-cmd) --child"
1092# When built statically, the pointer guard interface uses
1093# __pointer_chk_guard_local.
1094CFLAGS-tst-ptrguard1-static.c = -DPTRGUARD_LOCAL
1095tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
1096
1097$(objpfx)tst-leaks1: $(libdl)
1098$(objpfx)tst-leaks1-mem.out: $(objpfx)tst-leaks1.out
1099 $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@; \
1100 $(evaluate-test)
1101
1102$(objpfx)tst-leaks1-static: $(common-objpfx)dlfcn/libdl.a
1103$(objpfx)tst-leaks1-static-mem.out: $(objpfx)tst-leaks1-static.out
1104 $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1-static.mtrace > $@; \
1105 $(evaluate-test)
1106
1107tst-leaks1-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1.mtrace
1108tst-leaks1-static-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1-static.mtrace
1109
1110$(objpfx)tst-addr1: $(libdl)
1111
1112$(objpfx)tst-thrlock: $(libdl) $(shared-thread-library)
1113$(objpfx)tst-dlopen-aout: $(libdl) $(shared-thread-library)
1114
1115CFLAGS-ifuncmain1pic.c += $(pic-ccflag)
1116CFLAGS-ifuncmain1picstatic.c += $(pic-ccflag)
1117CFLAGS-ifuncmain1staticpic.c += $(pic-ccflag)
1118CFLAGS-ifuncdep1pic.c += $(pic-ccflag)
1119CFLAGS-ifuncmain1vispic.c += $(pic-ccflag)
1120CFLAGS-ifuncmain2pic.c += $(pic-ccflag)
1121CFLAGS-ifuncmain2picstatic.c += $(pic-ccflag)
1122CFLAGS-ifuncdep2pic.c += $(pic-ccflag)
1123CFLAGS-ifuncmain4picstatic.c += $(pic-ccflag)
1124CFLAGS-ifuncmain5pic.c += $(pic-ccflag)
1125CFLAGS-ifuncmain5picstatic.c += $(pic-ccflag)
1126CFLAGS-ifuncmain5staticpic.c += $(pic-ccflag)
1127CFLAGS-ifuncdep5pic.c += $(pic-ccflag)
1128CFLAGS-ifuncmain7pic.c += $(pic-ccflag)
1129CFLAGS-ifuncmain7picstatic.c += $(pic-ccflag)
1130
1131LDFLAGS-ifuncmain3 = -Wl,-export-dynamic
1132
1133CFLAGS-ifuncmain1pie.c += $(pie-ccflag)
1134CFLAGS-ifuncmain1vispie.c += $(pie-ccflag)
1135CFLAGS-ifuncmain1staticpie.c += $(pie-ccflag)
1136CFLAGS-ifuncmain5pie.c += $(pie-ccflag)
1137CFLAGS-ifuncmain6pie.c += $(pie-ccflag)
1138CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
1139
1140$(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so
1141$(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o
1142$(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so
1143$(objpfx)ifuncmain5pie: $(objpfx)ifuncmod5.so
1144$(objpfx)ifuncmain6pie: $(objpfx)ifuncmod6.so
1145
1146$(objpfx)ifuncmain1: $(addprefix $(objpfx),ifuncmod1.so)
1147$(objpfx)ifuncmain1pic: $(addprefix $(objpfx),ifuncmod1.so)
1148$(objpfx)ifuncmain1staticpic: $(addprefix $(objpfx),ifuncdep1pic.o)
1149$(objpfx)ifuncmain1static: $(addprefix $(objpfx),ifuncdep1.o)
1150$(objpfx)ifuncmain1picstatic: $(addprefix $(objpfx),ifuncdep1pic.o)
1151$(objpfx)ifuncmain1vis: $(addprefix $(objpfx),ifuncmod1.so)
1152$(objpfx)ifuncmain1vispic: $(addprefix $(objpfx),ifuncmod1.so)
1153$(objpfx)ifuncmain2: $(addprefix $(objpfx),ifuncdep2.o)
1154$(objpfx)ifuncmain2pic: $(addprefix $(objpfx),ifuncdep2pic.o)
1155$(objpfx)ifuncmain2static: $(addprefix $(objpfx),ifuncdep2.o)
1156$(objpfx)ifuncmain2picstatic: $(addprefix $(objpfx),ifuncdep2pic.o)
1157
1158$(objpfx)ifuncmain3: $(libdl)
1159$(objpfx)ifuncmain3.out: $(objpfx)ifuncmod3.so
1160
1161$(objpfx)ifuncmain5: $(addprefix $(objpfx),ifuncmod5.so)
1162$(objpfx)ifuncmain5pic: $(addprefix $(objpfx),ifuncmod5.so)
1163$(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
1164$(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
1165$(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
1166
1167$(objpfx)tst-unique1: $(libdl)
1168$(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
1169 $(objpfx)tst-unique1mod2.so
1170
1171$(objpfx)tst-unique2: $(libdl) $(objpfx)tst-unique2mod1.so
1172$(objpfx)tst-unique2.out: $(objpfx)tst-unique2mod2.so
1173
1174$(objpfx)tst-unique3: $(libdl) $(objpfx)tst-unique3lib.so
1175$(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
1176
1177$(objpfx)tst-unique4: $(objpfx)tst-unique4lib.so
1178
1179$(objpfx)tst-nodelete: $(libdl)
1180$(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
1181 $(objpfx)tst-nodelete-rtldmod.so \
1182 $(objpfx)tst-nodelete-zmod.so
1183
1184LDFLAGS-tst-nodelete = -rdynamic
1185LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
1186
1187$(objpfx)tst-nodelete2: $(libdl)
1188$(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
1189
1190LDFLAGS-tst-nodelete2 = -rdynamic
1191
1192$(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
1193 cmp $^ > $@; \
1194 $(evaluate-test)
1195
1196$(objpfx)tst-initorder2: $(objpfx)tst-initorder2a.so $(objpfx)tst-initorder2d.so $(objpfx)tst-initorder2c.so
1197$(objpfx)tst-initorder2a.so: $(objpfx)tst-initorder2b.so
1198$(objpfx)tst-initorder2b.so: $(objpfx)tst-initorder2c.so
1199$(objpfx)tst-initorder2c.so: $(objpfx)tst-initorder2d.so
1200LDFLAGS-tst-initorder2 = $(no-as-needed)
1201LDFLAGS-tst-initorder2a.so = $(no-as-needed)
1202LDFLAGS-tst-initorder2b.so = $(no-as-needed)
1203LDFLAGS-tst-initorder2c.so = $(no-as-needed)
1204define o-iterator-doit
1205$(objpfx)tst-initorder2$o.os: tst-initorder2.c; \
1206$$(compile-command.c) -DNAME=\"$o\"
1207endef
1208object-suffixes-left := a b c d
1209include $(o-iterator)
1210
1211$(objpfx)tst-initorder2-cmp.out: tst-initorder2.exp $(objpfx)tst-initorder2.out
1212 cmp $^ > $@; \
1213 $(evaluate-test)
1214
1215$(objpfx)tst-relsort1: $(libdl)
1216$(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
1217$(objpfx)tst-relsort1mod2.so: $(libm)
1218$(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
1219 $(objpfx)tst-relsort1mod2.so
1220
1221$(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
1222 $(test-wrapper-env) \
1223 LD_TRACE_LOADED_OBJECTS=1 \
1224 LD_DEBUG=unused \
1225 LD_PRELOAD= \
1226 $(rtld-prefix) \
1227 $< > $@; \
1228 $(evaluate-test)
1229
1230$(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
1231 cmp $< /dev/null > $@; \
1232 $(evaluate-test)
1233
1234$(objpfx)tst-audit11.out: $(objpfx)tst-auditmod11.so $(objpfx)tst-audit11mod1.so
1235$(objpfx)tst-audit11: $(libdl)
1236tst-audit11-ENV = LD_AUDIT=$(objpfx)tst-auditmod11.so
1237$(objpfx)tst-audit11mod1.so: $(objpfx)tst-audit11mod2.so
1238LDFLAGS-tst-audit11mod2.so = -Wl,--version-script=tst-audit11mod2.map,-soname,tst-audit11mod2.so
1239
1240$(objpfx)tst-audit12.out: $(objpfx)tst-auditmod12.so $(objpfx)tst-audit12mod1.so $(objpfx)tst-audit12mod3.so
1241$(objpfx)tst-audit12: $(libdl)
1242tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so
1243$(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
1244LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
1245
1246tst-prelink-ENV = LD_TRACE_PRELINKING=1
1247
1248$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
1249 grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
1250
1251$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
1252 $(objpfx)tst-prelink-conflict.out
1253 cmp $^ > $@; \
1254 $(evaluate-test)