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