]> sourceware.org Git - glibc.git/blob - elf/Makefile
Update.
[glibc.git] / elf / Makefile
1 # Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
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
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.
18
19 # Makefile for elf subdirectory of GNU C Library.
20
21 subdir := elf
22
23 headers = elf.h bits/elfclass.h link.h
24 routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
25 dl-addr enbl-secure dl-profstub dl-origin dl-libc dl-sym
26
27 # The core dynamic linking functions are in libc for the static and
28 # profiled libraries.
29 dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
30 runtime error init fini debug misc \
31 version profile)
32 all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
33 # But they are absent from the shared libc, because that code is in ld.so.
34 elide-routines.os = $(all-dl-routines) dl-support enbl-secure
35
36 # ld.so uses those routines, plus some special stuff for being the program
37 # interpreter and operating independent of libc.
38 rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
39 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
40
41 distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
42 dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
43 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
44 dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
45 do-lookup.h dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
46 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
47 testobj6.c testobj1_1.c failobj.c unloadmod.c \
48 ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
49 dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h \
50 vismain.c vismod1.c vismod2.c vismod3.c \
51 constload2.c constload3.c filtmod1.c filtmod2.c \
52 nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
53 nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
54 reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
55 nextmod1.c nextmod2.c
56
57 include ../Makeconfig
58
59 before-compile = $(objpfx)trusted-dirs.h
60 generated := trusted-dirs.h trusted-dirs.st
61
62 ifeq ($(versioning),yes)
63 ld-map = $(common-objpfx)ld.map
64 endif
65
66 ifeq (yes,$(build-shared))
67 extra-objs = $(all-rtld-routines:%=%.os) soinit.os sofini.os interp.os
68 generated += librtld.os dl-allobjs.os ld.so ldd
69 install-others = $(inst_slibdir)/$(rtld-installed-name)
70 install-bin = ldd
71 endif
72
73 others = sprof sln
74 install-bin += sprof
75 others-static = sln
76 install-rootsbin = sln
77
78 ifeq (yes,$(use-ldconfig))
79 ifeq (yes,$(build-shared))
80 others-static += ldconfig
81 others += ldconfig
82 install-rootsbin += ldconfig
83
84 ldconfig-modules := cache readlib xmalloc xstrdup
85 extra-objs += $(ldconfig-modules:=.o)
86
87 # To find xmalloc.c and xstrdup.c
88 vpath %.c ../locale/programs
89
90 endif
91 endif
92
93 ifeq (yes,$(build-shared))
94 tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
95 constload1 order $(tests-vis-$(have-protected)) noload filter unload \
96 reldep reldep2 reldep3 next $(tests-nodelete-$(have-z-nodelete)) \
97 $(tests-nodlopen-$(have-z-nodlopen))
98 tests-vis-yes = vismain
99 tests-nodelete-yes = nodelete
100 tests-nodlopen-yes = nodlopen
101 endif
102 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
103 testobj1_1 failobj constload2 constload3 unloadmod \
104 dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
105 $(modules-nodelete-$(have-z-nodelete)) \
106 $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
107 reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2
108 modules-vis-yes = vismod1 vismod2 vismod3
109 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
110 modules-nodlopen-yes = nodlopenmod
111 extra-objs += $(addsuffix .os,$(strip $(modules-names)))
112
113 include ../Rules
114
115 ifeq (yes,$(build-shared))
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.
118 lib-noranlib: $(objpfx)$(rtld-installed-name) \
119 $(addprefix $(objpfx),$(extra-objs))
120 endif
121
122 # Command to link into a larger single relocatable object.
123 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
124
125 $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
126 $(reloc-link) $^
127
128 # Link together the dynamic linker into a single relocatable object.
129 $(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
130 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
131
132 # Do we need a linker script?
133 rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
134
135 ifneq (,$(rtld-ldscript-in))
136 rtld-ldscript = $(objpfx)rtld-ldscript
137 generated += rtld-ldscript
138
139 LDFLAGS-rtld = -T $(rtld-ldscript)
140 before-compile += $(rtld-ldscript)
141
142 rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
143 include $(rtld-parms)
144
145 $(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
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)#' $< >$@
150 endif
151
152 $(objpfx)ld.so: $(objpfx)librtld.os $(rtld-ldscript) $(ld-map)
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)
156
157 # interp.c exists just to get this string into the libraries.
158 CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
159
160 ifneq (ld.so,$(rtld-installed-name))
161 # Make sure ld.so.1 exists in the build directory so we can link
162 # against it.
163 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
164 rm -f $@
165 ln -s $(<F) $@
166 generated += $(rtld-installed-name)
167 endif
168
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.
173 $(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
174 $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
175 $(make-target-directory)
176 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
177 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
178 $(move-if-change) ${@:st=T} ${@:st=h}
179 touch $@
180 CPPFLAGS-dl-load.c = -I$(objpfx).
181
182 ifeq (yes,$(build-shared))
183 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
184 $(make-target-directory)
185 $(do-install-program)
186
187 $(inst_slibdir)/$(rtld-installed-name): \
188 $(inst_slibdir)/$(rtld-version-installed-name) \
189 $(inst_slibdir)/libc-$(version).so
190 $(make-shlib-link)
191
192 # Special target called by parent to install just the dynamic linker.
193 .PHONY: ldso_install
194 ldso_install: $(inst_slibdir)/$(rtld-installed-name)
195 endif
196
197
198 common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
199 -e 's%@VERSION@%$(version)%g'
200 sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
201 bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
202 -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g'
203
204 ifneq ($(have-bash2),yes)
205 ldd-shell = sh
206 else
207 ldd-shell = bash
208 endif
209
210 ifeq ($(ldd-rewrite-script),no)
211 define gen-ldd
212 sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
213 endef
214 else
215 define gen-ldd
216 sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
217 endef
218 endif
219
220 $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
221 $(common-objpfx)config.make
222 $(gen-ldd)
223 chmod 555 $@.new
224 mv -f $@.new $@
225
226 $(objpfx)sprof: $(libdl)
227
228 $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o)
229 SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
230 CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' -D'SLIBDIR="$(slibdir)"'
231 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
232 CFLAGS-cache.c = $(SYSCONF-FLAGS)
233
234 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
235 generated += $(addsuffix .so,$(strip $(modules-names)))
236
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)
244 $(objpfx)failobj.so: $(objpfx)testobj6.so
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
248 $(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
249 $(objpfx)nextmod1.so: $(libdl)
250
251 # filtmod1.so has a special rule
252 $(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
253 $(build-module)
254
255 $(objpfx)loadtest: $(libdl)
256 LDFLAGS-loadtest = -rdynamic
257
258 $(objpfx)loadtest.out: $(test-modules)
259
260 $(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
261 LDFLAGS-restest1 = -rdynamic
262
263 $(objpfx)restest1.out: $(test-modules)
264
265 preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
266 $(objpfx)preloadtest: $(objpfx)testobj6.so
267 LDFLAGS-preloadtest = -rdynamic
268 $(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
269 preloadtest-ENV = \
270 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
271
272 $(objpfx)loadfail: $(libdl)
273 LDFLAGS-loadfail = -rdynamic
274
275 $(objpfx)loadfail.out: $(objpfx)failobj.so
276
277 $(objpfx)multiload: $(libdl)
278 LDFLAGS-multiload = -rdynamic
279 CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
280
281 $(objpfx)multiload.out: $(objpfx)testobj1.so
282
283 $(objpfx)origtest: $(libdl)
284 LDFLAGS-origtest = -rdynamic
285 $(objpfx)origtest.out: $(objpfx)testobj1.so
286
287 ifeq ($(have-thread-library),yes)
288 $(objpfx)resolvfail: $(libdl) $(shared-thread-library)
289 else
290 $(objpfx)resolvfail: $(libdl)
291 endif
292
293 $(objpfx)constload1: $(libdl)
294 $(objpfx)constload1.out: $(objpfx)constload2.so $(objpfx)constload3.so
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
303
304 $(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
305 $(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
306 vismain-ENV = LD_PRELOAD=$(addprefix $(objpfx),vismod3.so)
307
308 $(objpfx)noload: $(objpfx)testobj1.so
309 LDFLAGS-noload = -rdynamic
310 $(objpfx)noload.out: $(objpfx)testobj5.so
311
312 LDFLAGS-nodelete = -rdynamic
313 LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
314 LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
315 $(objpfx)nodelete: $(libdl)
316 $(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
317 $(objpfx)nodelmod3.so
318
319 LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
320 $(objpfx)nodlopen: $(libdl)
321 $(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so
322
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
328 $(objpfx)filter: $(objpfx)filtmod1.so
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
341
342 $(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
This page took 0.057455 seconds and 6 git commands to generate.