]> sourceware.org Git - glibc.git/blame - elf/Makefile
Update.
[glibc.git] / elf / Makefile
CommitLineData
b71e7ce8 1# Copyright (C) 1995-1999, 2000, 2001 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
5# modify it under the terms of the GNU Library General Public License as
6# published by the Free Software Foundation; either version 2 of the
7# License, or (at your option) any later version.
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Library General Public License for more details.
13
14# You should have received a copy of the GNU Library General Public
afd4eb37
UD
15# License along with the GNU C Library; see the file COPYING.LIB. If not,
16# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17# Boston, MA 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
cddcfecf 24routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
94e365c6 25 dl-addr enbl-secure dl-profstub dl-origin dl-libc dl-sym
266180eb
RM
26
27# The core dynamic linking functions are in libc for the static and
28# profiled libraries.
f18edac3 29dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
3996f34b 30 runtime error init fini debug misc \
d7926ed9 31 version profile)
b79f74cd 32all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
266180eb 33# But they are absent from the shared libc, because that code is in ld.so.
b79f74cd 34elide-routines.os = $(all-dl-routines) dl-support enbl-secure
266180eb
RM
35
36# ld.so uses those routines, plus some special stuff for being the program
37# interpreter and operating independent of libc.
e27b79d3 38rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
e39e6956 39all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
b79f74cd 40
94e365c6 41distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
b3ed8219 42 dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
94e365c6
UD
43 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
44 dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
c77ec56d 45 do-lookup.h dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
94e365c6 46 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
2b7238dd 47 testobj6.c testobj1_1.c failobj.c unloadmod.c \
84ddc586 48 ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
e340a2a2 49 chroot_canon.c gccframe.h \
74955460 50 dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h unsecvars.h \
afa0569f 51 vismain.c vismod1.c vismod2.c vismod3.c \
74dd1fee
UD
52 constload2.c constload3.c filtmod1.c filtmod2.c \
53 nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
2b7238dd 54 nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
917fd061 55 reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
8bc6161d 56 nextmod1.c nextmod2.c pathoptobj.c tst-pathopt.sh \
5ab7f7c1 57 neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
c77a4478 58 neededobj5.c neededobj6.c \
1a511d31 59 unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
715ed1e9 60 testobj.h vismod.h
d66e34cd 61
05f732b3
UD
62include ../Makeconfig
63
40c4c9b5 64before-compile = $(objpfx)trusted-dirs.h
5a384a91
UD
65generated := trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
66generated-dirs := for-renamed
fd26970f 67
bdd421cc 68ifeq ($(versioning),yes)
a0edd63e 69ld-map = $(common-objpfx)ld.map
bdd421cc
UD
70endif
71
d66e34cd 72ifeq (yes,$(build-shared))
b79f74cd 73extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
40c4c9b5 74generated += librtld.os dl-allobjs.os ld.so ldd
8d57beea 75install-others = $(inst_slibdir)/$(rtld-installed-name)
b122c703 76install-bin = ldd
f49bc43f 77endif
86d2c878 78
9d141cae 79others = sprof sln
ea278354 80install-bin += sprof
9d141cae
UD
81others-static = sln
82install-rootsbin = sln
ae828bc6 83
591e1ffb 84ifeq (yes,$(use-ldconfig))
99ac5e47 85ifeq (yes,$(build-shared))
e1586792 86others-static += ldconfig
da2d1bc5 87others += ldconfig
9d141cae 88install-rootsbin += ldconfig
591e1ffb 89
b4a555d6 90ldconfig-modules := cache readlib xmalloc xstrdup chroot_canon
591e1ffb
UD
91extra-objs += $(ldconfig-modules:=.o)
92
93# To find xmalloc.c and xstrdup.c
94vpath %.c ../locale/programs
95
99ac5e47 96endif
1ef32c3d
UD
97endif
98
2f512715 99ifeq (yes,$(build-shared))
19cf43be 100tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
2b7238dd 101 constload1 order $(tests-vis-$(have-protected)) noload filter unload \
917fd061 102 reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \
9807e540 103 $(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
b71e7ce8 104 neededtest3 neededtest4 unload2 lateglobal initfirst
5a384a91 105test-srcs = tst-pathopt
c1025c19 106tests-vis-yes = vismain
0fb7851f 107tests-nodelete-yes = nodelete
2f54c82d 108tests-nodlopen-yes = nodlopen
2f512715 109endif
a25f2023 110modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
2b7238dd 111 testobj1_1 failobj constload2 constload3 unloadmod \
0fb7851f 112 dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
2f54c82d 113 $(modules-nodelete-$(have-z-nodelete)) \
2b7238dd 114 $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
ceb579a3 115 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
8edd9172 116 neededobj1 neededobj2 neededobj3 neededobj4 \
b71e7ce8 117 neededobj5 neededobj6 firstobj \
5a384a91 118 unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj
c1025c19 119modules-vis-yes = vismod1 vismod2 vismod3
2cb8cefb 120modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
2f54c82d 121modules-nodlopen-yes = nodlopenmod
9b014809 122extra-objs += $(addsuffix .os,$(strip $(modules-names)))
482eec0d 123
01cc0be6 124include ../Rules
d66e34cd 125
1ef32c3d 126ifeq (yes,$(build-shared))
a89d30d4
RM
127# Make sure these things are built in the `make lib' pass so they can be used
128# to run programs during the `make others' pass.
129lib-noranlib: $(objpfx)$(rtld-installed-name) \
130 $(addprefix $(objpfx),$(extra-objs))
131endif
132
db2286f6
RM
133# Command to link into a larger single relocatable object.
134reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
135
b79f74cd 136$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
db2286f6
RM
137 $(reloc-link) $^
138
86d2c878 139# Link together the dynamic linker into a single relocatable object.
40a55d20 140$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
db2286f6 141 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
d66e34cd 142
f21acc89
UD
143# Do we need a linker script?
144rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
14ea22e9 145
f21acc89 146ifneq (,$(rtld-ldscript-in))
880f421f
UD
147rtld-ldscript = $(objpfx)rtld-ldscript
148generated += rtld-ldscript
149
150LDFLAGS-rtld = -T $(rtld-ldscript)
151before-compile += $(rtld-ldscript)
f21acc89 152
f21acc89
UD
153rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
154include $(rtld-parms)
880f421f
UD
155
156$(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
f21acc89
UD
157 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
158 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
159 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
160 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
880f421f 161endif
f21acc89 162
2f444823 163$(objpfx)ld.so: $(objpfx)librtld.os $(rtld-ldscript) $(ld-map)
7ef90c15
UD
164 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld) \
165 $(filter-out $(rtld-ldscript) $(map-file),$^) \
166 $(load-map-file) -Wl,-soname=$(rtld-installed-name)
266180eb 167
c7562c74
UD
168# interp.c exists just to get this string into the libraries.
169CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
170
1ef32c3d 171ifneq (ld.so,$(rtld-installed-name))
afd4eb37 172# Make sure ld.so.1 exists in the build directory so we can link
852fc4b9
RM
173# against it.
174$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
175 rm -f $@
f332db02 176 ln -s $(<F) $@
da2d1bc5 177generated += $(rtld-installed-name)
852fc4b9
RM
178endif
179
fd26970f
UD
180# Build a file mentioning all trustworthy directories to look for shared
181# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
182# add directories to the list by defining $(user-defined-trusted-dirs)
183# before starting make.
6598ac30
UD
184$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
185$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1ef32c3d 186 $(make-target-directory)
ab7eb292
UD
187 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
188 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
6598ac30
UD
189 $(move-if-change) ${@:st=T} ${@:st=h}
190 touch $@
9afc8a59 191CPPFLAGS-dl-load.c = -I$(objpfx).
86d2c878 192
9f2a9248 193ifeq (yes,$(build-shared))
73237de3 194$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
460adbb8 195 $(make-target-directory)
925e31d9 196 $(do-install-program)
1ef32c3d 197
8d57beea 198$(inst_slibdir)/$(rtld-installed-name): \
460adbb8
UD
199 $(inst_slibdir)/$(rtld-version-installed-name) \
200 $(inst_slibdir)/libc-$(version).so
925e31d9 201 $(make-shlib-link)
b122c703 202
5148d49f
UD
203# Special target called by parent to install just the dynamic linker.
204.PHONY: ldso_install
205ldso_install: $(inst_slibdir)/$(rtld-installed-name)
9f2a9248 206endif
5148d49f 207
cb343854 208
926e512f
RM
209common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
210 -e 's%@VERSION@%$(version)%g'
1ddf537f 211sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
926e512f 212bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
4a33c2f5 213 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
cb343854 214
84384f5b 215ifneq ($(have-bash2),yes)
cb343854 216ldd-shell = sh
e2102c14
UD
217else
218ldd-shell = bash
cb343854
UD
219endif
220
221ifeq ($(ldd-rewrite-script),no)
222define gen-ldd
223sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
224endef
84384f5b 225else
cb343854
UD
226define gen-ldd
227sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
228endef
229endif
230
926e512f 231$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
ee74a442 232 $(common-objpfx)config.make
cb343854 233 $(gen-ldd)
84384f5b
UD
234 chmod 555 $@.new
235 mv -f $@.new $@
cb343854 236
aaff4ba9 237$(objpfx)sprof: $(libdl)
94e365c6 238
591e1ffb 239$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
8ca91b36
UD
240SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
241CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' -D'SLIBDIR="$(slibdir)"'
242CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
243CFLAGS-cache.c = $(SYSCONF-FLAGS)
591e1ffb 244
9b014809
UD
245test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
246generated += $(addsuffix .so,$(strip $(modules-names)))
482eec0d 247
5a384a91
UD
248tests: $(objpfx)tst-pathopt.out
249
aaff4ba9
UD
250$(objpfx)testobj1.so: $(libdl)
251$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
252$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
253$(objpfx)testobj3.so: $(libdl)
254$(objpfx)testobj4.so: $(libdl)
255$(objpfx)testobj5.so: $(libdl)
e30f2b98 256$(objpfx)testobj6.so: $(objpfx)testobj1.so $(objpfx)testobj2.so $(libdl)
e18db2b0 257$(objpfx)failobj.so: $(objpfx)testobj6.so
84ddc586
UD
258$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
259$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
260$(objpfx)dep4.so: $(objpfx)dep3.so
2cb8cefb 261$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
917fd061 262$(objpfx)nextmod1.so: $(libdl)
ceb579a3
UD
263$(objpfx)neededobj1.so: $(libdl)
264$(objpfx)neededobj2.so: $(objpfx)neededobj1.so $(libdl)
265$(objpfx)neededobj3.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so $(libdl)
8edd9172
UD
266$(objpfx)neededobj4.so: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
267 $(objpfx)neededobj3.so $(libdl)
c77a4478 268$(objpfx)neededobj6.so: $(objpfx)neededobj5.so
f6de2239 269$(objpfx)unload2mod.so: $(objpfx)unload2dep.so
d785c366 270$(objpfx)ltglobmod2.so: $(libdl)
b71e7ce8 271$(objpfx)firstobj.so: $(shared-thread-library)
ceb579a3 272
10b36b41
AJ
273# filtmod1.so has a special rule
274$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
482eec0d
UD
275 $(build-module)
276
aaff4ba9 277$(objpfx)loadtest: $(libdl)
482eec0d
UD
278LDFLAGS-loadtest = -rdynamic
279
280$(objpfx)loadtest.out: $(test-modules)
6bd06384 281
ceb579a3 282$(objpfx)neededtest: $(libdl)
ceb579a3 283$(objpfx)neededtest.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172 284 $(objpfx)neededobj3.so
ceb579a3 285
9807e540
UD
286$(objpfx)neededtest2: $(libdl)
287$(objpfx)neededtest2.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
8edd9172
UD
288 $(objpfx)neededobj3.so
289
290$(objpfx)neededtest3: $(libdl)
291$(objpfx)neededtest3.out: $(objpfx)neededobj1.so $(objpfx)neededobj2.so \
292 $(objpfx)neededobj3.so $(objpfx)neededobj4.so
9807e540 293
c77a4478
UD
294neededtest4-ENV = LC_ALL=C LANGUAGE=C
295$(objpfx)neededtest4: $(libdl) $(objpfx)neededobj1.so
296$(objpfx)neededtest4.out: $(objpfx)neededobj5.so $(objpfx)neededobj6.so
297
aaff4ba9 298$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
e18db2b0 299LDFLAGS-restest1 = -rdynamic
6bd06384
UD
300
301$(objpfx)restest1.out: $(test-modules)
3d91edb2 302
e18db2b0 303preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
10584d2e 304$(objpfx)preloadtest: $(objpfx)testobj6.so
10584d2e 305LDFLAGS-preloadtest = -rdynamic
e18db2b0
UD
306$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
307preloadtest-ENV = \
308 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1e262312 309
aaff4ba9 310$(objpfx)loadfail: $(libdl)
1e262312
UD
311LDFLAGS-loadfail = -rdynamic
312
61e0617a
UD
313$(objpfx)loadfail.out: $(objpfx)failobj.so
314
315$(objpfx)multiload: $(libdl)
316LDFLAGS-multiload = -rdynamic
9df54168 317CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
61e0617a
UD
318
319$(objpfx)multiload.out: $(objpfx)testobj1.so
dc5efe83
UD
320
321$(objpfx)origtest: $(libdl)
394679eb 322LDFLAGS-origtest = -rdynamic
dc5efe83 323$(objpfx)origtest.out: $(objpfx)testobj1.so
ff5fad16
UD
324
325ifeq ($(have-thread-library),yes)
326$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
327else
328$(objpfx)resolvfail: $(libdl)
329endif
19cf43be
UD
330
331$(objpfx)constload1: $(libdl)
332$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
84ddc586
UD
333
334$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
335
336$(objpfx)order.out: $(objpfx)order
337 $(elf-objpfx)$(rtld-installed-name) \
338 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
339 $(objpfx)order > $@
340 (echo "0123456789" | cmp $@ -) > /dev/null
c1025c19
UD
341
342$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
343$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
344vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
5e61ef88
UD
345
346$(objpfx)noload: $(objpfx)testobj1.so
347LDFLAGS-noload = -rdynamic
348$(objpfx)noload.out: $(objpfx)testobj5.so
0fb7851f 349
ad7534c8 350LDFLAGS-nodelete = -rdynamic
0fb7851f 351LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
2cb8cefb 352LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
0fb7851f 353$(objpfx)nodelete: $(libdl)
2cb8cefb
UD
354$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
355 $(objpfx)nodelmod3.so
2f54c82d
UD
356
357LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
358$(objpfx)nodlopen: $(libdl)
359$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
fcacb36a 360
137bca87
UD
361$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
362 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
363 -L$(subst :, -L,$(rpath-link)) \
364 -Wl,-rpath-link=$(rpath-link) \
365 $< -Wl,-F,$(objpfx)filtmod2.so
fcacb36a 366$(objpfx)filter: $(objpfx)filtmod1.so
2b7238dd
UD
367
368$(objpfx)unload: $(libdl)
369$(objpfx)unload.out: $(objpfx)unloadmod.so
370
371$(objpfx)reldep: $(libdl)
372$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
373
374$(objpfx)reldep2: $(libdl)
375$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
376
377$(objpfx)reldep3: $(libdl)
378$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
917fd061
UD
379
380$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
f6de2239
UD
381
382$(objpfx)unload2: $(libdl)
383$(objpfx)unload2.out: $(objpfx)unload2mod.so $(objpfx)unload2dep.so
d785c366
UD
384
385$(objpfx)lateglobal: $(libdl)
386$(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
5a384a91
UD
387
388$(objpfx)tst-pathopt: $(libdl)
389$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
390 $(objpfx)pathoptobj.so
391 $(SHELL) -e $< $(common-objpfx)
b71e7ce8
UD
392
393$(objpfx)initfirst: $(libdl)
394$(objpfx)initfirst.out: $(objpfx)firstobj.so
This page took 0.187232 seconds and 5 git commands to generate.