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