]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/Makefile
[BZ #266]
[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 \
83 tst-array2dep.c \
bed12f78 84 tst-execstack-mod.c tst-dlmodcount.c \
ec503662 85 check-textrel.c dl-sysdep.h
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 \
bed12f78 155 $(tests-execstack-$(have-z-execstack)) tst-dlmodcount
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
a25f2023 163modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
2b7238dd 164 testobj1_1 failobj constload2 constload3 unloadmod \
0fb7851f 165 dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
2f54c82d 166 $(modules-nodelete-$(have-z-nodelete)) \
2b7238dd 167 $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
ceb579a3 168 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
1826d793 169 reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
8edd9172 170 neededobj1 neededobj2 neededobj3 neededobj4 \
273a3cfb 171 neededobj5 neededobj6 firstobj globalmod1 \
3fac0001 172 unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
c47e78b1 173 dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
2e36cb48 174 reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
a41d8a74 175 reldep7mod1 reldep7mod2 \
6d78cd00 176 tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4 \
94c24227
UD
177 tst-tlsmod5 tst-tlsmod6 tst-tlsmod7 tst-tlsmod8 \
178 tst-tlsmod9 tst-tlsmod10 tst-tlsmod11 tst-tlsmod12 \
99fe3b0e 179 tst-tlsmod13 tst-tlsmod13a tst-tlsmod14a tst-tlsmod14b \
6d78cd00 180 circlemod1 circlemod1a circlemod2 circlemod2a \
cfaf5e56 181 circlemod3 circlemod3a \
aff4519d 182 reldep8mod1 reldep8mod2 reldep8mod3 \
06f6ca90 183 reldep9mod1 reldep9mod2 reldep9mod3 \
2abf9ff1 184 tst-alignmod $(modules-execstack-$(have-z-execstack))
dfe4c900
RM
185ifeq (yes,$(have-initfini-array))
186modules-names += tst-array2dep
187endif
c1025c19 188modules-vis-yes = vismod1 vismod2 vismod3
aff4519d
UD
189modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
190 nodel2mod1 nodel2mod2 nodel2mod3
87837aac 191modules-nodlopen-yes = nodlopenmod nodlopenmod2
2abf9ff1 192modules-execstack-yes = tst-execstack-mod
9b014809 193extra-objs += $(addsuffix .os,$(strip $(modules-names)))
724d8c3f
RM
194# We need this variable to be sure the test modules get the right CPPFLAGS.
195test-extras += $(modules-names)
dc18d4d8 196
01cc0be6 197include ../Rules
d66e34cd 198
fd54683c
RM
199check-abi: check-abi-ld
200update-abi: update-abi-ld
201
1ef32c3d 202ifeq (yes,$(build-shared))
a89d30d4
RM
203# Make sure these things are built in the `make lib' pass so they can be used
204# to run programs during the `make others' pass.
205lib-noranlib: $(objpfx)$(rtld-installed-name) \
206 $(addprefix $(objpfx),$(extra-objs))
207endif
208
db2286f6 209# Command to link into a larger single relocatable object.
ce460d04 210reloc-link = $(LINK.o) -nostdlib -nostartfiles -r
db2286f6 211
b79f74cd 212$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
ce460d04 213 $(reloc-link) -o $@ $^
db2286f6 214
86d2c878 215# Link together the dynamic linker into a single relocatable object.
ce460d04
RM
216# First we do a link against libc_pic.a just to get a link map,
217# and discard the object produced by that link. From the link map
218# we can glean all the libc modules that need to go into the dynamic
219# linker. Then we do a recursive make that goes into all the subdirs
220# those modules come from and builds special rtld-foo.os versions that
221# are compiled with special flags, and puts these modules into rtld-libc.a
222# for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
223
224$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
240e87c2
RM
225 @-rm -f $@T
226 $(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
ce460d04 227 rm -f $@.o
240e87c2 228 mv -f $@T $@
ce460d04
RM
229
230$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
b61c8aba 231 LC_ALL=C \
6461e577
RM
232 sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
233 $< | \
ce460d04
RM
234 while read lib file; do \
235 case $$lib in \
236 libc_pic.a) \
b61c8aba 237 LC_ALL=C fgrep -l /$$file \
ce460d04 238 $(common-objpfx)stamp.os $(common-objpfx)*/stamp.os | \
b61c8aba 239 LC_ALL=C \
ce460d04
RM
240 sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
241 ;; \
242 */*.a) \
243 echo rtld-$${lib%%/*} += $$file ;; \
244 *) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
245 esac; \
246 done > $@T
b61c8aba
UD
247 echo rtld-subdirs = `LC_ALL=C sed 's/^rtld-\([^ ]*\).*$$/\1/' $@T \
248 | LC_ALL=C sort -u` >> $@T
ce460d04
RM
249 mv -f $@T $@
250
251$(objpfx)rtld-libc.a: $(objpfx)librtld.mk FORCE
252 $(MAKE) -f $< -f rtld-Rules
253
ce460d04 254$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(objpfx)rtld-libc.a
5896ffa8
UD
255 $(LINK.o) -nostdlib -nostartfiles -r -o $@ '-Wl,-(' $^ -lgcc '-Wl,-)' \
256 -Wl,-Map,$@.map
257
258generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
d66e34cd 259
4df8c11d
UD
260z-now-yes = -Wl,-z,now
261
32e6df36 262$(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
070cadeb 263 @rm -f $@.lds
4df8c11d 264 $(LINK.o) -nostdlib -nostartfiles -shared $(z-now-$(bind-now)) \
9ae10332 265 $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \
b61c8aba 266 LC_ALL=C \
32e6df36
UD
267 sed -e '/^=========/,/^=========/!d;/^=========/d' \
268 -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
070cadeb 269 > $@.lds
9ae10332 270 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
4df8c11d 271 $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \
32e6df36 272 $(filter-out $(map-file),$^) $(load-map-file) \
070cadeb 273 -Wl,-soname=$(rtld-installed-name) -T $@.lds
32e6df36 274 rm -f $@.lds
266180eb 275
c7562c74 276# interp.c exists just to get this string into the libraries.
b30542fb
UD
277CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \
278 -DNOT_IN_libc=1
656f8223 279$(objpfx)interp.os: $(common-objpfx)config.make
c7562c74 280
1ef32c3d 281ifneq (ld.so,$(rtld-installed-name))
afd4eb37 282# Make sure ld.so.1 exists in the build directory so we can link
852fc4b9
RM
283# against it.
284$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
285 rm -f $@
f332db02 286 ln -s $(<F) $@
da2d1bc5 287generated += $(rtld-installed-name)
852fc4b9
RM
288endif
289
fd26970f
UD
290# Build a file mentioning all trustworthy directories to look for shared
291# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
292# add directories to the list by defining $(user-defined-trusted-dirs)
293# before starting make.
6598ac30
UD
294$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
295$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1ef32c3d 296 $(make-target-directory)
ab7eb292
UD
297 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
298 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
ce460d04 299 echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T}
6598ac30
UD
300 $(move-if-change) ${@:st=T} ${@:st=h}
301 touch $@
a986484f 302CPPFLAGS-dl-load.c = -I$(objpfx). -I$(csu-objpfx).
86d2c878 303
9f2a9248 304ifeq (yes,$(build-shared))
73237de3 305$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
460adbb8 306 $(make-target-directory)
925e31d9 307 $(do-install-program)
1ef32c3d 308
8d57beea 309$(inst_slibdir)/$(rtld-installed-name): \
460adbb8
UD
310 $(inst_slibdir)/$(rtld-version-installed-name) \
311 $(inst_slibdir)/libc-$(version).so
925e31d9 312 $(make-shlib-link)
b122c703 313
5148d49f
UD
314# Special target called by parent to install just the dynamic linker.
315.PHONY: ldso_install
316ldso_install: $(inst_slibdir)/$(rtld-installed-name)
9f2a9248 317endif
5148d49f 318
cb343854 319
926e512f
RM
320common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
321 -e 's%@VERSION@%$(version)%g'
1ddf537f 322sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
926e512f 323bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
4a33c2f5 324 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
cb343854 325
84384f5b 326ifneq ($(have-bash2),yes)
cb343854 327ldd-shell = sh
e2102c14
UD
328else
329ldd-shell = bash
cb343854
UD
330endif
331
332ifeq ($(ldd-rewrite-script),no)
333define gen-ldd
b61c8aba 334LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
cb343854 335endef
84384f5b 336else
cb343854 337define gen-ldd
b61c8aba 338LC_ALL=C sed $($(ldd-shell)-ldd-rewrite) < $< | LC_ALL=C sed -f $(ldd-rewrite-script) > $@.new
cb343854
UD
339endef
340endif
341
926e512f 342$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
ee74a442 343 $(common-objpfx)config.make
cb343854 344 $(gen-ldd)
84384f5b
UD
345 chmod 555 $@.new
346 mv -f $@.new $@
cb343854 347
aaff4ba9 348$(objpfx)sprof: $(libdl)
94e365c6 349
591e1ffb 350$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
8ca91b36 351SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
1a379ea0 352CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
11bf8ce1 353 -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
8ca91b36
UD
354CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
355CFLAGS-cache.c = $(SYSCONF-FLAGS)
591e1ffb 356
ce460d04 357CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
0d01dace 358
9b014809
UD
359test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
360generated += $(addsuffix .so,$(strip $(modules-names)))
482eec0d 361
e1e3ba54 362ifeq (yes,$(build-shared))
8c0fe290 363ifeq ($(cross-compiling),no)
5a384a91 364tests: $(objpfx)tst-pathopt.out
e1e3ba54 365endif
8c0fe290 366endif
5a384a91 367
aaff4ba9
UD
368$(objpfx)testobj1.so: $(libdl)
369$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
370$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
371$(objpfx)testobj3.so: $(libdl)
372$(objpfx)testobj4.so: $(libdl)
373$(objpfx)testobj5.so: $(libdl)
e30f2b98 374$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
e18db2b0 375$(objpfx)failobj.so: $(objpfx)testobj6.so
84ddc586
UD
376$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
377$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
378$(objpfx)dep4.so: $(objpfx)dep3.so
2cb8cefb 379$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
917fd061 380$(objpfx)nextmod1.so: $(libdl)
ceb579a3
UD
381$(objpfx)neededobj1.so: $(libdl)
382$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
383$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
8edd9172
UD
384$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
385 $(objpfx)neededobj3.so $(libdl)
c77a4478 386$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
f6de2239 387$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
d785c366 388$(objpfx)ltglobmod2.so: $(libdl)
b71e7ce8 389$(objpfx)firstobj.so: $(shared-thread-library)
273a3cfb 390$(objpfx)globalmod1.so: $(libdl)
1826d793
UD
391$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
392$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
3fac0001
UD
393$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
394$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
c4bb124a
UD
395$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
396$(objpfx)reldepmod6.so: $(objpfx)reldepmod2.so
c47e78b1
UD
397$(objpfx)reldep6mod1.so: $(objpfx)reldep6mod0.so
398$(objpfx)reldep6mod2.so: $(objpfx)reldep6mod1.so
399$(objpfx)reldep6mod3.so: $(objpfx)reldep6mod2.so
400$(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
fc093be1 401$(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
94c24227
UD
402$(objpfx)tst-tlsmod8.so: $(objpfx)tst-tlsmod7.so
403$(objpfx)tst-tlsmod10.so: $(objpfx)tst-tlsmod9.so
404$(objpfx)tst-tlsmod12.so: $(objpfx)tst-tlsmod11.so
541765b6 405$(objpfx)tst-tlsmod13a.so: $(objpfx)tst-tlsmod13.so
aff4519d
UD
406# For tst-tls9-static, make sure the modules it dlopens have libc.so in DT_NEEDED
407$(objpfx)tst-tlsmod5.so: $(common-objpfx)libc.so
408$(objpfx)tst-tlsmod6.so: $(common-objpfx)libc.so
556224ab 409$(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
aff4519d
UD
410$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
411$(objpfx)reldep9mod2.so: $(objpfx)reldep9mod1.so
412$(objpfx)reldep9mod3.so: $(objpfx)reldep9mod1.so $(objpfx)reldep9mod2.so
ceb579a3 413
6ef518c3
RM
414LDFLAGS-tst-tlsmod5.so = -nostdlib
415LDFLAGS-tst-tlsmod6.so = -nostdlib
416
1a379ea0
UD
417testobj1.so-no-z-defs = yes
418testobj3.so-no-z-defs = yes
419testobj4.so-no-z-defs = yes
420testobj5.so-no-z-defs = yes
421testobj6.so-no-z-defs = yes
422failobj.so-no-z-defs = yes
423constload2.so-no-z-defs = yes
424constload3.so-no-z-defs = yes
425nodelmod1.so-no-z-defs = yes
426nodelmod2.so-no-z-defs = yes
427nodelmod4.so-no-z-defs = yes
428nodel2mod2.so-no-z-defs = yes
429reldepmod2.so-no-z-defs = yes
430reldepmod3.so-no-z-defs = yes
431reldepmod4.so-no-z-defs = yes
432reldep4mod4.so-no-z-defs = yes
433reldep4mod2.so-no-z-defs = yes
434ltglobmod2.so-no-z-defs = yes
435dblloadmod3.so-no-z-defs = yes
436tst-tlsmod1.so-no-z-defs = yes
437tst-tlsmod2.so-no-z-defs = yes
438tst-tlsmod3.so-no-z-defs = yes
439tst-tlsmod4.so-no-z-defs = yes
440tst-tlsmod7.so-no-z-defs = yes
441tst-tlsmod8.so-no-z-defs = yes
442tst-tlsmod9.so-no-z-defs = yes
443tst-tlsmod10.so-no-z-defs = yes
444tst-tlsmod12.so-no-z-defs = yes
99fe3b0e
UD
445tst-tlsmod14a.so-no-z-defs = yes
446tst-tlsmod14b.so-no-z-defs = yes
1a379ea0
UD
447circlemod2.so-no-z-defs = yes
448circlemod3.so-no-z-defs = yes
449circlemod3a.so-no-z-defs = yes
450reldep8mod2.so-no-z-defs = yes
451reldep9mod1.so-no-z-defs = yes
452
10b36b41
AJ
453# filtmod1.so has a special rule
454$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
482eec0d
UD
455 $(build-module)
456
5181d776
RM
457ifeq ($(build-shared),yes)
458# Build all the modules even when not actually running test programs.
459tests: $(test-modules)
460endif
461
aaff4ba9 462$(objpfx)loadtest: $(libdl)
482eec0d
UD
463LDFLAGS-loadtest = -rdynamic
464
465$(objpfx)loadtest.out: $(test-modules)
6bd06384 466
ceb579a3 467$(objpfx)neededtest: $(libdl)
ceb579a3 468$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172 469 $(objpfx)neededobj3.so
ceb579a3 470
9807e540
UD
471$(objpfx)neededtest2: $(libdl)
472$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172
UD
473 $(objpfx)neededobj3.so
474
475$(objpfx)neededtest3: $(libdl)
476$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
477 $(objpfx)neededobj3.so $(objpfx)neededobj4.so
9807e540 478
c77a4478
UD
479neededtest4-ENV = LC_ALL=C LANGUAGE=C
480$(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
481$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
482
aaff4ba9 483$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
e18db2b0 484LDFLAGS-restest1 = -rdynamic
6bd06384 485
2373b30e
UD
486$(objpfx)restest2: $(libdl)
487LDFLAGS-restest2 = -rdynamic
488
6bd06384 489$(objpfx)restest1.out: $(test-modules)
3d91edb2 490
e18db2b0 491preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
10584d2e 492$(objpfx)preloadtest: $(objpfx)testobj6.so
10584d2e 493LDFLAGS-preloadtest = -rdynamic
e18db2b0
UD
494$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
495preloadtest-ENV = \
496 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1e262312 497
aaff4ba9 498$(objpfx)loadfail: $(libdl)
1e262312
UD
499LDFLAGS-loadfail = -rdynamic
500
61e0617a
UD
501$(objpfx)loadfail.out: $(objpfx)failobj.so
502
503$(objpfx)multiload: $(libdl)
504LDFLAGS-multiload = -rdynamic
9df54168 505CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
61e0617a
UD
506
507$(objpfx)multiload.out: $(objpfx)testobj1.so
dc5efe83
UD
508
509$(objpfx)origtest: $(libdl)
394679eb 510LDFLAGS-origtest = -rdynamic
dc5efe83 511$(objpfx)origtest.out: $(objpfx)testobj1.so
ff5fad16
UD
512
513ifeq ($(have-thread-library),yes)
514$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
515else
516$(objpfx)resolvfail: $(libdl)
517endif
19cf43be
UD
518
519$(objpfx)constload1: $(libdl)
520$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
84ddc586 521
6d78cd00
UD
522$(objpfx)circleload1: $(libdl)
523$(objpfx)circleload1.out: $(objpfx)circlemod1.so \
524 $(objpfx)circlemod1a.so
525
526$(objpfx)circlemod1.so: $(objpfx)circlemod2.so
527$(objpfx)circlemod2.so: $(objpfx)circlemod3.so
528$(objpfx)circlemod1a.so: $(objpfx)circlemod2a.so
529$(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
530
84ddc586
UD
531$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
532
533$(objpfx)order.out: $(objpfx)order
534 $(elf-objpfx)$(rtld-installed-name) \
535 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
536 $(objpfx)order > $@
537 (echo "0123456789" | cmp $@ -) > /dev/null
c1025c19
UD
538
539$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
540$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
541vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
5e61ef88
UD
542
543$(objpfx)noload: $(objpfx)testobj1.so
544LDFLAGS-noload = -rdynamic
545$(objpfx)noload.out: $(objpfx)testobj5.so
0fb7851f 546
ad7534c8 547LDFLAGS-nodelete = -rdynamic
0fb7851f 548LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
2cb8cefb 549LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
0fb7851f 550$(objpfx)nodelete: $(libdl)
2cb8cefb
UD
551$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
552 $(objpfx)nodelmod3.so
2f54c82d
UD
553
554LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
555$(objpfx)nodlopen: $(libdl)
556$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
fcacb36a 557
87837aac
UD
558$(objpfx)nodlopenmod2.so: $(objpfx)nodlopenmod.so
559$(objpfx)nodlopen2: $(libdl)
560$(objpfx)nodlopen2.out: $(objpfx)nodlopenmod2.so
561
137bca87
UD
562$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
563 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
564 -L$(subst :, -L,$(rpath-link)) \
565 -Wl,-rpath-link=$(rpath-link) \
566 $< -Wl,-F,$(objpfx)filtmod2.so
fcacb36a 567$(objpfx)filter: $(objpfx)filtmod1.so
2b7238dd
UD
568
569$(objpfx)unload: $(libdl)
570$(objpfx)unload.out: $(objpfx)unloadmod.so
571
572$(objpfx)reldep: $(libdl)
573$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
574
575$(objpfx)reldep2: $(libdl)
576$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
577
578$(objpfx)reldep3: $(libdl)
579$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
917fd061 580
1826d793
UD
581$(objpfx)reldep4: $(libdl)
582$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
583
917fd061 584$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
f6de2239
UD
585
586$(objpfx)unload2: $(libdl)
587$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
d785c366
UD
588
589$(objpfx)lateglobal: $(libdl)
590$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
5a384a91
UD
591
592$(objpfx)tst-pathopt: $(libdl)
593$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
594 $(objpfx)pathoptobj.so
595 $(SHELL) -e $< $(common-objpfx)
b71e7ce8
UD
596
597$(objpfx)initfirst: $(libdl)
598$(objpfx)initfirst.out: $(objpfx)firstobj.so
273a3cfb
UD
599
600$(objpfx)global: $(objpfx)globalmod1.so
601$(objpfx)global.out: $(objpfx)reldepmod1.so
3fac0001
UD
602
603$(objpfx)dblload: $(libdl)
604$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
605
606$(objpfx)dblunload: $(libdl)
607$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
c4bb124a
UD
608
609$(objpfx)reldep5: $(libdl)
610$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod5.so
c47e78b1
UD
611
612$(objpfx)reldep6: $(libdl)
613$(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
2e36cb48 614
a41d8a74
UD
615$(objpfx)reldep7: $(libdl)
616$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
617
cfaf5e56
UD
618$(objpfx)reldep8: $(libdl)
619$(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
620
aff4519d
UD
621LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
622$(objpfx)nodelete2: $(libdl)
623$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
624
625$(objpfx)reldep9: $(libdl)
626$(objpfx)reldep9.out: $(objpfx)reldep9mod3.so
627
2e36cb48 628$(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
aed283dd
UD
629
630$(objpfx)tst-tls4: $(libdl)
631$(objpfx)tst-tls4.out: $(objpfx)tst-tlsmod2.so
632
633$(objpfx)tst-tls5: $(libdl)
634$(objpfx)tst-tls5.out: $(objpfx)tst-tlsmod2.so
bb4cb252
UD
635
636$(objpfx)tst-tls6: $(libdl)
637$(objpfx)tst-tls6.out: $(objpfx)tst-tlsmod2.so
fc093be1
UD
638
639$(objpfx)tst-tls7: $(libdl)
640$(objpfx)tst-tls7.out: $(objpfx)tst-tlsmod3.so
ebda6173
UD
641
642$(objpfx)tst-tls8: $(libdl)
643$(objpfx)tst-tls8.out: $(objpfx)tst-tlsmod3.so $(objpfx)tst-tlsmod4.so
6ef518c3
RM
644
645$(objpfx)tst-tls9: $(libdl)
646$(objpfx)tst-tls9.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
647
94c24227
UD
648$(objpfx)tst-tls10: $(objpfx)tst-tlsmod8.so
649
650$(objpfx)tst-tls11: $(objpfx)tst-tlsmod10.so
651
652$(objpfx)tst-tls12: $(objpfx)tst-tlsmod12.so
653
541765b6
UD
654$(objpfx)tst-tls13: $(libdl)
655$(objpfx)tst-tls13.out: $(objpfx)tst-tlsmod13a.so
656
99fe3b0e
UD
657$(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl)
658$(objpfx)tst-tls14.out:$(objpfx)tst-tlsmod14b.so
659
06f6ca90
UD
660CFLAGS-tst-align.c = $(stack-align-test-flags)
661CFLAGS-tst-alignmod.c = $(stack-align-test-flags)
662$(objpfx)tst-align: $(libdl)
663$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so
664
6ef518c3
RM
665ifdef libdl
666$(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
667$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
668endif
dfe4c900 669
2abf9ff1
RM
670ifeq ($(have-z-execstack),yes)
671$(objpfx)tst-execstack: $(libdl)
672$(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
673LDFLAGS-tst-execstack = -Wl,-z,noexecstack
674LDFLAGS-tst-execstack-mod = -Wl,-z,execstack
675
676$(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so
677LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack
c70ba488
RM
678
679LDFLAGS-tst-execstack-prog = -Wl,-z,execstack
2abf9ff1
RM
680endif
681
dfe4c900
RM
682$(objpfx)tst-array1.out: $(objpfx)tst-array1
683 $(elf-objpfx)$(rtld-installed-name) \
684 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
685 $(objpfx)tst-array1 > $@
686 cmp $@ tst-array1.exp > /dev/null
687
688$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
689$(objpfx)tst-array2.out: $(objpfx)tst-array2
690 $(elf-objpfx)$(rtld-installed-name) \
691 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
692 $(objpfx)tst-array2 > $@
693 cmp $@ tst-array2.exp > /dev/null
694
695$(objpfx)tst-array3.out: $(objpfx)tst-array3
696 $(elf-objpfx)$(rtld-installed-name) \
697 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
698 $(objpfx)tst-array3 > $@
699 cmp $@ tst-array1.exp > /dev/null
efd56f53 700
62f29da7
UD
701$(objpfx)tst-array4: $(libdl)
702$(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
703 $(elf-objpfx)$(rtld-installed-name) \
704 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
705 $< > $@
706 cmp $@ tst-array4.exp > /dev/null
efd56f53 707
e5ffa64a 708check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
efd56f53
UD
709$(objpfx)check-textrel: check-textrel.c
710 $(native-compile)
711
712ifeq (yes,$(build-shared))
713tests: $(objpfx)check-textrel.out
714
715$(objpfx)check-textrel.out: $(objpfx)check-textrel
716 $(dir $<)$(notdir $<) $(common-objpfx)libc.so \
b4c98dc4
UD
717 $(sort $(wildcard $(common-objpfx)*/lib*.so \
718 $(common-objpfx)iconvdata/*.so)) > $@
efd56f53 719generated += check-textrel check-textrel.out
bed12f78
UD
720
721$(objpfx)tst-dlmodcount: $(libdl)
722$(objpfx)tst-dlmodcount.out: $(test-modules)
723
efd56f53 724endif