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