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