]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/Makefile
Update.
[thirdparty/glibc.git] / elf / Makefile
CommitLineData
19cf43be 1# Copyright (C) 1995-1999, 2000 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 \
afa0569f
UD
49 dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h \
50 vismain.c vismod1.c vismod2.c vismod3.c \
74dd1fee
UD
51 constload2.c constload3.c filtmod1.c filtmod2.c \
52 nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
2b7238dd 53 nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
917fd061
UD
54 reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
55 nextmod1.c nextmod2.c
d66e34cd 56
05f732b3
UD
57include ../Makeconfig
58
40c4c9b5
UD
59before-compile = $(objpfx)trusted-dirs.h
60generated := trusted-dirs.h trusted-dirs.st
fd26970f 61
bdd421cc 62ifeq ($(versioning),yes)
a0edd63e 63ld-map = $(common-objpfx)ld.map
bdd421cc
UD
64endif
65
d66e34cd 66ifeq (yes,$(build-shared))
b79f74cd 67extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
40c4c9b5 68generated += librtld.os dl-allobjs.os ld.so ldd
8d57beea 69install-others = $(inst_slibdir)/$(rtld-installed-name)
b122c703 70install-bin = ldd
f49bc43f 71endif
86d2c878 72
9d141cae 73others = sprof sln
ea278354 74install-bin += sprof
9d141cae
UD
75others-static = sln
76install-rootsbin = sln
ae828bc6 77
591e1ffb 78ifeq (yes,$(use-ldconfig))
99ac5e47 79ifeq (yes,$(build-shared))
e1586792 80others-static += ldconfig
da2d1bc5 81others += ldconfig
9d141cae 82install-rootsbin += ldconfig
591e1ffb
UD
83
84ldconfig-modules := cache readlib xmalloc xstrdup
85extra-objs += $(ldconfig-modules:=.o)
86
87# To find xmalloc.c and xstrdup.c
88vpath %.c ../locale/programs
89
99ac5e47 90endif
1ef32c3d
UD
91endif
92
2f512715 93ifeq (yes,$(build-shared))
19cf43be 94tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
2b7238dd 95 constload1 order $(tests-vis-$(have-protected)) noload filter unload \
917fd061 96 reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \
2f54c82d 97 $(tests-nodlopen-$(have-z-nodlopen))
c1025c19 98tests-vis-yes = vismain
0fb7851f 99tests-nodelete-yes = nodelete
2f54c82d 100tests-nodlopen-yes = nodlopen
2f512715 101endif
a25f2023 102modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
2b7238dd 103 testobj1_1 failobj constload2 constload3 unloadmod \
0fb7851f 104 dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
2f54c82d 105 $(modules-nodelete-$(have-z-nodelete)) \
2b7238dd 106 $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
917fd061 107 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2
c1025c19 108modules-vis-yes = vismod1 vismod2 vismod3
2cb8cefb 109modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
2f54c82d 110modules-nodlopen-yes = nodlopenmod
9b014809 111extra-objs += $(addsuffix .os,$(strip $(modules-names)))
482eec0d 112
01cc0be6 113include ../Rules
d66e34cd 114
1ef32c3d 115ifeq (yes,$(build-shared))
a89d30d4
RM
116# Make sure these things are built in the `make lib' pass so they can be used
117# to run programs during the `make others' pass.
118lib-noranlib: $(objpfx)$(rtld-installed-name) \
119 $(addprefix $(objpfx),$(extra-objs))
120endif
121
db2286f6
RM
122# Command to link into a larger single relocatable object.
123reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
124
b79f74cd 125$(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
db2286f6
RM
126 $(reloc-link) $^
127
86d2c878 128# Link together the dynamic linker into a single relocatable object.
40a55d20 129$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
db2286f6 130 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
d66e34cd 131
f21acc89
UD
132# Do we need a linker script?
133rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
14ea22e9 134
f21acc89 135ifneq (,$(rtld-ldscript-in))
880f421f
UD
136rtld-ldscript = $(objpfx)rtld-ldscript
137generated += rtld-ldscript
138
139LDFLAGS-rtld = -T $(rtld-ldscript)
140before-compile += $(rtld-ldscript)
f21acc89 141
f21acc89
UD
142rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
143include $(rtld-parms)
880f421f
UD
144
145$(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
f21acc89
UD
146 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
147 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
148 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
149 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
880f421f 150endif
f21acc89 151
2f444823 152$(objpfx)ld.so: $(objpfx)librtld.os $(rtld-ldscript) $(ld-map)
7ef90c15
UD
153 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld) \
154 $(filter-out $(rtld-ldscript) $(map-file),$^) \
155 $(load-map-file) -Wl,-soname=$(rtld-installed-name)
266180eb 156
c7562c74
UD
157# interp.c exists just to get this string into the libraries.
158CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
159
1ef32c3d 160ifneq (ld.so,$(rtld-installed-name))
afd4eb37 161# Make sure ld.so.1 exists in the build directory so we can link
852fc4b9
RM
162# against it.
163$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
164 rm -f $@
f332db02 165 ln -s $(<F) $@
da2d1bc5 166generated += $(rtld-installed-name)
852fc4b9
RM
167endif
168
fd26970f
UD
169# Build a file mentioning all trustworthy directories to look for shared
170# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
171# add directories to the list by defining $(user-defined-trusted-dirs)
172# before starting make.
6598ac30
UD
173$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
174$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1ef32c3d 175 $(make-target-directory)
ab7eb292
UD
176 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
177 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
6598ac30
UD
178 $(move-if-change) ${@:st=T} ${@:st=h}
179 touch $@
9afc8a59 180CPPFLAGS-dl-load.c = -I$(objpfx).
86d2c878 181
9f2a9248 182ifeq (yes,$(build-shared))
73237de3 183$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
460adbb8 184 $(make-target-directory)
925e31d9 185 $(do-install-program)
1ef32c3d 186
8d57beea 187$(inst_slibdir)/$(rtld-installed-name): \
460adbb8
UD
188 $(inst_slibdir)/$(rtld-version-installed-name) \
189 $(inst_slibdir)/libc-$(version).so
925e31d9 190 $(make-shlib-link)
b122c703 191
5148d49f
UD
192# Special target called by parent to install just the dynamic linker.
193.PHONY: ldso_install
194ldso_install: $(inst_slibdir)/$(rtld-installed-name)
9f2a9248 195endif
5148d49f 196
cb343854 197
926e512f
RM
198common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
199 -e 's%@VERSION@%$(version)%g'
1ddf537f 200sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
926e512f 201bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
4a33c2f5 202 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
cb343854 203
84384f5b 204ifneq ($(have-bash2),yes)
cb343854 205ldd-shell = sh
e2102c14
UD
206else
207ldd-shell = bash
cb343854
UD
208endif
209
210ifeq ($(ldd-rewrite-script),no)
211define gen-ldd
212sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
213endef
84384f5b 214else
cb343854
UD
215define gen-ldd
216sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
217endef
218endif
219
926e512f 220$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
ee74a442 221 $(common-objpfx)config.make
cb343854 222 $(gen-ldd)
84384f5b
UD
223 chmod 555 $@.new
224 mv -f $@.new $@
cb343854 225
aaff4ba9 226$(objpfx)sprof: $(libdl)
94e365c6 227
591e1ffb 228$(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
8ca91b36
UD
229SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
230CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' -D'SLIBDIR="$(slibdir)"'
231CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
232CFLAGS-cache.c = $(SYSCONF-FLAGS)
591e1ffb 233
9b014809
UD
234test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
235generated += $(addsuffix .so,$(strip $(modules-names)))
482eec0d 236
aaff4ba9
UD
237$(objpfx)testobj1.so: $(libdl)
238$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
239$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
240$(objpfx)testobj3.so: $(libdl)
241$(objpfx)testobj4.so: $(libdl)
242$(objpfx)testobj5.so: $(libdl)
243$(objpfx)testobj6.so: $(libdl)
e18db2b0 244$(objpfx)failobj.so: $(objpfx)testobj6.so
84ddc586
UD
245$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
246$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
247$(objpfx)dep4.so: $(objpfx)dep3.so
2cb8cefb 248$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
917fd061 249$(objpfx)nextmod1.so: $(libdl)
482eec0d 250
10b36b41
AJ
251# filtmod1.so has a special rule
252$(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
482eec0d
UD
253 $(build-module)
254
aaff4ba9 255$(objpfx)loadtest: $(libdl)
482eec0d
UD
256LDFLAGS-loadtest = -rdynamic
257
258$(objpfx)loadtest.out: $(test-modules)
6bd06384 259
aaff4ba9 260$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
e18db2b0 261LDFLAGS-restest1 = -rdynamic
6bd06384
UD
262
263$(objpfx)restest1.out: $(test-modules)
3d91edb2 264
e18db2b0 265preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
10584d2e 266$(objpfx)preloadtest: $(objpfx)testobj6.so
10584d2e 267LDFLAGS-preloadtest = -rdynamic
e18db2b0
UD
268$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
269preloadtest-ENV = \
270 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1e262312 271
aaff4ba9 272$(objpfx)loadfail: $(libdl)
1e262312
UD
273LDFLAGS-loadfail = -rdynamic
274
61e0617a
UD
275$(objpfx)loadfail.out: $(objpfx)failobj.so
276
277$(objpfx)multiload: $(libdl)
278LDFLAGS-multiload = -rdynamic
9df54168 279CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
61e0617a
UD
280
281$(objpfx)multiload.out: $(objpfx)testobj1.so
dc5efe83
UD
282
283$(objpfx)origtest: $(libdl)
394679eb 284LDFLAGS-origtest = -rdynamic
dc5efe83 285$(objpfx)origtest.out: $(objpfx)testobj1.so
ff5fad16
UD
286
287ifeq ($(have-thread-library),yes)
288$(objpfx)resolvfail: $(libdl) $(shared-thread-library)
289else
290$(objpfx)resolvfail: $(libdl)
291endif
19cf43be
UD
292
293$(objpfx)constload1: $(libdl)
294$(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
84ddc586
UD
295
296$(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
297
298$(objpfx)order.out: $(objpfx)order
299 $(elf-objpfx)$(rtld-installed-name) \
300 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
301 $(objpfx)order > $@
302 (echo "0123456789" | cmp $@ -) > /dev/null
c1025c19
UD
303
304$(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
305$(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
306vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
5e61ef88
UD
307
308$(objpfx)noload: $(objpfx)testobj1.so
309LDFLAGS-noload = -rdynamic
310$(objpfx)noload.out: $(objpfx)testobj5.so
0fb7851f 311
ad7534c8 312LDFLAGS-nodelete = -rdynamic
0fb7851f 313LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
2cb8cefb 314LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
0fb7851f 315$(objpfx)nodelete: $(libdl)
2cb8cefb
UD
316$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
317 $(objpfx)nodelmod3.so
2f54c82d
UD
318
319LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
320$(objpfx)nodlopen: $(libdl)
321$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
fcacb36a 322
137bca87
UD
323$(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
324 $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \
325 -L$(subst :, -L,$(rpath-link)) \
326 -Wl,-rpath-link=$(rpath-link) \
327 $< -Wl,-F,$(objpfx)filtmod2.so
fcacb36a 328$(objpfx)filter: $(objpfx)filtmod1.so
2b7238dd
UD
329
330$(objpfx)unload: $(libdl)
331$(objpfx)unload.out: $(objpfx)unloadmod.so
332
333$(objpfx)reldep: $(libdl)
334$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so
335
336$(objpfx)reldep2: $(libdl)
337$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
338
339$(objpfx)reldep3: $(libdl)
340$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
917fd061
UD
341
342$(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)