]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/Makefile
dea51ca182c67858344f75dd63d73a835851247f
[thirdparty/glibc.git] / elf / Makefile
1 # Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
17
18 # Makefile for elf subdirectory of GNU C Library.
19
20 subdir := elf
21
22 include ../Makeconfig
23
24 headers = elf.h bits/elfclass.h link.h bits/link.h
25 routines = $(all-dl-routines) dl-support dl-iteratephdr \
26 dl-addr dl-addr-obj enbl-secure dl-profstub \
27 dl-origin dl-libc dl-sym dl-sysdep dl-error \
28 dl-reloc-static-pie
29
30 # The core dynamic linking functions are in libc for the static and
31 # profiled libraries.
32 dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
33 runtime init fini debug misc \
34 version profile tls origin scope \
35 execstack open close trampoline \
36 exception sort-maps)
37 ifeq (yes,$(use-ldconfig))
38 dl-routines += dl-cache
39 endif
40
41 ifneq (no,$(have-tunables))
42 dl-routines += dl-tunables
43 tunables-type = $(addprefix TUNABLES_FRONTEND_,$(have-tunables))
44 CPPFLAGS-dl-tunables.c += -DTUNABLES_FRONTEND=$(tunables-type)
45
46 # Make sure that the compiler does not insert any library calls in tunables
47 # code paths.
48 ifeq (yes,$(have-loop-to-function))
49 CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns
50 endif
51 endif
52
53 all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
54 # But they are absent from the shared libc, because that code is in ld.so.
55 elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
56 dl-sysdep dl-exception dl-reloc-static-pie
57
58 # ld.so uses those routines, plus some special stuff for being the program
59 # interpreter and operating independent of libc.
60 rtld-routines = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \
61 dl-error-minimal dl-conflict
62 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
63
64 CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
65 CFLAGS-dl-lookup.c += -fexceptions -fasynchronous-unwind-tables
66 CFLAGS-dl-iterate-phdr.c += $(uses-callbacks)
67
68 # Compile rtld itself without stack protection.
69 # Also compile all routines in the static library that are elided from
70 # the shared libc because they are in libc.a in the same way.
71
72 define elide-stack-protector
73 $(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
74 endef
75
76 CFLAGS-.o += $(call elide-stack-protector,.o,$(elide-routines.os))
77 CFLAGS-.op += $(call elide-stack-protector,.op,$(elide-routines.os))
78 CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines))
79
80 ifeq ($(unwind-find-fde),yes)
81 routines += unwind-dw2-fde-glibc
82 shared-only-routines += unwind-dw2-fde-glibc
83 endif
84
85 before-compile += $(objpfx)trusted-dirs.h
86 generated += trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
87 generated-dirs += for-renamed
88
89 ifeq ($(build-shared),yes)
90 ld-map = $(common-objpfx)ld.map
91 endif
92
93 ifeq (yes,$(build-shared))
94 extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
95 generated += librtld.os dl-allobjs.os ld.so ldd
96 install-others = $(inst_rtlddir)/$(rtld-installed-name)
97 install-bin-script = ldd
98 endif
99
100 others = sprof sln
101 install-bin = sprof
102 others-static = sln
103 install-rootsbin = sln
104 sln-modules := static-stubs
105 extra-objs += $(sln-modules:=.o)
106
107 ifeq (yes,$(use-ldconfig))
108 ifeq (yes,$(build-shared))
109 others-static += ldconfig
110 others += ldconfig
111 install-rootsbin += ldconfig
112
113 ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon static-stubs
114 extra-objs += $(ldconfig-modules:=.o)
115 others-extras = $(ldconfig-modules)
116 endif
117 endif
118
119 # To find xmalloc.c and xstrdup.c
120 vpath %.c ../locale/programs
121
122 ifeq ($(build-shared),yes)
123 extra-objs += sotruss-lib.os sotruss-lib.so
124 install-others += $(inst_auditdir)/sotruss-lib.so
125 install-bin-script += sotruss
126 generated += sotruss
127 libof-sotruss-lib = extramodules
128 LDFLAGS-sotruss-lib.so += $(z-now-$(bind-now))
129 $(objpfx)sotruss-lib.so: $(objpfx)sotruss-lib.os
130 $(build-module-asneeded)
131 $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
132 $(common-objpfx)libc_nonshared.a
133
134 $(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
135 sed -e 's%@BASH@%$(BASH)%g' \
136 -e 's%@VERSION@%$(version)%g' \
137 -e 's%@TEXTDOMAINDIR@%$(localedir)%g' \
138 -e 's%@PREFIX@%$(prefix)%g' \
139 -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
140 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
141 < $< > $@.new
142 chmod 555 $@.new
143 mv -f $@.new $@
144 $(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
145 $(do-install-program)
146 endif
147
148 tests-static-normal := tst-leaks1-static tst-array1-static tst-array5-static \
149 tst-dl-iter-static \
150 tst-tlsalign-static tst-tlsalign-extern-static \
151 tst-linkall-static tst-env-setuid tst-env-setuid-tunables
152 tests-static-internal := tst-tls1-static tst-tls2-static \
153 tst-ptrguard1-static tst-stackguard1-static \
154 tst-tls1-static-non-pie tst-libc_dlvsym-static
155
156 CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o
157 tst-tls1-static-non-pie-no-pie = yes
158
159 tests-container = \
160 tst-ldconfig-bad-aux-cache
161
162 tests := tst-tls9 tst-leaks1 \
163 tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
164 tst-auxv
165 tests-internal := tst-tls1 tst-tls2 $(tests-static-internal)
166 tests-static := $(tests-static-normal) $(tests-static-internal)
167
168 ifeq (yes,$(build-shared))
169 tests-static += tst-tls9-static
170 tst-tls9-static-ENV = \
171 LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
172
173 tests += restest1 preloadtest loadfail multiload origtest resolvfail \
174 constload1 order noload filter \
175 reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
176 nodlopen nodlopen2 lateglobal initfirst global \
177 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
178 tst-tls4 tst-tls5 \
179 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \
180 tst-tls16 tst-tls17 tst-tls18 tst-tls19 tst-tls-dlinfo \
181 tst-align tst-align2 \
182 tst-dlmodcount tst-dlopenrpath tst-deep1 \
183 tst-dlmopen1 tst-dlmopen3 \
184 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
185 tst-audit1 tst-audit2 tst-audit8 tst-audit9 \
186 tst-addr1 tst-thrlock \
187 tst-unique1 tst-unique2 $(if $(CXX),tst-unique3 tst-unique4 \
188 tst-nodelete) \
189 tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
190 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
191 tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
192 tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \
193 tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note \
194 tst-unwind-ctor tst-unwind-main tst-audit13 \
195 tst-sonamemove-link tst-sonamemove-dlopen tst-dlopen-aout
196 # reldep9
197 tests-internal += loadtest unload unload2 circleload1 \
198 neededtest neededtest2 neededtest3 neededtest4 \
199 tst-tls3 tst-tls6 tst-tls7 tst-tls8 tst-dlmopen2 \
200 tst-ptrguard1 tst-stackguard1 tst-libc_dlvsym \
201 tst-create_format1
202 tests-container += tst-pldd tst-dlopen-aout-container
203 test-srcs = tst-pathopt
204 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
205 ifneq ($(selinux-enabled),1)
206 tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
207 endif
208 endif
209 tests += $(tests-execstack-$(have-z-execstack))
210 ifeq ($(run-built-tests),yes)
211 tests-special += $(objpfx)tst-leaks1-mem.out \
212 $(objpfx)tst-leaks1-static-mem.out $(objpfx)noload-mem.out \
213 $(objpfx)tst-ldconfig-X.out
214 endif
215 tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
216 tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
217 tlsmod17a-modules = $(addprefix tst-tlsmod17a, $(tlsmod17a-suffixes))
218 tlsmod18a-modules = $(addprefix tst-tlsmod18a, $(tlsmod17a-suffixes))
219 one-hundred = $(foreach x,0 1 2 3 4 5 6 7 8 9, \
220 0$x 1$x 2$x 3$x 4$x 5$x 6$x 7$x 8$x 9$x)
221 tst-tls-many-dynamic-modules := \
222 $(foreach n,$(one-hundred),tst-tls-manydynamic$(n)mod)
223 extra-test-objs += $(tlsmod17a-modules:=.os) $(tlsmod18a-modules:=.os) \
224 tst-tlsalign-vars.o
225 test-extras += tst-tlsmod17a tst-tlsmod18a tst-tlsalign-vars
226 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
227 testobj1_1 failobj constload2 constload3 unloadmod \
228 dep1 dep2 dep3 dep4 vismod1 vismod2 vismod3 \
229 nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
230 nodel2mod1 nodel2mod2 nodel2mod3 \
231 nodlopenmod nodlopenmod2 filtmod1 filtmod2 \
232 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
233 reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
234 neededobj1 neededobj2 neededobj3 neededobj4 \
235 neededobj5 neededobj6 firstobj globalmod1 \
236 unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
237 dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
238 reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
239 reldep7mod1 reldep7mod2 \
240 tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
241 tst-tlsmod5 tst-tlsmod6 tst-tlsmod7 tst-tlsmod8 \
242 tst-tlsmod9 tst-tlsmod10 tst-tlsmod11 tst-tlsmod12 \
243 tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \
244 tst-tlsmod15a tst-tlsmod15b tst-tlsmod16a tst-tlsmod16b \
245 $(tlsmod17a-modules) tst-tlsmod17b $(tlsmod18a-modules) \
246 tst-tls19mod1 tst-tls19mod2 tst-tls19mod3 \
247 circlemod1 circlemod1a circlemod2 circlemod2a \
248 circlemod3 circlemod3a \
249 reldep8mod1 reldep8mod2 reldep8mod3 \
250 reldep9mod1 reldep9mod2 reldep9mod3 \
251 tst-alignmod tst-alignmod2 \
252 $(modules-execstack-$(have-z-execstack)) \
253 tst-dlopenrpathmod tst-deep1mod1 tst-deep1mod2 tst-deep1mod3 \
254 tst-dlmopen1mod tst-auditmod1 \
255 unload3mod1 unload3mod2 unload3mod3 unload3mod4 \
256 unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
257 unload6mod1 unload6mod2 unload6mod3 \
258 unload7mod1 unload7mod2 \
259 unload8mod1 unload8mod1x unload8mod2 unload8mod3 \
260 order2mod1 order2mod2 order2mod3 order2mod4 \
261 tst-unique1mod1 tst-unique1mod2 \
262 tst-unique2mod1 tst-unique2mod2 \
263 tst-auditmod9a tst-auditmod9b \
264 $(if $(CXX),tst-unique3lib tst-unique3lib2 tst-unique4lib \
265 tst-nodelete-uniquemod tst-nodelete-rtldmod \
266 tst-nodelete-zmod) \
267 tst-initordera1 tst-initorderb1 \
268 tst-initordera2 tst-initorderb2 \
269 tst-initordera3 tst-initordera4 \
270 tst-initorder2a tst-initorder2b tst-initorder2c \
271 tst-initorder2d \
272 tst-relsort1mod1 tst-relsort1mod2 tst-array2dep \
273 tst-array5dep tst-null-argv-lib \
274 tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod \
275 tst-audit11mod1 tst-audit11mod2 tst-auditmod11 \
276 tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12 \
277 tst-latepthreadmod $(tst-tls-many-dynamic-modules) \
278 tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin \
279 tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \
280 tst-absolute-zero-lib tst-big-note-lib tst-unwind-ctor-lib \
281 tst-audit13mod1 tst-sonamemove-linkmod1 \
282 tst-sonamemove-runmod1 tst-sonamemove-runmod2
283 # Most modules build with _ISOMAC defined, but those filtered out
284 # depend on internal headers.
285 modules-names-tests = $(filter-out ifuncmod% tst-libc_dlvsym-dso tst-tlsmod%,\
286 $(modules-names))
287
288 ifeq (yes,$(have-mtls-dialect-gnu2))
289 tests += tst-gnu2-tls1
290 modules-names += tst-gnu2-tls1mod
291 $(objpfx)tst-gnu2-tls1: $(objpfx)tst-gnu2-tls1mod.so
292 tst-gnu2-tls1mod.so-no-z-defs = yes
293 CFLAGS-tst-gnu2-tls1mod.c += -mtls-dialect=gnu2
294 endif
295 ifeq (yes,$(have-protected-data))
296 modules-names += tst-protected1moda tst-protected1modb
297 tests += tst-protected1a tst-protected1b
298 $(objpfx)tst-protected1a: $(addprefix $(objpfx),tst-protected1moda.so tst-protected1modb.so)
299 $(objpfx)tst-protected1b: $(addprefix $(objpfx),tst-protected1modb.so tst-protected1moda.so)
300 tst-protected1modb.so-no-z-defs = yes
301 # These tests fail with GCC versions prior to 5.1 and with some versions
302 # of binutils. See https://sourceware.org/bugzilla/show_bug.cgi?id=17709
303 # and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 for details.
304 # Perhaps in future we can make these XFAILs conditional on some detection
305 # of compiler/linker behavior/version.
306 test-xfail-tst-protected1a = yes
307 test-xfail-tst-protected1b = yes
308 endif
309 ifeq (yesyes,$(have-fpie)$(build-shared))
310 modules-names += tst-piemod1
311 tests += tst-pie1 tst-pie2 tst-dlopen-pie tst-dlopen-aout-pie
312 tests-pie += tst-pie1 tst-pie2 tst-dlopen-aout-pie
313 ifeq (yes,$(have-protected-data))
314 tests += vismain
315 tests-pie += vismain
316 CFLAGS-vismain.c += $(PIE-ccflag)
317 endif
318 endif
319 modules-execstack-yes = tst-execstack-mod
320 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
321
322 # filtmod1.so, tst-big-note-lib.so have special rules.
323 modules-names-nobuild := filtmod1 tst-big-note-lib
324
325 tests += $(tests-static)
326
327 ifeq (yes,$(have-ifunc))
328 tests-ifuncstatic := ifuncmain1static ifuncmain1picstatic \
329 ifuncmain2static ifuncmain2picstatic \
330 ifuncmain4static ifuncmain4picstatic \
331 ifuncmain5static ifuncmain5picstatic \
332 ifuncmain7static ifuncmain7picstatic \
333 ifuncmain9static ifuncmain9picstatic
334 tests-static += $(tests-ifuncstatic)
335 tests-internal += $(tests-ifuncstatic)
336 ifeq (yes,$(build-shared))
337 # Note: sysdeps/x86_64/ifuncmain8.c uses ifuncmain8.
338 tests-internal += \
339 ifuncmain1 ifuncmain1pic ifuncmain1vis ifuncmain1vispic \
340 ifuncmain1staticpic \
341 ifuncmain2 ifuncmain2pic ifuncmain3 ifuncmain4 \
342 ifuncmain5 ifuncmain5pic ifuncmain5staticpic \
343 ifuncmain7 ifuncmain7pic \
344 ifuncmain9 ifuncmain9pic
345 ifunc-test-modules = ifuncdep1 ifuncdep1pic ifuncdep2 ifuncdep2pic \
346 ifuncdep5 ifuncdep5pic
347 extra-test-objs += $(ifunc-test-modules:=.o)
348 test-internal-extras += $(ifunc-test-modules)
349 ifeq (yes,$(have-fpie))
350 ifunc-pie-tests = ifuncmain1pie ifuncmain1vispie ifuncmain1staticpie \
351 ifuncmain5pie ifuncmain6pie ifuncmain7pie ifuncmain9pie
352 ifeq (yes,$(have-textrel_ifunc))
353 ifunc-pie-tests += tst-ifunc-textrel
354 endif
355 tests-internal += $(ifunc-pie-tests)
356 tests-pie += $(ifunc-pie-tests)
357 endif
358 modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
359 endif
360 endif
361
362 ifeq (yes,$(build-shared))
363 ifeq ($(run-built-tests),yes)
364 tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out \
365 $(objpfx)tst-rtld-preload.out
366 endif
367 tests-special += $(objpfx)check-textrel.out $(objpfx)check-execstack.out \
368 $(objpfx)check-localplt.out $(objpfx)check-initfini.out
369 endif
370
371 ifeq ($(run-built-tests),yes)
372 tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
373 $(objpfx)tst-array1-static-cmp.out \
374 $(objpfx)tst-array2-cmp.out $(objpfx)tst-array3-cmp.out \
375 $(objpfx)tst-array4-cmp.out $(objpfx)tst-array5-cmp.out \
376 $(objpfx)tst-array5-static-cmp.out $(objpfx)order2-cmp.out \
377 $(objpfx)tst-initorder-cmp.out \
378 $(objpfx)tst-initorder2-cmp.out $(objpfx)tst-unused-dep.out \
379 $(objpfx)tst-unused-dep-cmp.out
380 endif
381
382 check-abi: $(objpfx)check-abi-ld.out
383 tests-special += $(objpfx)check-abi-ld.out
384 update-abi: update-abi-ld
385 update-all-abi: update-all-abi-ld
386
387 ifeq ($(have-glob-dat-reloc),yes)
388 tests += tst-prelink
389 # Don't compile tst-prelink.c with PIE for GLOB_DAT relocation.
390 CFLAGS-tst-prelink.c += -fno-pie
391 tst-prelink-no-pie = yes
392 ifeq ($(run-built-tests),yes)
393 tests-special += $(objpfx)tst-prelink-cmp.out
394 endif
395 endif
396
397 # The test requires shared _and_ PIE because the executable
398 # unit test driver must be able to link with the shared object
399 # that is going to eventually go into an installed DSO.
400 ifeq (yesyes,$(have-fpie)$(build-shared))
401 tests-internal += tst-_dl_addr_inside_object
402 tests-pie += tst-_dl_addr_inside_object
403 $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os
404 CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag)
405 endif
406
407 # We can only test static libcrypt use if libcrypt has been built,
408 # and either NSS crypto is not in use, or static NSS libraries are
409 # available.
410 ifeq ($(build-crypt),no)
411 CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=0
412 else
413 ifeq ($(nss-crypt),no)
414 CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=1
415 else
416 ifeq ($(static-nss-crypt),no)
417 CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=0
418 else
419 CFLAGS-tst-linkall-static.c += -DUSE_CRYPT=1
420 endif
421 endif
422 endif
423
424 include ../Rules
425
426 ifeq (yes,$(build-shared))
427 # Make sure these things are built in the `make lib' pass so they can be used
428 # to run programs during the `make others' pass.
429 lib-noranlib: $(objpfx)$(rtld-installed-name) \
430 $(addprefix $(objpfx),$(extra-objs))
431 endif
432
433 # Command to link into a larger single relocatable object.
434 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
435
436 $(objpfx)sotruss-lib.so: $(shlib-lds)
437
438 $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
439 $(reloc-link) -o $@ $^
440
441 # Link together the dynamic linker into a single relocatable object.
442 # First we do a link against libc_pic.a just to get a link map,
443 # and discard the object produced by that link. From the link map
444 # we can glean all the libc modules that need to go into the dynamic
445 # linker. Then we do a recursive make that goes into all the subdirs
446 # those modules come from and builds special rtld-foo.os versions that
447 # are compiled with special flags, and puts these modules into rtld-libc.a
448 # for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
449
450 # If the compiler can do SSP, build the mapfile with dummy __stack_chk_fail
451 # and __stack_chk_fail_local symbols defined, to prevent the real things
452 # being dragged into rtld even though rtld is never built with stack-
453 # protection.
454
455 ifeq ($(have-ssp),yes)
456 dummy-stack-chk-fail := -Wl,--defsym='__stack_chk_fail=0' \
457 -Wl,--defsym='__stack_chk_fail_local=0'
458 else
459 dummy-stack-chk-fail :=
460 endif
461
462 $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
463 @-rm -f $@T
464 $(reloc-link) -o $@.o $(dummy-stack-chk-fail) \
465 '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
466 rm -f $@.o
467 mv -f $@T $@
468
469 $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
470 LC_ALL=C \
471 sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
472 $< | \
473 while read lib file; do \
474 case $$lib in \
475 libc_pic.a) \
476 LC_ALL=C fgrep -l /$$file \
477 $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
478 LC_ALL=C \
479 sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
480 ;; \
481 */*.a) \
482 echo rtld-$${lib%%/*} += $$file ;; \
483 *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
484 esac; \
485 done > $@T
486 echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
487 | LC_ALL=C sort -u` >> $@T
488 mv -f $@T $@
489
490 $(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
491 $(MAKE) -f $< -f rtld-Rules
492
493 $(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
494 $(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
495 -Wl,-Map,$@.map
496
497 generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
498
499 z-now-yes = -Wl,-z,now
500
501 $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
502 # Link into a temporary file so that we don't touch $@ at all
503 # if the sanity check below fails.
504 $(LINK.o) -nostdlib -nostartfiles -shared -o $@.new \
505 $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
506 $(filter-out $(map-file),$^) $(load-map-file) \
507 -Wl,-soname=$(rtld-installed-name) \
508 -Wl,-defsym=_begin=0
509 $(call after-link,$@.new)
510 $(READELF) -s $@.new \
511 | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
512 mv -f $@.new $@
513
514 ifeq (yes,$(build-shared))
515 # interp.c exists just to get the runtime linker path into libc.so.
516 $(objpfx)interp.os: $(common-objpfx)runtime-linker.h
517 endif
518
519 ifneq (ld.so,$(rtld-installed-name))
520 # Make sure ld.so.1 exists in the build directory so we can link
521 # against it.
522 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
523 $(make-link)
524 generated += $(rtld-installed-name)
525 endif
526
527 # Build a file mentioning all trustworthy directories to look for shared
528 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
529 # add directories to the list by defining $(user-defined-trusted-dirs)
530 # before starting make.
531 $(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
532 $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
533 $(make-target-directory)
534 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
535 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
536 echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
537 $(move-if-change) ${@:st=T} ${@:st=h}
538 touch $@
539 CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
540
541 ifeq (yes,$(build-shared))
542 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
543 $(make-target-directory)
544 $(do-install-program)
545
546 $(inst_rtlddir)/$(rtld-installed-name): \
547 $(inst_slibdir)/$(rtld-version-installed-name) \
548 $(inst_slibdir)/libc-$(version).so
549 $(make-target-directory)
550 $(make-shlib-link)
551
552 # Special target called by parent to install just the dynamic linker.
553 .PHONY: ldso_install
554 ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
555 endif
556
557
558 ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
559 -e 's%@VERSION@%$(version)%g' \
560 -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
561 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
562 -e 's%@BASH@%$(BASH)%g' \
563 -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
564
565 ifeq ($(ldd-rewrite-script),no)
566 define gen-ldd
567 LC_ALL=C sed $(ldd-rewrite) < $< > $@.new
568 endef
569 else
570 define gen-ldd
571 LC_ALL=C sed $(ldd-rewrite) < $< \
572 | LC_ALL=C sed -f $(patsubst $(..)/%,/%,$(..)$(ldd-rewrite-script)) > $@.new
573 endef
574 endif
575
576 $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
577 $(common-objpfx)config.make
578 $(gen-ldd)
579 chmod 555 $@.new
580 mv -f $@.new $@
581
582 $(objpfx)sprof: $(libdl)
583
584 $(objpfx)sln: $(sln-modules:%=$(objpfx)%.o)
585
586 $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
587
588 SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
589 CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
590 -D'SLIBDIR="$(slibdir)"'
591 libof-ldconfig = ldconfig
592 CFLAGS-dl-cache.c += $(SYSCONF-FLAGS)
593 CFLAGS-cache.c += $(SYSCONF-FLAGS)
594 CFLAGS-rtld.c += $(SYSCONF-FLAGS)
595
596 cpp-srcs-left := $(all-rtld-routines:=.os)
597 lib := rtld
598 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
599
600 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
601 generated += $(addsuffix .so,$(strip $(modules-names)))
602
603 $(objpfx)testobj1.so: $(libdl)
604 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
605 $(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
606 $(objpfx)testobj3.so: $(libdl)
607 $(objpfx)testobj4.so: $(libdl)
608 $(objpfx)testobj5.so: $(libdl)
609 $(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
610 $(objpfx)failobj.so: $(objpfx)testobj6.so
611 $(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
612 $(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
613 $(objpfx)dep4.so: $(objpfx)dep3.so
614 $(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
615 $(objpfx)nextmod1.so: $(libdl)
616 $(objpfx)neededobj1.so: $(libdl)
617 $(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
618 $(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
619 $(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
620 $(objpfx)neededobj3.so $(libdl)
621 $(objpfx)neededobj6.so: $(objpfx)neededobj5.so
622 $(objpfx)unload2mod.so: $(objpfx)unload2dep.so
623 $(objpfx)ltglobmod2.so: $(libdl)
624 $(objpfx)firstobj.so: $(shared-thread-library)
625 $(objpfx)globalmod1.so: $(libdl)
626 $(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
627 $(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
628 $(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
629 $(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
630 $(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
631 $(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
632 $(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
633 $(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
634 $(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
635 $(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
636 $(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
637 $(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
638 $(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
639 $(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
640 $(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
641 # For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
642 $(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
643 $(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
644 $(objpfx)tst-tls19mod1.so: $(objpfx)tst-tls19mod2.so $(objpfx)tst-tls19mod3.so
645 $(objpfx)tst-tls19mod3.so: $(objpfx)ld.so
646 $(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
647 $(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
648 $(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
649 $(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
650 $(objpfx)unload3mod1.so: $(objpfx)unload3mod3.so
651 $(objpfx)unload3mod2.so: $(objpfx)unload3mod3.so
652 $(objpfx)unload3mod3.so: $(objpfx)unload3mod4.so
653 $(objpfx)unload4mod1.so: $(objpfx)unload4mod2.so $(objpfx)unload4mod3.so
654 $(objpfx)unload4mod2.so: $(objpfx)unload4mod4.so $(objpfx)unload4mod3.so
655 $(objpfx)unload6mod1.so: $(libdl)
656 $(objpfx)unload6mod2.so: $(libdl)
657 $(objpfx)unload6mod3.so: $(libdl)
658 $(objpfx)unload7mod1.so: $(libdl)
659 $(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
660 $(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
661 $(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
662 $(objpfx)unload8mod3.so: $(libdl)
663 $(objpfx)tst-initordera2.so: $(objpfx)tst-initordera1.so
664 $(objpfx)tst-initorderb2.so: $(objpfx)tst-initorderb1.so $(objpfx)tst-initordera2.so
665 $(objpfx)tst-initordera3.so: $(objpfx)tst-initorderb2.so $(objpfx)tst-initorderb1.so
666 $(objpfx)tst-initordera4.so: $(objpfx)tst-initordera3.so
667 $(objpfx)tst-initorder: $(objpfx)tst-initordera4.so $(objpfx)tst-initordera1.so $(objpfx)tst-initorderb2.so
668 $(objpfx)tst-null-argv: $(objpfx)tst-null-argv-lib.so
669 $(objpfx)tst-tlsalign: $(objpfx)tst-tlsalign-lib.so
670 $(objpfx)tst-nodelete-opened.out: $(objpfx)tst-nodelete-opened-lib.so
671 $(objpfx)tst-nodelete-opened: $(libdl)
672 $(objpfx)tst-noload: $(libdl)
673
674 $(objpfx)tst-tlsalign-extern: $(objpfx)tst-tlsalign-vars.o
675 $(objpfx)tst-tlsalign-extern-static: $(objpfx)tst-tlsalign-vars.o
676
677 tst-null-argv-ENV = LD_DEBUG=all LD_DEBUG_OUTPUT=$(objpfx)tst-null-argv.debug.out
678 LDFLAGS-nodel2mod3.so = $(no-as-needed)
679 LDFLAGS-reldepmod5.so = $(no-as-needed)
680 LDFLAGS-reldep6mod1.so = $(no-as-needed)
681 LDFLAGS-reldep6mod4.so = $(no-as-needed)
682 LDFLAGS-reldep8mod3.so = $(no-as-needed)
683 LDFLAGS-unload4mod1.so = $(no-as-needed)
684 LDFLAGS-unload4mod2.so = $(no-as-needed)
685 LDFLAGS-tst-initorder = $(no-as-needed)
686 LDFLAGS-tst-initordera2.so = $(no-as-needed)
687 LDFLAGS-tst-initordera3.so = $(no-as-needed)
688 LDFLAGS-tst-initordera4.so = $(no-as-needed)
689 LDFLAGS-tst-initorderb2.so = $(no-as-needed)
690 LDFLAGS-tst-tlsmod5.so = -nostdlib $(no-as-needed)
691 LDFLAGS-tst-tlsmod6.so = -nostdlib $(no-as-needed)
692
693 testobj1.so-no-z-defs = yes
694 testobj3.so-no-z-defs = yes
695 testobj4.so-no-z-defs = yes
696 testobj5.so-no-z-defs = yes
697 testobj6.so-no-z-defs = yes
698 failobj.so-no-z-defs = yes
699 constload2.so-no-z-defs = yes
700 constload3.so-no-z-defs = yes
701 nodelmod1.so-no-z-defs = yes
702 nodelmod2.so-no-z-defs = yes
703 nodelmod4.so-no-z-defs = yes
704 nodel2mod2.so-no-z-defs = yes
705 reldepmod2.so-no-z-defs = yes
706 reldepmod3.so-no-z-defs = yes
707 reldepmod4.so-no-z-defs = yes
708 reldep4mod4.so-no-z-defs = yes
709 reldep4mod2.so-no-z-defs = yes
710 ltglobmod2.so-no-z-defs = yes
711 dblloadmod3.so-no-z-defs = yes
712 tst-tlsmod1.so-no-z-defs = yes
713 tst-tlsmod2.so-no-z-defs = yes
714 tst-tlsmod3.so-no-z-defs = yes
715 tst-tlsmod4.so-no-z-defs = yes
716 tst-tlsmod7.so-no-z-defs = yes
717 tst-tlsmod8.so-no-z-defs = yes
718 tst-tlsmod9.so-no-z-defs = yes
719 tst-tlsmod10.so-no-z-defs = yes
720 tst-tlsmod12.so-no-z-defs = yes
721 tst-tlsmod14a.so-no-z-defs = yes
722 tst-tlsmod14b.so-no-z-defs = yes
723 tst-tlsmod15a.so-no-z-defs = yes
724 tst-tlsmod16b.so-no-z-defs = yes
725 circlemod2.so-no-z-defs = yes
726 circlemod3.so-no-z-defs = yes
727 circlemod3a.so-no-z-defs = yes
728 reldep8mod2.so-no-z-defs = yes
729 reldep9mod1.so-no-z-defs = yes
730 unload3mod4.so-no-z-defs = yes
731 unload4mod1.so-no-z-defs = yes
732 ifuncmod1.so-no-z-defs = yes
733 ifuncmod5.so-no-z-defs = yes
734 ifuncmod6.so-no-z-defs = yes
735 tst-auditmod9a.so-no-z-defs = yes
736 tst-auditmod9b.so-no-z-defs = yes
737 tst-nodelete-uniquemod.so-no-z-defs = yes
738 tst-nodelete-rtldmod.so-no-z-defs = yes
739 tst-nodelete-zmod.so-no-z-defs = yes
740 tst-nodelete2mod.so-no-z-defs = yes
741
742 ifeq ($(build-shared),yes)
743 # Build all the modules even when not actually running test programs.
744 tests: $(test-modules)
745 endif
746
747 $(objpfx)loadtest: $(libdl)
748 LDFLAGS-loadtest = -rdynamic
749
750 $(objpfx)loadtest.out: $(test-modules)
751
752 $(objpfx)neededtest: $(libdl)
753 $(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
754 $(objpfx)neededobj3.so
755
756 $(objpfx)neededtest2: $(libdl)
757 $(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
758 $(objpfx)neededobj3.so
759
760 $(objpfx)neededtest3: $(libdl)
761 $(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
762 $(objpfx)neededobj3.so $(objpfx)neededobj4.so
763
764 $(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
765 $(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
766
767 $(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
768 LDFLAGS-restest1 = -rdynamic
769
770 $(objpfx)restest2: $(libdl)
771 LDFLAGS-restest2 = -rdynamic
772
773 $(objpfx)restest1.out: $(test-modules)
774
775 preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
776 $(objpfx)preloadtest: $(objpfx)testobj6.so
777 LDFLAGS-preloadtest = -rdynamic
778 $(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
779 preloadtest-ENV = \
780 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
781
782 $(objpfx)loadfail: $(libdl)
783 LDFLAGS-loadfail = -rdynamic
784
785 $(objpfx)loadfail.out: $(objpfx)failobj.so
786
787 $(objpfx)multiload: $(libdl)
788 LDFLAGS-multiload = -rdynamic
789 CFLAGS-multiload.c += -DOBJDIR=\"$(elf-objpfx)\"
790
791 $(objpfx)multiload.out: $(objpfx)testobj1.so
792
793 $(objpfx)origtest: $(libdl)
794 LDFLAGS-origtest = -rdynamic
795 $(objpfx)origtest.out: $(objpfx)testobj1.so
796
797 ifeq ($(have-thread-library),yes)
798 $(objpfx)resolvfail: $(libdl) $(shared-thread-library)
799 else
800 $(objpfx)resolvfail: $(libdl)
801 endif
802
803 $(objpfx)constload1: $(libdl)
804 $(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
805
806 $(objpfx)circleload1: $(libdl)
807 $(objpfx)circleload1.out: $(objpfx)circlemod1.so \
808 $(objpfx)circlemod1a.so
809
810 $(objpfx)circlemod1.so: $(objpfx)circlemod2.so
811 $(objpfx)circlemod2.so: $(objpfx)circlemod3.so
812 $(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
813 $(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
814
815 $(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
816
817 $(objpfx)order-cmp.out: $(objpfx)order.out
818 (echo "0123456789" | cmp $< -) > $@; \
819 $(evaluate-test)
820
821 $(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
822 $(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
823 vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
824
825 $(objpfx)noload: $(objpfx)testobj1.so $(libdl)
826 LDFLAGS-noload = -rdynamic $(no-as-needed)
827 $(objpfx)noload.out: $(objpfx)testobj5.so
828
829 $(objpfx)noload-mem.out: $(objpfx)noload.out
830 $(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@; \
831 $(evaluate-test)
832 noload-ENV = MALLOC_TRACE=$(objpfx)noload.mtrace
833
834 LDFLAGS-nodelete = -rdynamic
835 LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
836 LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
837 $(objpfx)nodelete: $(libdl)
838 $(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
839 $(objpfx)nodelmod3.so
840
841 LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
842 $(objpfx)nodlopen: $(libdl)
843 $(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
844
845 $(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
846 $(objpfx)nodlopen2: $(libdl)
847 $(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
848
849 $(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
850 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
851 -L$(subst :, -L,$(rpath-link)) \
852 -Wl,-rpath-link=$(rpath-link) \
853 $< -Wl,-F,$(objpfx)filtmod2.so
854 $(objpfx)filter: $(objpfx)filtmod1.so
855
856 # This does not link against libc.
857 CFLAGS-filtmod1.c += $(no-stack-protector)
858
859 $(objpfx)unload: $(libdl)
860 $(objpfx)unload.out: $(objpfx)unloadmod.so
861
862 $(objpfx)reldep: $(libdl)
863 $(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
864
865 $(objpfx)reldep2: $(libdl)
866 $(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
867
868 $(objpfx)reldep3: $(libdl)
869 $(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
870
871 $(objpfx)reldep4: $(libdl)
872 $(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
873
874 $(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
875 LDFLAGS-next = $(no-as-needed)
876
877 $(objpfx)unload2: $(libdl)
878 $(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
879
880 $(objpfx)lateglobal: $(libdl)
881 $(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
882
883 $(objpfx)tst-pathopt: $(libdl)
884 $(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
885 $(objpfx)pathoptobj.so
886 $(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
887 '$(run-program-env)' > $@; \
888 $(evaluate-test)
889
890 $(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
891 $(SHELL) $^ '$(test-wrapper)' '$(test-wrapper-env)' > $@; \
892 $(evaluate-test)
893
894 tst-rtld-preload-OBJS = $(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
895 $(objpfx)tst-rtld-preload.out: tst-rtld-preload.sh $(objpfx)ld.so \
896 $(objpfx)preloadtest \
897 $(preloadtest-preloads:%=$(objpfx)%.so)
898 $(SHELL) $< $(objpfx)ld.so $(objpfx)preloadtest \
899 '$(test-wrapper)' '$(test-wrapper-env)' '$(run_program_env)' \
900 '$(rpath-link)' '$(tst-rtld-preload-OBJS)' > $@; \
901 $(evaluate-test)
902
903 $(objpfx)initfirst: $(libdl)
904 $(objpfx)initfirst.out: $(objpfx)firstobj.so
905
906 $(objpfx)global: $(objpfx)globalmod1.so
907 $(objpfx)global.out: $(objpfx)reldepmod1.so
908
909 $(objpfx)dblload: $(libdl)
910 $(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
911
912 $(objpfx)dblunload: $(libdl)
913 $(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
914
915 $(objpfx)reldep5: $(libdl)
916 $(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod6.so
917
918 $(objpfx)reldep6: $(libdl)
919 $(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
920
921 $(objpfx)reldep7: $(libdl)
922 $(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
923
924 $(objpfx)reldep8: $(libdl)
925 $(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
926
927 LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
928 $(objpfx)nodelete2: $(libdl)
929 $(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
930
931 $(objpfx)reldep9: $(libdl)
932 $(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
933
934 $(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
935
936 $(objpfx)tst-tls4: $(libdl)
937 $(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
938
939 $(objpfx)tst-tls5: $(libdl)
940 $(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
941
942 $(objpfx)tst-tls6: $(libdl)
943 $(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
944
945 $(objpfx)tst-tls7: $(libdl)
946 $(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
947
948 $(objpfx)tst-tls8: $(libdl)
949 $(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
950
951 $(objpfx)tst-tls9: $(libdl)
952 $(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
953
954 $(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so $(objpfx)tst-tlsmod7.so
955
956 $(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so $(objpfx)tst-tlsmod9.so
957
958 $(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so $(objpfx)tst-tlsmod11.so
959
960 $(objpfx)tst-tls13: $(libdl)
961 $(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
962
963 $(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl)
964 $(objpfx)tst-tls14.out: $(objpfx)tst-tlsmod14b.so
965
966 $(objpfx)tst-tls15: $(libdl)
967 $(objpfx)tst-tls15.out: $(objpfx)tst-tlsmod15a.so $(objpfx)tst-tlsmod15b.so
968
969 $(objpfx)tst-tls-dlinfo: $(libdl)
970 $(objpfx)tst-tls-dlinfo.out: $(objpfx)tst-tlsmod2.so
971
972
973
974 $(objpfx)tst-tls16: $(libdl)
975 $(objpfx)tst-tls16.out: $(objpfx)tst-tlsmod16a.so $(objpfx)tst-tlsmod16b.so
976
977 $(objpfx)tst-tls17: $(libdl)
978 $(objpfx)tst-tls17.out: $(objpfx)tst-tlsmod17b.so
979 $(patsubst %,$(objpfx)%.os,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.os: tst-tlsmod17a.c
980 $(compile-command.c) -DN=$*
981 $(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules)): $(objpfx)tst-tlsmod17a%.so: $(objpfx)ld.so
982 $(objpfx)tst-tlsmod17b.so: $(patsubst %,$(objpfx)%.so,$(tlsmod17a-modules))
983
984 $(objpfx)tst-tls18: $(libdl)
985 $(objpfx)tst-tls18.out: $(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules))
986 $(patsubst %,$(objpfx)%.os,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.os : tst-tlsmod18a.c
987 $(compile-command.c) -DN=$*
988 $(patsubst %,$(objpfx)%.so,$(tlsmod18a-modules)): $(objpfx)tst-tlsmod18a%.so: $(objpfx)ld.so
989
990 $(objpfx)tst-tls19: $(libdl)
991 $(objpfx)tst-tls19.out: $(objpfx)tst-tls19mod1.so
992
993 CFLAGS-tst-align.c += $(stack-align-test-flags)
994 CFLAGS-tst-align2.c += $(stack-align-test-flags)
995 CFLAGS-tst-alignmod.c += $(stack-align-test-flags)
996 CFLAGS-tst-alignmod2.c += $(stack-align-test-flags)
997 $(objpfx)tst-align: $(libdl)
998 $(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
999 $(objpfx)tst-align2: $(objpfx)tst-alignmod2.so
1000
1001 $(objpfx)unload3: $(libdl)
1002 $(objpfx)unload3.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
1003 $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
1004
1005 $(objpfx)unload4: $(libdl)
1006 $(objpfx)unload4.out: $(objpfx)unload4mod1.so $(objpfx)unload4mod3.so
1007
1008 $(objpfx)unload5: $(libdl)
1009 $(objpfx)unload5.out: $(objpfx)unload3mod1.so $(objpfx)unload3mod2.so \
1010 $(objpfx)unload3mod3.so $(objpfx)unload3mod4.so
1011
1012 $(objpfx)unload6: $(libdl)
1013 $(objpfx)unload6.out: $(objpfx)unload6mod1.so $(objpfx)unload6mod2.so \
1014 $(objpfx)unload6mod3.so
1015
1016 $(objpfx)unload7: $(libdl)
1017 $(objpfx)unload7.out: $(objpfx)unload7mod1.so $(objpfx)unload7mod2.so
1018 unload7-ENV = MALLOC_PERTURB_=85
1019
1020 $(objpfx)unload8: $(libdl)
1021 $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
1022
1023 ifdef libdl
1024 $(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
1025 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
1026 endif
1027
1028 ifeq ($(have-z-execstack),yes)
1029 $(objpfx)tst-execstack: $(libdl)
1030 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
1031 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
1032 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
1033 LDFLAGS-tst-execstack-mod.so = -Wl,-z,execstack
1034
1035 $(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
1036 LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
1037
1038 LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
1039 CFLAGS-tst-execstack-prog.c += -Wno-trampolines
1040 CFLAGS-tst-execstack-mod.c += -Wno-trampolines
1041 endif
1042
1043 LDFLAGS-tst-array2 = $(no-as-needed)
1044 LDFLAGS-tst-array5 = $(no-as-needed)
1045
1046 $(objpfx)tst-array1-cmp.out: tst-array1.exp $(objpfx)tst-array1.out
1047 cmp $^ > $@; \
1048 $(evaluate-test)
1049
1050 $(objpfx)tst-array1-static-cmp.out: tst-array1.exp \
1051 $(objpfx)tst-array1-static.out
1052 cmp $^ > $@; \
1053 $(evaluate-test)
1054
1055 $(objpfx)tst-array2: $(objpfx)tst-array2dep.so
1056 $(objpfx)tst-array2-cmp.out: tst-array2.exp $(objpfx)tst-array2.out
1057 cmp $^ > $@; \
1058 $(evaluate-test)
1059
1060 $(objpfx)tst-array3-cmp.out: tst-array1.exp $(objpfx)tst-array3.out
1061 cmp $^ > $@; \
1062 $(evaluate-test)
1063
1064 $(objpfx)tst-array4: $(libdl)
1065 $(objpfx)tst-array4.out: $(objpfx)tst-array2dep.so
1066 $(objpfx)tst-array4-cmp.out: tst-array4.exp $(objpfx)tst-array4.out
1067 cmp $^ > $@; \
1068 $(evaluate-test)
1069
1070 $(objpfx)tst-array5: $(objpfx)tst-array5dep.so
1071 $(objpfx)tst-array5-cmp.out: tst-array5.exp $(objpfx)tst-array5.out
1072 cmp $^ > $@; \
1073 $(evaluate-test)
1074
1075 $(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
1076 $(objpfx)tst-array5-static.out
1077 cmp $^ > $@; \
1078 $(evaluate-test)
1079
1080 CFLAGS-tst-pie1.c += $(pie-ccflag)
1081 CFLAGS-tst-pie2.c += $(pie-ccflag)
1082
1083 $(objpfx)tst-piemod1.so: $(libsupport)
1084 $(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
1085 $(objpfx)tst-dlopen-pie: $(libdl)
1086 $(objpfx)tst-dlopen-pie.out: $(objpfx)tst-pie1
1087
1088 ifeq (yes,$(build-shared))
1089 # NB: Please keep cet-built-dso in sysdeps/x86/Makefile in sync with
1090 # all-built-dso here.
1091 all-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
1092 $(filter-out $(common-objpfx)linkobj/libc.so, \
1093 $(sort $(wildcard $(addprefix $(common-objpfx), \
1094 */lib*.so \
1095 iconvdata/*.so))))
1096
1097 $(all-built-dso:=.dyn): %.dyn: %
1098 @rm -f $@T
1099 LC_ALL=C $(READELF) -W -d $< > $@T
1100 test -s $@T
1101 mv -f $@T $@
1102 common-generated += $(all-built-dso:$(common-objpfx)%=%.dyn)
1103
1104 $(objpfx)check-textrel.out: $(..)scripts/check-textrel.awk \
1105 $(all-built-dso:=.dyn)
1106 LC_ALL=C $(AWK) -f $^ > $@; \
1107 $(evaluate-test)
1108 generated += check-textrel.out
1109
1110 $(objpfx)execstack-default: $(first-word $(wildcard $(sysdirs:%=%/stackinfo.h)))
1111 $(make-target-directory)
1112 { echo '#include <elf.h>'; \
1113 echo '#include <stackinfo.h>'; \
1114 echo '#if (DEFAULT_STACK_PERMS & PF_X) == 0'; \
1115 echo '@@@execstack-no@@@'; \
1116 echo '#else'; \
1117 echo '@@@execstack-yes@@@'; \
1118 echo '#endif'; } | \
1119 $(CC) $(CFLAGS) $(CPPFLAGS) -E -x c-header - | \
1120 sed -n -e 's/^@@@\(.*\)@@@/\1/p' > $@T
1121 mv -f $@T $@
1122 generated += execstack-default
1123
1124 $(all-built-dso:=.phdr): %.phdr: %
1125 @rm -f $@T
1126 LC_ALL=C $(READELF) -W -l $< > $@T
1127 test -s $@T
1128 mv -f $@T $@
1129 common-generated += $(all-built-dso:$(common-objpfx)%=%.phdr)
1130
1131 $(objpfx)check-execstack.out: $(..)scripts/check-execstack.awk \
1132 $(objpfx)execstack-default \
1133 $(all-built-dso:=.phdr)
1134 LC_ALL=C $(AWK) -v "xfail=$(check-execstack-xfail)" -f $^ > $@; \
1135 $(evaluate-test)
1136 generated += check-execstack.out
1137
1138 $(objpfx)tst-dlmodcount: $(libdl)
1139 $(objpfx)tst-dlmodcount.out: $(test-modules)
1140
1141 $(all-built-dso:=.jmprel): %.jmprel: % Makefile
1142 @rm -f $@T
1143 LC_ALL=C $(READELF) -W -S -d -r $< > $@T
1144 test -s $@T
1145 mv -f $@T $@
1146 common-generated += $(all-built-dso:$(common-objpfx)%=%.jmprel)
1147
1148 localplt-built-dso := $(addprefix $(common-objpfx),\
1149 libc.so \
1150 elf/ld.so \
1151 math/libm.so \
1152 rt/librt.so \
1153 dlfcn/libdl.so \
1154 resolv/libresolv.so \
1155 )
1156 ifeq ($(build-mathvec),yes)
1157 localplt-built-dso += $(addprefix $(common-objpfx), mathvec/libmvec.so)
1158 endif
1159 ifeq ($(have-thread-library),yes)
1160 localplt-built-dso += $(filter-out %_nonshared.a, $(shared-thread-library))
1161 endif
1162 ifeq ($(build-crypt),yes)
1163 localplt-built-dso += $(addprefix $(common-objpfx), crypt/libcrypt.so)
1164 endif
1165
1166 vpath localplt.data $(+sysdep_dirs)
1167
1168 $(objpfx)check-localplt.out: $(..)scripts/check-localplt.awk \
1169 $(..)scripts/localplt.awk \
1170 $(localplt-built-dso:=.jmprel) \
1171 localplt.data
1172 LC_ALL=C $(AWK) -f $(filter-out $< %localplt.data,$^) | \
1173 LC_ALL=C $(AWK) -f $< $(filter %localplt.data,$^) - \
1174 > $@; \
1175 $(evaluate-test)
1176 endif
1177
1178 $(all-built-dso:=.dynsym): %.dynsym: %
1179 @rm -f $@T
1180 LC_ALL=C $(READELF) -W --dyn-syms $< > $@T
1181 test -s $@T
1182 mv -f $@T $@
1183 common-generated += $(all-built-dso:$(common-objpfx)%=%.dynsym)
1184
1185 $(objpfx)check-initfini.out: $(..)scripts/check-initfini.awk \
1186 $(all-built-dso:=.dynsym)
1187 LC_ALL=C $(AWK) -f $^ > $@; \
1188 $(evaluate-test)
1189 generated += check-initfini.out
1190
1191 $(objpfx)tst-dlopenrpathmod.so: $(libdl)
1192 $(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so $(libdl)
1193 CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
1194 LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir
1195 $(objpfx)tst-dlopenrpath.out: $(objpfx)firstobj.so
1196
1197 $(objpfx)tst-deep1mod2.so: $(objpfx)tst-deep1mod3.so
1198 $(objpfx)tst-deep1: $(libdl) $(objpfx)tst-deep1mod1.so
1199 $(objpfx)tst-deep1.out: $(objpfx)tst-deep1mod2.so
1200 LDFLAGS-tst-deep1 += -rdynamic
1201 tst-deep1mod3.so-no-z-defs = yes
1202
1203 $(objpfx)tst-dlmopen1mod.so: $(libdl)
1204 $(objpfx)tst-dlmopen1: $(libdl)
1205 $(objpfx)tst-dlmopen1.out: $(objpfx)tst-dlmopen1mod.so
1206
1207 $(objpfx)tst-dlmopen2: $(libdl)
1208 $(objpfx)tst-dlmopen2.out: $(objpfx)tst-dlmopen1mod.so
1209
1210 $(objpfx)tst-dlmopen3: $(libdl)
1211 $(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so
1212
1213 $(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so
1214 tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1215
1216 $(objpfx)tst-audit2: $(libdl)
1217 $(objpfx)tst-audit2.out: $(objpfx)tst-auditmod1.so $(objpfx)tst-auditmod9b.so
1218 # Prevent GCC-5 from translating a malloc/memset pair into calloc
1219 CFLAGS-tst-audit2.c += -fno-builtin
1220 tst-audit2-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1221
1222 $(objpfx)tst-audit9: $(libdl)
1223 $(objpfx)tst-audit9.out: $(objpfx)tst-auditmod9a.so $(objpfx)tst-auditmod9b.so
1224 tst-audit9-ENV = LD_AUDIT=$(objpfx)tst-auditmod9a.so
1225
1226 $(objpfx)tst-audit8: $(libm)
1227 $(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so
1228 tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
1229
1230 $(objpfx)tst-global1: $(libdl)
1231 $(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
1232
1233 $(objpfx)order2: $(libdl)
1234 $(objpfx)order2.out: $(objpfx)order2mod1.so $(objpfx)order2mod2.so
1235 $(objpfx)order2-cmp.out: $(objpfx)order2.out
1236 (echo "12345" | cmp $< -) > $@; \
1237 $(evaluate-test)
1238 $(objpfx)order2mod1.so: $(objpfx)order2mod4.so
1239 $(objpfx)order2mod4.so: $(objpfx)order2mod3.so
1240 $(objpfx)order2mod2.so: $(objpfx)order2mod3.so
1241 order2mod2.so-no-z-defs = yes
1242 LDFLAGS-order2mod1.so = $(no-as-needed)
1243 LDFLAGS-order2mod2.so = $(no-as-needed)
1244
1245 tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
1246 tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
1247
1248 tst-ptrguard1-ARGS = --command "$(host-test-program-cmd) --child"
1249 # When built statically, the pointer guard interface uses
1250 # __pointer_chk_guard_local.
1251 CFLAGS-tst-ptrguard1-static.c += -DPTRGUARD_LOCAL
1252 tst-ptrguard1-static-ARGS = --command "$(objpfx)tst-ptrguard1-static --child"
1253
1254 $(objpfx)tst-leaks1: $(libdl)
1255 $(objpfx)tst-leaks1-mem.out: $(objpfx)tst-leaks1.out
1256 $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1.mtrace > $@; \
1257 $(evaluate-test)
1258
1259 $(objpfx)tst-leaks1-static: $(common-objpfx)dlfcn/libdl.a
1260 $(objpfx)tst-leaks1-static-mem.out: $(objpfx)tst-leaks1-static.out
1261 $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks1-static.mtrace > $@; \
1262 $(evaluate-test)
1263
1264 tst-leaks1-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1.mtrace
1265 tst-leaks1-static-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1-static.mtrace
1266
1267 $(objpfx)tst-addr1: $(libdl)
1268
1269 $(objpfx)tst-thrlock: $(libdl) $(shared-thread-library)
1270
1271 tst-tst-dlopen-aout-no-pie = yes
1272 $(objpfx)tst-dlopen-aout: $(libdl) $(shared-thread-library)
1273 CFLAGS-tst-dlopen-aout-pie.c += $(pie-ccflag)
1274 $(objpfx)tst-dlopen-aout-pie: $(libdl) $(shared-thread-library)
1275 $(objpfx)tst-dlopen-aout-container: $(libdl) $(shared-thread-library)
1276 LDFLAGS-tst-dlopen-aout-container += -Wl,-rpath,\$$ORIGIN
1277
1278 CFLAGS-ifuncmain1pic.c += $(pic-ccflag)
1279 CFLAGS-ifuncmain1picstatic.c += $(pic-ccflag)
1280 CFLAGS-ifuncmain1staticpic.c += $(pic-ccflag)
1281 CFLAGS-ifuncdep1pic.c += $(pic-ccflag)
1282 CFLAGS-ifuncmain1vispic.c += $(pic-ccflag)
1283 CFLAGS-ifuncmain2pic.c += $(pic-ccflag)
1284 CFLAGS-ifuncmain2picstatic.c += $(pic-ccflag)
1285 CFLAGS-ifuncdep2pic.c += $(pic-ccflag)
1286 CFLAGS-ifuncmain4picstatic.c += $(pic-ccflag)
1287 CFLAGS-ifuncmain5pic.c += $(pic-ccflag)
1288 CFLAGS-ifuncmain5picstatic.c += $(pic-ccflag)
1289 CFLAGS-ifuncmain5staticpic.c += $(pic-ccflag)
1290 CFLAGS-ifuncdep5pic.c += $(pic-ccflag)
1291 CFLAGS-ifuncmain7pic.c += $(pic-ccflag)
1292 CFLAGS-ifuncmain7picstatic.c += $(pic-ccflag)
1293 CFLAGS-ifuncmain9pic.c += $(pic-ccflag)
1294 CFLAGS-ifuncmain9picstatic.c += $(pic-ccflag)
1295
1296 LDFLAGS-ifuncmain3 = -Wl,-export-dynamic
1297
1298 CFLAGS-ifuncmain1pie.c += $(pie-ccflag)
1299 CFLAGS-ifuncmain1vispie.c += $(pie-ccflag)
1300 CFLAGS-ifuncmain1staticpie.c += $(pie-ccflag)
1301 CFLAGS-ifuncmain5pie.c += $(pie-ccflag)
1302 CFLAGS-ifuncmain6pie.c += $(pie-ccflag)
1303 CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
1304 CFLAGS-ifuncmain9pie.c += $(pie-ccflag)
1305 CFLAGS-tst-ifunc-textrel.c += $(pic-ccflag)
1306
1307 $(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so
1308 $(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o
1309 $(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so
1310 $(objpfx)ifuncmain5pie: $(objpfx)ifuncmod5.so
1311 $(objpfx)ifuncmain6pie: $(objpfx)ifuncmod6.so
1312
1313 $(objpfx)ifuncmain1: $(addprefix $(objpfx),ifuncmod1.so)
1314 $(objpfx)ifuncmain1pic: $(addprefix $(objpfx),ifuncmod1.so)
1315 $(objpfx)ifuncmain1staticpic: $(addprefix $(objpfx),ifuncdep1pic.o)
1316 $(objpfx)ifuncmain1static: $(addprefix $(objpfx),ifuncdep1.o)
1317 $(objpfx)ifuncmain1picstatic: $(addprefix $(objpfx),ifuncdep1pic.o)
1318 $(objpfx)ifuncmain1vis: $(addprefix $(objpfx),ifuncmod1.so)
1319 $(objpfx)ifuncmain1vispic: $(addprefix $(objpfx),ifuncmod1.so)
1320 $(objpfx)ifuncmain2: $(addprefix $(objpfx),ifuncdep2.o)
1321 $(objpfx)ifuncmain2pic: $(addprefix $(objpfx),ifuncdep2pic.o)
1322 $(objpfx)ifuncmain2static: $(addprefix $(objpfx),ifuncdep2.o)
1323 $(objpfx)ifuncmain2picstatic: $(addprefix $(objpfx),ifuncdep2pic.o)
1324
1325 $(objpfx)ifuncmain3: $(libdl)
1326 $(objpfx)ifuncmain3.out: $(objpfx)ifuncmod3.so
1327
1328 $(objpfx)ifuncmain5: $(addprefix $(objpfx),ifuncmod5.so)
1329 $(objpfx)ifuncmain5pic: $(addprefix $(objpfx),ifuncmod5.so)
1330 $(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
1331 $(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
1332 $(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
1333
1334 $(objpfx)tst-unique1: $(libdl)
1335 $(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
1336 $(objpfx)tst-unique1mod2.so
1337
1338 $(objpfx)tst-unique2: $(libdl) $(objpfx)tst-unique2mod1.so
1339 $(objpfx)tst-unique2.out: $(objpfx)tst-unique2mod2.so
1340
1341 $(objpfx)tst-unique3: $(libdl) $(objpfx)tst-unique3lib.so
1342 $(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
1343
1344 $(objpfx)tst-unique4: $(objpfx)tst-unique4lib.so
1345
1346 $(objpfx)tst-nodelete: $(libdl)
1347 $(objpfx)tst-nodelete.out: $(objpfx)tst-nodelete-uniquemod.so \
1348 $(objpfx)tst-nodelete-rtldmod.so \
1349 $(objpfx)tst-nodelete-zmod.so
1350
1351 LDFLAGS-tst-nodelete = -rdynamic
1352 LDFLAGS-tst-nodelete-zmod.so = -Wl,--enable-new-dtags,-z,nodelete
1353
1354 $(objpfx)tst-nodelete2: $(libdl)
1355 $(objpfx)tst-nodelete2.out: $(objpfx)tst-nodelete2mod.so
1356
1357 LDFLAGS-tst-nodelete2 = -rdynamic
1358
1359 $(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
1360 cmp $^ > $@; \
1361 $(evaluate-test)
1362
1363 $(objpfx)tst-initorder2: $(objpfx)tst-initorder2a.so $(objpfx)tst-initorder2d.so $(objpfx)tst-initorder2c.so
1364 $(objpfx)tst-initorder2a.so: $(objpfx)tst-initorder2b.so
1365 $(objpfx)tst-initorder2b.so: $(objpfx)tst-initorder2c.so
1366 $(objpfx)tst-initorder2c.so: $(objpfx)tst-initorder2d.so
1367 LDFLAGS-tst-initorder2 = $(no-as-needed)
1368 LDFLAGS-tst-initorder2a.so = $(no-as-needed)
1369 LDFLAGS-tst-initorder2b.so = $(no-as-needed)
1370 LDFLAGS-tst-initorder2c.so = $(no-as-needed)
1371 define o-iterator-doit
1372 $(objpfx)tst-initorder2$o.os: tst-initorder2.c; \
1373 $$(compile-command.c) -DNAME=\"$o\"
1374 endef
1375 object-suffixes-left := a b c d
1376 include $(o-iterator)
1377
1378 $(objpfx)tst-initorder2-cmp.out: tst-initorder2.exp $(objpfx)tst-initorder2.out
1379 cmp $^ > $@; \
1380 $(evaluate-test)
1381
1382 $(objpfx)tst-relsort1: $(libdl)
1383 $(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
1384 $(objpfx)tst-relsort1mod2.so: $(libm)
1385 $(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
1386 $(objpfx)tst-relsort1mod2.so
1387
1388 $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
1389 $(test-wrapper-env) \
1390 LD_TRACE_LOADED_OBJECTS=1 \
1391 LD_DEBUG=unused \
1392 LD_PRELOAD= \
1393 $(rtld-prefix) \
1394 $< > $@; \
1395 $(evaluate-test)
1396
1397 $(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
1398 cmp $< /dev/null > $@; \
1399 $(evaluate-test)
1400
1401 $(objpfx)tst-audit11.out: $(objpfx)tst-auditmod11.so $(objpfx)tst-audit11mod1.so
1402 $(objpfx)tst-audit11: $(libdl)
1403 tst-audit11-ENV = LD_AUDIT=$(objpfx)tst-auditmod11.so
1404 $(objpfx)tst-audit11mod1.so: $(objpfx)tst-audit11mod2.so
1405 LDFLAGS-tst-audit11mod2.so = -Wl,--version-script=tst-audit11mod2.map,-soname,tst-audit11mod2.so
1406
1407 $(objpfx)tst-audit12.out: $(objpfx)tst-auditmod12.so $(objpfx)tst-audit12mod1.so $(objpfx)tst-audit12mod3.so
1408 $(objpfx)tst-audit12: $(libdl)
1409 tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so
1410 $(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so
1411 LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
1412
1413 $(objpfx)tst-audit13.out: $(objpfx)tst-audit13mod1.so
1414 LDFLAGS-tst-audit13mod1.so = -Wl,-z,lazy
1415 tst-audit13-ENV = LD_AUDIT=$(objpfx)tst-audit13mod1.so
1416
1417 # tst-sonamemove links against an older implementation of the library.
1418 LDFLAGS-tst-sonamemove-linkmod1.so = \
1419 -Wl,--version-script=tst-sonamemove-linkmod1.map \
1420 -Wl,-soname,tst-sonamemove-runmod1.so
1421 LDFLAGS-tst-sonamemove-runmod1.so = -Wl,--no-as-needed \
1422 -Wl,--version-script=tst-sonamemove-runmod1.map \
1423 -Wl,-soname,tst-sonamemove-runmod1.so
1424 LDFLAGS-tst-sonamemove-runmod2.so = \
1425 -Wl,--version-script=tst-sonamemove-runmod2.map \
1426 -Wl,-soname,tst-sonamemove-runmod2.so
1427 $(objpfx)tst-sonamemove-runmod1.so: $(objpfx)tst-sonamemove-runmod2.so
1428 # Link against the link module, but depend on the run-time modules
1429 # for execution.
1430 $(objpfx)tst-sonamemove-link: $(objpfx)tst-sonamemove-linkmod1.so
1431 $(objpfx)tst-sonamemove-link.out: \
1432 $(objpfx)tst-sonamemove-runmod1.so \
1433 $(objpfx)tst-sonamemove-runmod2.so
1434 $(objpfx)tst-sonamemove-dlopen: $(libdl)
1435 $(objpfx)tst-sonamemove-dlopen.out: \
1436 $(objpfx)tst-sonamemove-runmod1.so \
1437 $(objpfx)tst-sonamemove-runmod2.so
1438
1439 # Override -z defs, so that we can reference an undefined symbol.
1440 # Force lazy binding for the same reason.
1441 LDFLAGS-tst-latepthreadmod.so = \
1442 -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all
1443 # Do not optimize sibling calls as the test relies on a JMP_SLOT relocation for
1444 # function this_function_is_not_defined.
1445 CFLAGS-tst-latepthreadmod.c += -fno-optimize-sibling-calls
1446 $(objpfx)tst-latepthreadmod.so: $(shared-thread-library)
1447 $(objpfx)tst-latepthread: $(libdl)
1448 $(objpfx)tst-latepthread.out: $(objpfx)tst-latepthreadmod.so
1449
1450 # The test modules are parameterized by preprocessor macros.
1451 $(patsubst %,$(objpfx)%.os,$(tst-tls-many-dynamic-modules)): \
1452 $(objpfx)tst-tls-manydynamic%mod.os : tst-tls-manydynamicmod.c
1453 $(compile-command.c) \
1454 -DNAME=tls_global_$* -DSETTER=set_value_$* -DGETTER=get_value_$*
1455 $(objpfx)tst-tls-manydynamic: $(libdl) $(shared-thread-library)
1456 $(objpfx)tst-tls-manydynamic.out: \
1457 $(patsubst %,$(objpfx)%.so,$(tst-tls-many-dynamic-modules))
1458
1459 tst-prelink-ENV = LD_TRACE_PRELINKING=1
1460
1461 $(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
1462 grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
1463
1464 $(objpfx)tst-prelink-cmp.out: tst-prelink.exp \
1465 $(objpfx)tst-prelink-conflict.out
1466 cmp $^ > $@; \
1467 $(evaluate-test)
1468
1469 $(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig
1470 $(SHELL) $< '$(common-objpfx)' '$(test-wrapper-env)' \
1471 '$(run-program-env)' > $@; \
1472 $(evaluate-test)
1473
1474 $(objpfx)tst-dlsym-error: $(libdl)
1475
1476 # Test static linking of all the libraries we can possibly link
1477 # together. Note that in some configurations this may be less than the
1478 # complete list of libraries we build but we try to maxmimize this list.
1479 $(objpfx)tst-linkall-static: \
1480 $(common-objpfx)math/libm.a \
1481 $(common-objpfx)resolv/libresolv.a \
1482 $(common-objpfx)dlfcn/libdl.a \
1483 $(common-objpfx)login/libutil.a \
1484 $(common-objpfx)rt/librt.a \
1485 $(common-objpfx)resolv/libanl.a \
1486 $(static-thread-library)
1487
1488 ifeq ($(build-crypt),yes)
1489 # If we are using NSS crypto and we have the ability to link statically
1490 # then we include libcrypt.a, otherwise we leave out libcrypt.a and
1491 # link as much as we can into the tst-linkall-static test. This assumes
1492 # that linking with libcrypt.a does everything required to include the
1493 # static NSS crypto library.
1494 ifeq (yesyes,$(nss-crypt)$(static-nss-crypt))
1495 $(objpfx)tst-linkall-static: \
1496 $(common-objpfx)crypt/libcrypt.a
1497 endif
1498 # If we are not using NSS crypto then we always have the ability to link
1499 # with libcrypt.a.
1500 ifeq (no,$(nss-crypt))
1501 $(objpfx)tst-linkall-static: \
1502 $(common-objpfx)crypt/libcrypt.a
1503 endif
1504 endif
1505
1506 # The application depends on the DSO, and the DSO loads the plugin.
1507 # The plugin also depends on the DSO. This creates the circular
1508 # dependency via dlopen that we're testing to make sure works.
1509 $(objpfx)tst-nodelete-dlclose-dso.so: $(libdl)
1510 $(objpfx)tst-nodelete-dlclose-plugin.so: $(objpfx)tst-nodelete-dlclose-dso.so
1511 $(objpfx)tst-nodelete-dlclose: $(objpfx)tst-nodelete-dlclose-dso.so
1512 $(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \
1513 $(objpfx)tst-nodelete-dlclose-plugin.so
1514
1515 tst-env-setuid-ENV = MALLOC_CHECK_=2 MALLOC_MMAP_THRESHOLD_=4096 \
1516 LD_HWCAP_MASK=0x1
1517 tst-env-setuid-tunables-ENV = \
1518 GLIBC_TUNABLES=glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096
1519
1520 $(objpfx)tst-debug1: $(libdl)
1521 $(objpfx)tst-debug1.out: $(objpfx)tst-debug1mod1.so
1522
1523 $(objpfx)tst-debug1mod1.so: $(objpfx)testobj1.so
1524 $(OBJCOPY) --only-keep-debug $< $@
1525
1526 $(objpfx)tst-main1: $(objpfx)tst-main1mod.so
1527 CRT-tst-main1 := $(csu-objpfx)crt1.o
1528 tst-main1-no-pie = yes
1529 LDLIBS-tst-main1 = $(libsupport)
1530 tst-main1mod.so-no-z-defs = yes
1531
1532 LDLIBS-tst-absolute-sym-lib.so = tst-absolute-sym-lib.lds
1533 $(objpfx)tst-absolute-sym-lib.so: $(LDLIBS-tst-absolute-sym-lib.so)
1534 $(objpfx)tst-absolute-sym: $(objpfx)tst-absolute-sym-lib.so
1535
1536 LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
1537 $(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
1538 $(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
1539
1540 # Both the main program and the DSO for tst-libc_dlvsym need to link
1541 # against libdl.
1542 $(objpfx)tst-libc_dlvsym: $(libdl)
1543 $(objpfx)tst-libc_dlvsym-dso.so: $(libsupport) $(libdl)
1544 $(objpfx)tst-libc_dlvsym.out: $(objpfx)tst-libc_dlvsym-dso.so
1545 $(objpfx)tst-libc_dlvsym-static: $(common-objpfx)dlfcn/libdl.a
1546 tst-libc_dlvsym-static-ENV = \
1547 LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
1548 $(objpfx)tst-libc_dlvsym-static.out: $(objpfx)tst-libc_dlvsym-dso.so
1549
1550 $(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
1551 # Avoid creating an ABI tag note, which may come before the
1552 # artificial, large note in tst-big-note-lib.o and invalidate the
1553 # test.
1554 $(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o
1555 $(LINK.o) -shared -o $@ $(LDFLAGS.so) $<
1556
1557 $(objpfx)tst-unwind-ctor: $(objpfx)tst-unwind-ctor-lib.so
1558
1559 CFLAGS-tst-unwind-main.c += -funwind-tables -DUSE_PTHREADS=0