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