]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/Makefile
Update.
[thirdparty/glibc.git] / elf / Makefile
CommitLineData
4df8c11d 1# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc.
01cc0be6
RM
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
41bdb6e2
AJ
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.
01cc0be6
RM
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
41bdb6e2 12# Lesser General Public License for more details.
01cc0be6 13
41bdb6e2
AJ
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.
01cc0be6 18
3db52d94
UD
19# Makefile for elf subdirectory of GNU C Library.
20
d66e34cd
RM
21subdir := elf
22
019e7a64 23headers = elf.h bits/elfclass.h link.h
39ab0fdf 24routines = $(dl-routines) dl-open dl-close dl-support dl-iteratephdr \
27d640be 25 dl-addr enbl-secure dl-profstub \
ce460d04 26 dl-origin dl-libc dl-sym dl-tsd
266180eb
RM
27
28# The core dynamic linking functions are in libc for the static and
29# profiled libraries.
f18edac3 30dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
3996f34b 31 runtime error init fini debug misc \
2abf9ff1 32 version profile conflict tls origin \
eec8b6ca 33 execstack caller)
b79f74cd 34all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
266180eb 35# But they are absent from the shared libc, because that code is in ld.so.
27d640be 36elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin
44094580 37shared-only-routines += dl-caller
266180eb
RM
38
39# ld.so uses those routines, plus some special stuff for being the program
40# interpreter and operating independent of libc.
ce460d04 41rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
e39e6956 42all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
b79f74cd 43
ce460d04
RM
44distribute := rtld-Rules \
45 $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
b3ed8219 46 dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
94e365c6
UD
47 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
48 dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
c77ec56d 49 do-lookup.h dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
94e365c6 50 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
2b7238dd 51 testobj6.c testobj1_1.c failobj.c unloadmod.c \
84ddc586 52 ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
e340a2a2 53 chroot_canon.c gccframe.h \
74955460 54 dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h unsecvars.h \
afa0569f 55 vismain.c vismod1.c vismod2.c vismod3.c \
74dd1fee
UD
56 constload2.c constload3.c filtmod1.c filtmod2.c \
57 nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
2b7238dd 58 nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
917fd061 59 reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
c4bb124a 60 reldepmod5.c reldepmod6.c \
1826d793 61 reldep4mod1.c reldep4mod2.c reldep4mod3.c reldep4mod4.c \
8bc6161d 62 nextmod1.c nextmod2.c pathoptobj.c tst-pathopt.sh \
5ab7f7c1 63 neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
421f0c9d 64 neededobj5.c neededobj6.c firstobj.c \
1a511d31 65 unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
3fac0001 66 testobj.h vismod.h globalmod1.c \
ab92bebd
UD
67 dblloadmod1.c dblloadmod2.c dblloadmod3.c \
68 reldep6mod4.c reldep6mod3.c reldep6mod2.c reldep6mod1.c \
a41d8a74 69 reldep6mod0.c reldep7mod1.c reldep7mod2.c \
ab92bebd 70 unwind-dw2.c unwind-dw2-fde.c unwind.h unwind-pe.h \
2cef4257 71 unwind-dw2-fde.h dwarf2.h dl-procinfo.c tls.h dl-tls.h \
4c53d221 72 tst-tlsmod1.c tst-tlsmod2.c tst-tlsmod3.c tst-tlsmod4.c \
94c24227
UD
73 tst-tlsmod5.c tst-tlsmod6.c tst-tlsmod7.c tst-tlsmod8.c \
74 tst-tlsmod9.c tst-tlsmod10.c tst-tlsmod11.c \
06f6ca90 75 tst-tlsmod12.c tst-tls10.h tst-alignmod.c \
4c53d221
UD
76 circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \
77 circlemod3.c circlemod3a.c nodlopenmod2.c \
cfaf5e56 78 tls-macros.h \
aff4519d
UD
79 reldep8mod1.c reldep8mod2.c reldep8mod3.c \
80 nodel2mod1.c nodel2mod2.c nodel2mod3.c \
ec503662
UD
81 reldep9.c reldep9mod1.c reldep9mod2.c reldep9mod3.c \
82 tst-array1.exp tst-array2.exp tst-array4.exp \
f17ed1a9 83 tst-array2dep.c tst-piemod1.c \
bed12f78 84 tst-execstack-mod.c tst-dlmodcount.c \
28977c2c 85 check-textrel.c dl-sysdep.h test-dlopenrpathmod.c
d66e34cd 86
80b54217 87CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
bb958f59 88CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
e07bb02a 89CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
80b54217 90
05f732b3
UD
91include ../Makeconfig
92
74bd2300 93ifeq ($(unwind-find-fde),yes)
a0dcb689 94routines += unwind-dw2-fde-glibc
44094580 95shared-only-routines += unwind-dw2-fde-glibc
74bd2300
UD
96endif
97
40c4c9b5 98before-compile = $(objpfx)trusted-dirs.h
5a384a91
UD
99generated := trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
100generated-dirs := for-renamed
fd26970f 101
bdd421cc 102ifeq ($(versioning),yes)
a0edd63e 103ld-map = $(common-objpfx)ld.map
bdd421cc
UD
104endif
105
d66e34cd 106ifeq (yes,$(build-shared))
b79f74cd 107extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
40c4c9b5 108generated += librtld.os dl-allobjs.os ld.so ldd
8d57beea 109install-others = $(inst_slibdir)/$(rtld-installed-name)
6c3ebebd 110install-bin-script = ldd
f49bc43f 111endif
86d2c878 112
9d141cae 113others = sprof sln
6c3ebebd 114install-bin = sprof
9d141cae
UD
115others-static = sln
116install-rootsbin = sln
ae828bc6 117
591e1ffb 118ifeq (yes,$(use-ldconfig))
99ac5e47 119ifeq (yes,$(build-shared))
e1586792 120others-static += ldconfig
da2d1bc5 121others += ldconfig
9d141cae 122install-rootsbin += ldconfig
591e1ffb 123
b4a555d6 124ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon
591e1ffb
UD
125extra-objs += $(ldconfig-modules:=.o)
126
127# To find xmalloc.c and xstrdup.c
128vpath %.c ../locale/programs
129
99ac5e47 130endif
1ef32c3d
UD
131endif
132
6ef518c3 133tests = tst-tls1 tst-tls2 tst-tls9
dfe4c900 134ifeq (yes,$(have-initfini-array))
62f29da7 135tests += tst-array1 tst-array2 tst-array3 tst-array4
dfe4c900 136endif
db265313
RM
137ifeq (yes,$(build-static))
138tests-static = tst-tls1-static tst-tls2-static
6ef518c3
RM
139ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
140tests-static += tst-tls9-static
141tst-tls9-static-ENV = \
142 LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
143endif
db265313
RM
144tests += $(tests-static)
145endif
2f512715 146ifeq (yes,$(build-shared))
db265313
RM
147tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
148 constload1 order $(tests-vis-$(have-protected)) noload filter unload \
149 reldep reldep2 reldep3 reldep4 $(tests-nodelete-$(have-z-nodelete)) \
150 $(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
151 neededtest3 neededtest4 unload2 lateglobal initfirst global \
cfaf5e56 152 restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
94c24227 153 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
2abf9ff1 154 tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-align \
28977c2c 155 $(tests-execstack-$(have-z-execstack)) tst-dlmodcount tst-dlopenrpath
aff4519d 156# reldep9
5a384a91 157test-srcs = tst-pathopt
c1025c19 158tests-vis-yes = vismain
aff4519d 159tests-nodelete-yes = nodelete nodelete2
87837aac 160tests-nodlopen-yes = nodlopen nodlopen2
c70ba488 161tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
2f512715 162endif
f17ed1a9
UD
163ifeq (yesyes,$(have-fpie)$(build-shared))
164tests: $(objpfx)tst-pie1.out
165endif
a25f2023 166modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
2b7238dd 167 testobj1_1 failobj constload2 constload3 unloadmod \
0fb7851f 168 dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
2f54c82d 169 $(modules-nodelete-$(have-z-nodelete)) \
2b7238dd 170 $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
ceb579a3 171 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
1826d793 172 reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
8edd9172 173 neededobj1 neededobj2 neededobj3 neededobj4 \
273a3cfb 174 neededobj5 neededobj6 firstobj globalmod1 \
3fac0001 175 unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
c47e78b1 176 dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
2e36cb48 177 reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
a41d8a74 178 reldep7mod1 reldep7mod2 \
6d78cd00 179 tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
94c24227
UD
180 tst-tlsmod5 tst-tlsmod6 tst-tlsmod7 tst-tlsmod8 \
181 tst-tlsmod9 tst-tlsmod10 tst-tlsmod11 tst-tlsmod12 \
99fe3b0e 182 tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \
6d78cd00 183 circlemod1 circlemod1a circlemod2 circlemod2a \
cfaf5e56 184 circlemod3 circlemod3a \
aff4519d 185 reldep8mod1 reldep8mod2 reldep8mod3 \
06f6ca90 186 reldep9mod1 reldep9mod2 reldep9mod3 \
28977c2c
UD
187 tst-alignmod $(modules-execstack-$(have-z-execstack)) \
188 tst-dlopenrpathmod
dfe4c900
RM
189ifeq (yes,$(have-initfini-array))
190modules-names += tst-array2dep
191endif
f17ed1a9
UD
192ifeq (yesyes,$(have-fpie)$(build-shared))
193modules-names += tst-piemod1
194endif
c1025c19 195modules-vis-yes = vismod1 vismod2 vismod3
aff4519d
UD
196modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
197 nodel2mod1 nodel2mod2 nodel2mod3
87837aac 198modules-nodlopen-yes = nodlopenmod nodlopenmod2
2abf9ff1 199modules-execstack-yes = tst-execstack-mod
9b014809 200extra-objs += $(addsuffix .os,$(strip $(modules-names)))
724d8c3f
RM
201# We need this variable to be sure the test modules get the right CPPFLAGS.
202test-extras += $(modules-names)
dc18d4d8 203
01cc0be6 204include ../Rules
d66e34cd 205
fd54683c
RM
206check-abi: check-abi-ld
207update-abi: update-abi-ld
208
1ef32c3d 209ifeq (yes,$(build-shared))
a89d30d4
RM
210# Make sure these things are built in the `make lib' pass so they can be used
211# to run programs during the `make others' pass.
212lib-noranlib: $(objpfx)$(rtld-installed-name) \
213 $(addprefix $(objpfx),$(extra-objs))
214endif
215
db2286f6 216# Command to link into a larger single relocatable object.
ce460d04 217reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
db2286f6 218
b79f74cd 219$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
ce460d04 220 $(reloc-link) -o $@ $^
db2286f6 221
86d2c878 222# Link together the dynamic linker into a single relocatable object.
ce460d04
RM
223# First we do a link against libc_pic.a just to get a link map,
224# and discard the object produced by that link. From the link map
225# we can glean all the libc modules that need to go into the dynamic
226# linker. Then we do a recursive make that goes into all the subdirs
227# those modules come from and builds special rtld-foo.os versions that
228# are compiled with special flags, and puts these modules into rtld-libc.a
229# for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
230
231$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
240e87c2
RM
232 @-rm -f $@T
233 $(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
ce460d04 234 rm -f $@.o
240e87c2 235 mv -f $@T $@
ce460d04
RM
236
237$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
b61c8aba 238 LC_ALL=C \
6461e577
RM
239 sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
240 $< | \
ce460d04
RM
241 while read lib file; do \
242 case $$lib in \
243 libc_pic.a) \
b61c8aba 244 LC_ALL=C fgrep -l /$$file \
ce460d04 245 $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
b61c8aba 246 LC_ALL=C \
ce460d04
RM
247 sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
248 ;; \
249 */*.a) \
250 echo rtld-$${lib%%/*} += $$file ;; \
251 *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
252 esac; \
253 done > $@T
b61c8aba
UD
254 echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
255 | LC_ALL=C sort -u` >> $@T
ce460d04
RM
256 mv -f $@T $@
257
258$(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
259 $(MAKE) -f $< -f rtld-Rules
260
ce460d04 261$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
5896ffa8
UD
262 $(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
263 -Wl,-Map,$@.map
264
265generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
d66e34cd 266
4df8c11d
UD
267z-now-yes = -Wl,-z,now
268
32e6df36 269$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
070cadeb 270 @rm -f $@.lds
4df8c11d 271 $(LINK.o) -nostdlib -nostartfiles -shared $(z-now-$(bind-now)) \
9ae10332 272 $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \
b61c8aba 273 LC_ALL=C \
32e6df36
UD
274 sed -e '/^=========/,/^=========/!d;/^=========/d' \
275 -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
070cadeb 276 > $@.lds
9ae10332 277 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
4df8c11d 278 $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
32e6df36 279 $(filter-out $(map-file),$^) $(load-map-file) \
070cadeb 280 -Wl,-soname=$(rtld-installed-name) -T $@.lds
32e6df36 281 rm -f $@.lds
266180eb 282
c7562c74 283# interp.c exists just to get this string into the libraries.
b30542fb
UD
284CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \
285 -DNOT_IN_libc=1
656f8223 286$(objpfx)interp.os: $(common-objpfx)config.make
c7562c74 287
1ef32c3d 288ifneq (ld.so,$(rtld-installed-name))
afd4eb37 289# Make sure ld.so.1 exists in the build directory so we can link
852fc4b9
RM
290# against it.
291$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
292 rm -f $@
f332db02 293 ln -s $(<F) $@
da2d1bc5 294generated += $(rtld-installed-name)
852fc4b9
RM
295endif
296
fd26970f
UD
297# Build a file mentioning all trustworthy directories to look for shared
298# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
299# add directories to the list by defining $(user-defined-trusted-dirs)
300# before starting make.
6598ac30
UD
301$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
302$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1ef32c3d 303 $(make-target-directory)
ab7eb292
UD
304 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
305 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
ce460d04 306 echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
6598ac30
UD
307 $(move-if-change) ${@:st=T} ${@:st=h}
308 touch $@
a986484f 309CPPFLAGS-dl-load.c = -I$(objpfx). -I$(csu-objpfx).
86d2c878 310
9f2a9248 311ifeq (yes,$(build-shared))
73237de3 312$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
460adbb8 313 $(make-target-directory)
925e31d9 314 $(do-install-program)
1ef32c3d 315
8d57beea 316$(inst_slibdir)/$(rtld-installed-name): \
460adbb8
UD
317 $(inst_slibdir)/$(rtld-version-installed-name) \
318 $(inst_slibdir)/libc-$(version).so
925e31d9 319 $(make-shlib-link)
b122c703 320
5148d49f
UD
321# Special target called by parent to install just the dynamic linker.
322.PHONY: ldso_install
323ldso_install: $(inst_slibdir)/$(rtld-installed-name)
9f2a9248 324endif
5148d49f 325
cb343854 326
926e512f
RM
327common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
328 -e 's%@VERSION@%$(version)%g'
1ddf537f 329sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
926e512f 330bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
4a33c2f5 331 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
cb343854 332
84384f5b 333ifneq ($(have-bash2),yes)
cb343854 334ldd-shell = sh
e2102c14
UD
335else
336ldd-shell = bash
cb343854
UD
337endif
338
339ifeq ($(ldd-rewrite-script),no)
340define gen-ldd
b61c8aba 341LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
cb343854 342endef
84384f5b 343else
cb343854 344define gen-ldd
b61c8aba 345LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< | LC_ALL=C sed -f $(ldd-rewrite-script) > $@.new
cb343854
UD
346endef
347endif
348
926e512f 349$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
ee74a442 350 $(common-objpfx)config.make
cb343854 351 $(gen-ldd)
84384f5b
UD
352 chmod 555 $@.new
353 mv -f $@.new $@
cb343854 354
aaff4ba9 355$(objpfx)sprof: $(libdl)
94e365c6 356
591e1ffb 357$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
8ca91b36 358SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
1a379ea0 359CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
11bf8ce1 360 -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
8ca91b36
UD
361CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
362CFLAGS-cache.c = $(SYSCONF-FLAGS)
591e1ffb 363
ce460d04 364CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
0d01dace 365
9b014809
UD
366test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
367generated += $(addsuffix .so,$(strip $(modules-names)))
482eec0d 368
e1e3ba54 369ifeq (yes,$(build-shared))
8c0fe290 370ifeq ($(cross-compiling),no)
5a384a91 371tests: $(objpfx)tst-pathopt.out
e1e3ba54 372endif
8c0fe290 373endif
5a384a91 374
aaff4ba9
UD
375$(objpfx)testobj1.so: $(libdl)
376$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
377$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
378$(objpfx)testobj3.so: $(libdl)
379$(objpfx)testobj4.so: $(libdl)
380$(objpfx)testobj5.so: $(libdl)
e30f2b98 381$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
e18db2b0 382$(objpfx)failobj.so: $(objpfx)testobj6.so
84ddc586
UD
383$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
384$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
385$(objpfx)dep4.so: $(objpfx)dep3.so
2cb8cefb 386$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
917fd061 387$(objpfx)nextmod1.so: $(libdl)
ceb579a3
UD
388$(objpfx)neededobj1.so: $(libdl)
389$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
390$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
8edd9172
UD
391$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
392 $(objpfx)neededobj3.so $(libdl)
c77a4478 393$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
f6de2239 394$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
d785c366 395$(objpfx)ltglobmod2.so: $(libdl)
b71e7ce8 396$(objpfx)firstobj.so: $(shared-thread-library)
273a3cfb 397$(objpfx)globalmod1.so: $(libdl)
1826d793
UD
398$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
399$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
3fac0001
UD
400$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
401$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
c4bb124a
UD
402$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
403$(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
c47e78b1
UD
404$(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
405$(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
406$(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
407$(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
fc093be1 408$(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
94c24227
UD
409$(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
410$(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
411$(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
541765b6 412$(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
aff4519d
UD
413# For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
414$(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
415$(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
556224ab 416$(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
aff4519d
UD
417$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
418$(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
419$(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
ceb579a3 420
6ef518c3
RM
421LDFLAGS-tst-tlsmod5.so = -nostdlib
422LDFLAGS-tst-tlsmod6.so = -nostdlib
423
1a379ea0
UD
424testobj1.so-no-z-defs = yes
425testobj3.so-no-z-defs = yes
426testobj4.so-no-z-defs = yes
427testobj5.so-no-z-defs = yes
428testobj6.so-no-z-defs = yes
429failobj.so-no-z-defs = yes
430constload2.so-no-z-defs = yes
431constload3.so-no-z-defs = yes
432nodelmod1.so-no-z-defs = yes
433nodelmod2.so-no-z-defs = yes
434nodelmod4.so-no-z-defs = yes
435nodel2mod2.so-no-z-defs = yes
436reldepmod2.so-no-z-defs = yes
437reldepmod3.so-no-z-defs = yes
438reldepmod4.so-no-z-defs = yes
439reldep4mod4.so-no-z-defs = yes
440reldep4mod2.so-no-z-defs = yes
441ltglobmod2.so-no-z-defs = yes
442dblloadmod3.so-no-z-defs = yes
443tst-tlsmod1.so-no-z-defs = yes
444tst-tlsmod2.so-no-z-defs = yes
445tst-tlsmod3.so-no-z-defs = yes
446tst-tlsmod4.so-no-z-defs = yes
447tst-tlsmod7.so-no-z-defs = yes
448tst-tlsmod8.so-no-z-defs = yes
449tst-tlsmod9.so-no-z-defs = yes
450tst-tlsmod10.so-no-z-defs = yes
451tst-tlsmod12.so-no-z-defs = yes
99fe3b0e
UD
452tst-tlsmod14a.so-no-z-defs = yes
453tst-tlsmod14b.so-no-z-defs = yes
1a379ea0
UD
454circlemod2.so-no-z-defs = yes
455circlemod3.so-no-z-defs = yes
456circlemod3a.so-no-z-defs = yes
457reldep8mod2.so-no-z-defs = yes
458reldep9mod1.so-no-z-defs = yes
459
10b36b41
AJ
460# filtmod1.so has a special rule
461$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
482eec0d
UD
462 $(build-module)
463
5181d776
RM
464ifeq ($(build-shared),yes)
465# Build all the modules even when not actually running test programs.
466tests: $(test-modules)
467endif
468
aaff4ba9 469$(objpfx)loadtest: $(libdl)
482eec0d
UD
470LDFLAGS-loadtest = -rdynamic
471
472$(objpfx)loadtest.out: $(test-modules)
6bd06384 473
ceb579a3 474$(objpfx)neededtest: $(libdl)
ceb579a3 475$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172 476 $(objpfx)neededobj3.so
ceb579a3 477
9807e540
UD
478$(objpfx)neededtest2: $(libdl)
479$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172
UD
480 $(objpfx)neededobj3.so
481
482$(objpfx)neededtest3: $(libdl)
483$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
484 $(objpfx)neededobj3.so $(objpfx)neededobj4.so
9807e540 485
c77a4478
UD
486neededtest4-ENV = LC_ALL=C LANGUAGE=C
487$(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
488$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
489
aaff4ba9 490$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
e18db2b0 491LDFLAGS-restest1 = -rdynamic
6bd06384 492
2373b30e
UD
493$(objpfx)restest2: $(libdl)
494LDFLAGS-restest2 = -rdynamic
495
6bd06384 496$(objpfx)restest1.out: $(test-modules)
3d91edb2 497
e18db2b0 498preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
10584d2e 499$(objpfx)preloadtest: $(objpfx)testobj6.so
10584d2e 500LDFLAGS-preloadtest = -rdynamic
e18db2b0
UD
501$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
502preloadtest-ENV = \
503 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1e262312 504
aaff4ba9 505$(objpfx)loadfail: $(libdl)
1e262312
UD
506LDFLAGS-loadfail = -rdynamic
507
61e0617a
UD
508$(objpfx)loadfail.out: $(objpfx)failobj.so
509
510$(objpfx)multiload: $(libdl)
511LDFLAGS-multiload = -rdynamic
9df54168 512CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
61e0617a
UD
513
514$(objpfx)multiload.out: $(objpfx)testobj1.so
dc5efe83
UD
515
516$(objpfx)origtest: $(libdl)
394679eb 517LDFLAGS-origtest = -rdynamic
dc5efe83 518$(objpfx)origtest.out: $(objpfx)testobj1.so
ff5fad16
UD
519
520ifeq ($(have-thread-library),yes)
521$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
522else
523$(objpfx)resolvfail: $(libdl)
524endif
19cf43be
UD
525
526$(objpfx)constload1: $(libdl)
527$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
84ddc586 528
6d78cd00
UD
529$(objpfx)circleload1: $(libdl)
530$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
531 $(objpfx)circlemod1a.so
532
533$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
534$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
535$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
536$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
537
84ddc586
UD
538$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
539
540$(objpfx)order.out: $(objpfx)order
541 $(elf-objpfx)$(rtld-installed-name) \
542 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
543 $(objpfx)order > $@
544 (echo "0123456789" | cmp $@ -) > /dev/null
c1025c19
UD
545
546$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
547$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
548vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
5e61ef88
UD
549
550$(objpfx)noload: $(objpfx)testobj1.so
551LDFLAGS-noload = -rdynamic
552$(objpfx)noload.out: $(objpfx)testobj5.so
0fb7851f 553
ad7534c8 554LDFLAGS-nodelete = -rdynamic
0fb7851f 555LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
2cb8cefb 556LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
0fb7851f 557$(objpfx)nodelete: $(libdl)
2cb8cefb
UD
558$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
559 $(objpfx)nodelmod3.so
2f54c82d
UD
560
561LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
562$(objpfx)nodlopen: $(libdl)
563$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
fcacb36a 564
87837aac
UD
565$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
566$(objpfx)nodlopen2: $(libdl)
567$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
568
137bca87
UD
569$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
570 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
571 -L$(subst :, -L,$(rpath-link)) \
572 -Wl,-rpath-link=$(rpath-link) \
573 $< -Wl,-F,$(objpfx)filtmod2.so
fcacb36a 574$(objpfx)filter: $(objpfx)filtmod1.so
2b7238dd
UD
575
576$(objpfx)unload: $(libdl)
577$(objpfx)unload.out: $(objpfx)unloadmod.so
578
579$(objpfx)reldep: $(libdl)
580$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
581
582$(objpfx)reldep2: $(libdl)
583$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
584
585$(objpfx)reldep3: $(libdl)
586$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
917fd061 587
1826d793
UD
588$(objpfx)reldep4: $(libdl)
589$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
590
917fd061 591$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
f6de2239
UD
592
593$(objpfx)unload2: $(libdl)
594$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
d785c366
UD
595
596$(objpfx)lateglobal: $(libdl)
597$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
5a384a91
UD
598
599$(objpfx)tst-pathopt: $(libdl)
600$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
601 $(objpfx)pathoptobj.so
602 $(SHELL) -e $< $(common-objpfx)
b71e7ce8
UD
603
604$(objpfx)initfirst: $(libdl)
605$(objpfx)initfirst.out: $(objpfx)firstobj.so
273a3cfb
UD
606
607$(objpfx)global: $(objpfx)globalmod1.so
608$(objpfx)global.out: $(objpfx)reldepmod1.so
3fac0001
UD
609
610$(objpfx)dblload: $(libdl)
611$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
612
613$(objpfx)dblunload: $(libdl)
614$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
c4bb124a
UD
615
616$(objpfx)reldep5: $(libdl)
617$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod5.so
c47e78b1
UD
618
619$(objpfx)reldep6: $(libdl)
620$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
2e36cb48 621
a41d8a74
UD
622$(objpfx)reldep7: $(libdl)
623$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
624
cfaf5e56
UD
625$(objpfx)reldep8: $(libdl)
626$(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
627
aff4519d
UD
628LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
629$(objpfx)nodelete2: $(libdl)
630$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
631
632$(objpfx)reldep9: $(libdl)
633$(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
634
2e36cb48 635$(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
aed283dd
UD
636
637$(objpfx)tst-tls4: $(libdl)
638$(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
639
640$(objpfx)tst-tls5: $(libdl)
641$(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
bb4cb252
UD
642
643$(objpfx)tst-tls6: $(libdl)
644$(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
fc093be1
UD
645
646$(objpfx)tst-tls7: $(libdl)
647$(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
ebda6173
UD
648
649$(objpfx)tst-tls8: $(libdl)
650$(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
6ef518c3
RM
651
652$(objpfx)tst-tls9: $(libdl)
653$(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
654
94c24227
UD
655$(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so
656
657$(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so
658
659$(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so
660
541765b6
UD
661$(objpfx)tst-tls13: $(libdl)
662$(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
663
99fe3b0e
UD
664$(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl)
665$(objpfx)tst-tls14.out:$(objpfx)tst-tlsmod14b.so
666
06f6ca90
UD
667CFLAGS-tst-align.c = $(stack-align-test-flags)
668CFLAGS-tst-alignmod.c = $(stack-align-test-flags)
669$(objpfx)tst-align: $(libdl)
670$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
671
6ef518c3
RM
672ifdef libdl
673$(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
674$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
675endif
dfe4c900 676
2abf9ff1
RM
677ifeq ($(have-z-execstack),yes)
678$(objpfx)tst-execstack: $(libdl)
679$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
680LDFLAGS-tst-execstack = -Wl,-z,noexecstack
681LDFLAGS-tst-execstack-mod = -Wl,-z,execstack
682
683$(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
684LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
c70ba488
RM
685
686LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
2abf9ff1
RM
687endif
688
dfe4c900
RM
689$(objpfx)tst-array1.out: $(objpfx)tst-array1
690 $(elf-objpfx)$(rtld-installed-name) \
691 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
692 $(objpfx)tst-array1 > $@
693 cmp $@ tst-array1.exp > /dev/null
694
695$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
696$(objpfx)tst-array2.out: $(objpfx)tst-array2
697 $(elf-objpfx)$(rtld-installed-name) \
698 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
699 $(objpfx)tst-array2 > $@
700 cmp $@ tst-array2.exp > /dev/null
701
702$(objpfx)tst-array3.out: $(objpfx)tst-array3
703 $(elf-objpfx)$(rtld-installed-name) \
704 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
705 $(objpfx)tst-array3 > $@
706 cmp $@ tst-array1.exp > /dev/null
efd56f53 707
62f29da7
UD
708$(objpfx)tst-array4: $(libdl)
709$(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
710 $(elf-objpfx)$(rtld-installed-name) \
711 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
712 $< > $@
713 cmp $@ tst-array4.exp > /dev/null
efd56f53 714
f17ed1a9
UD
715ifeq (yesyes,$(have-fpie)$(build-shared))
716CFLAGS-tst-pie1.c += -fpie
717
718$(objpfx)tst-pie1.out: $(objpfx)tst-pie1
719 $(elf-objpfx)$(rtld-installed-name) \
720 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
721 $< > $@
722
723$(objpfx)tst-pie1: $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so
724 $(LINK.o) -pie -Wl,-O1 \
725 $(sysdep-LDFLAGS) $(config-LDFLAGS) \
726 $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
727 $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
728 $(LDFLAGS) $(LDFLAGS-$(@F)) \
729 -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \
730 -o $@ $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so \
731 $(common-objpfx)libc_nonshared.a
732endif
733
e5ffa64a 734check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
efd56f53
UD
735$(objpfx)check-textrel: check-textrel.c
736 $(native-compile)
737
738ifeq (yes,$(build-shared))
739tests: $(objpfx)check-textrel.out
740
741$(objpfx)check-textrel.out: $(objpfx)check-textrel
742 $(dir $<)$(notdir $<) $(common-objpfx)libc.so \
b4c98dc4
UD
743 $(sort $(wildcard $(common-objpfx)*/lib*.so \
744 $(common-objpfx)iconvdata/*.so)) > $@
efd56f53 745generated += check-textrel check-textrel.out
bed12f78
UD
746
747$(objpfx)tst-dlmodcount: $(libdl)
748$(objpfx)tst-dlmodcount.out: $(test-modules)
749
efd56f53 750endif
28977c2c
UD
751
752$(objpfx)tst-dlopenrpathmod.so: $(libdl)
753$(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so $(libdl)
754CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
755LDFLAGS-tst-dlopenrpathmod.so += -Wl,-rpath,\$$ORIGIN/test-subdir
756$(objpfx)tst-dlopenrpath.out: $(objpfx)firstobj.so