]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/Makefile
Update.
[thirdparty/glibc.git] / elf / Makefile
CommitLineData
482eec0d 1# Copyright (C) 1995, 1996, 1997, 1998, 1999 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
f21acc89 23headers = elf.h bits/elfclass.h bits/dlfcn.h link.h dlfcn.h
cddcfecf 24routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
b3fc5f84 25 dl-addr enbl-secure dl-profstub dl-origin dl-libc
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 \
e27b79d3 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
266180eb 38distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
bfce746a 39 dl-hash.h soinit.c sofini.c ldd.bash.in eval.c \
d09ef153 40 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
fabad360 41 dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
448c3875 42 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
fabad360
UD
43 testobj6.c testobj1_1.c failobj.c do-lookup.h \
44 gen-trusted-dirs.awk
d66e34cd 45
05f732b3
UD
46include ../Makeconfig
47
f0f1bf85
UD
48extra-libs = libdl
49extra-libs-others = $(extra-libs)
05f732b3
UD
50libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
51ifeq ($(versioning),yes)
52libdl-routines += dlopenold
53libdl-shared-only-routines := dlopenold
54endif
d66e34cd 55
6598ac30 56before-compile = $(objpfx)trusted-dirs.h
fd26970f 57
bdd421cc 58ifeq ($(versioning),yes)
8d8c6efa 59ld-map = $(common-objpfx)ld.so.map
bdd421cc
UD
60endif
61
d66e34cd 62ifeq (yes,$(build-shared))
c7562c74 63extra-objs = $(rtld-routines:=.os) soinit.os sofini.os eval.os interp.os
6598ac30 64generated = librtld.os dl-allobjs.os ld.so trusted-dirs.h trusted-dirs.st
8d57beea 65install-others = $(inst_slibdir)/$(rtld-installed-name)
b122c703 66install-bin = ldd
da2d1bc5 67generated += ldd
f49bc43f 68endif
86d2c878 69
9d141cae 70others = sprof sln
ea278354 71install-bin += sprof
9d141cae
UD
72others-static = sln
73install-rootsbin = sln
ae828bc6 74
1ef32c3d 75ifeq (yes,$(has-ldconfig))
e1586792 76others-static += ldconfig
da2d1bc5 77others += ldconfig
9d141cae 78install-rootsbin += ldconfig
1ef32c3d
UD
79endif
80
2f512715 81ifeq (yes,$(build-shared))
dc5efe83 82tests = loadtest restest1 preloadtest loadfail multiload origtest
2f512715 83endif
a25f2023
UD
84modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
85 testobj1_1 failobj
86extra-objs += $(modules-names:=.os)
482eec0d 87
aaff4ba9
UD
88ifeq ($(build-shared),yes)
89libdl = $(objpfx)libdl.so$(libdl.so-version)
90else
91libdl = $(objpfx)libdl.a
92endif
93
01cc0be6 94include ../Rules
d66e34cd 95
86d2c878 96
1ef32c3d 97ifeq (yes,$(build-shared))
a89d30d4
RM
98# Make sure these things are built in the `make lib' pass so they can be used
99# to run programs during the `make others' pass.
100lib-noranlib: $(objpfx)$(rtld-installed-name) \
101 $(addprefix $(objpfx),$(extra-objs))
102endif
103
db2286f6
RM
104# Command to link into a larger single relocatable object.
105reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
106
40a55d20 107$(objpfx)dl-allobjs.os: $(rtld-routines:%=$(objpfx)%.os)
db2286f6
RM
108 $(reloc-link) $^
109
86d2c878 110# Link together the dynamic linker into a single relocatable object.
40a55d20 111$(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
db2286f6 112 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
d66e34cd 113
f21acc89
UD
114# Do we need a linker script?
115rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
14ea22e9 116
f21acc89 117ifneq (,$(rtld-ldscript-in))
880f421f
UD
118rtld-ldscript = $(objpfx)rtld-ldscript
119generated += rtld-ldscript
120
121LDFLAGS-rtld = -T $(rtld-ldscript)
122before-compile += $(rtld-ldscript)
f21acc89 123
f21acc89
UD
124rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
125include $(rtld-parms)
880f421f
UD
126
127$(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
f21acc89
UD
128 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
129 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
130 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
131 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
880f421f 132endif
f21acc89 133
9afc8a59
UD
134$(objpfx)ld.so: $(objpfx)librtld.os $(addprefix $(objpfx),$(rtld-ldscript)) \
135 $(ld-map)
7ef90c15
UD
136 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld) \
137 $(filter-out $(rtld-ldscript) $(map-file),$^) \
138 $(load-map-file) -Wl,-soname=$(rtld-installed-name)
266180eb 139
c7562c74
UD
140# interp.c exists just to get this string into the libraries.
141CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
142
1ef32c3d 143ifneq (ld.so,$(rtld-installed-name))
afd4eb37 144# Make sure ld.so.1 exists in the build directory so we can link
852fc4b9
RM
145# against it.
146$(objpfx)$(rtld-installed-name): $(objpfx)ld.so
147 rm -f $@
f332db02 148 ln -s $(<F) $@
da2d1bc5 149generated += $(rtld-installed-name)
852fc4b9
RM
150endif
151
fd26970f
UD
152# Build a file mentioning all trustworthy directories to look for shared
153# libraries when using LD_LIBRARY_PATH in a setuid program. The user can
154# add directories to the list by defining $(user-defined-trusted-dirs)
155# before starting make.
6598ac30
UD
156$(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
157$(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
1ef32c3d 158 $(make-target-directory)
ab7eb292
UD
159 echo "$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))" \
160 | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T};
6598ac30
UD
161 $(move-if-change) ${@:st=T} ${@:st=h}
162 touch $@
9afc8a59 163CPPFLAGS-dl-load.c = -I$(objpfx).
56552e42 164CFLAGS-dl-load.c += -Wno-uninitialized
86d2c878 165
266180eb
RM
166# Specify the dependencies of libdl.so; its commands come from the generic
167# rule to build a shared library.
7e0e6f50 168$(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
b122c703 169
9f2a9248 170ifeq (yes,$(build-shared))
73237de3 171$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
1ef32c3d
UD
172 $(do-install-program)
173
8d57beea
UD
174$(inst_slibdir)/$(rtld-installed-name): \
175 $(inst_slibdir)/$(rtld-version-installed-name)
1ef32c3d 176 $(make-shlib-link)
b122c703 177
5148d49f
UD
178# Special target called by parent to install just the dynamic linker.
179.PHONY: ldso_install
180ldso_install: $(inst_slibdir)/$(rtld-installed-name)
9f2a9248 181endif
5148d49f 182
cb343854 183
926e512f
RM
184common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
185 -e 's%@VERSION@%$(version)%g'
1ddf537f 186sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
926e512f 187bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
cb343854
UD
188 -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
189
84384f5b 190ifneq ($(have-bash2),yes)
cb343854 191ldd-shell = sh
e2102c14
UD
192else
193ldd-shell = bash
cb343854
UD
194endif
195
196ifeq ($(ldd-rewrite-script),no)
197define gen-ldd
198sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
199endef
84384f5b 200else
cb343854
UD
201define gen-ldd
202sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
203endef
204endif
205
926e512f 206$(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
ee74a442 207 $(common-objpfx)config.make
cb343854 208 $(gen-ldd)
84384f5b
UD
209 chmod 555 $@.new
210 mv -f $@.new $@
cb343854 211
ae828bc6 212
aaff4ba9 213$(objpfx)sprof: $(libdl)
96bda0ea 214\f
482eec0d 215test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
407a7d0e 216generated += $(addsuffix .so,$(modules-names))
482eec0d 217
aaff4ba9
UD
218$(objpfx)testobj1.so: $(libdl)
219$(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
220$(objpfx)testobj2.so: $(objpfx)testobj1.so $(libdl)
221$(objpfx)testobj3.so: $(libdl)
222$(objpfx)testobj4.so: $(libdl)
223$(objpfx)testobj5.so: $(libdl)
224$(objpfx)testobj6.so: $(libdl)
e18db2b0 225$(objpfx)failobj.so: $(objpfx)testobj6.so
482eec0d 226
fe60f764 227$(test-modules): $(objpfx)%.so: $(objpfx)%.os
482eec0d
UD
228 $(build-module)
229
aaff4ba9 230$(objpfx)loadtest: $(libdl)
482eec0d
UD
231LDFLAGS-loadtest = -rdynamic
232
233$(objpfx)loadtest.out: $(test-modules)
6bd06384 234
aaff4ba9 235$(objpfx)restest1: $(objpfx)testobj1.so $(objpfx)testobj1_1.so $(libdl)
e18db2b0 236LDFLAGS-restest1 = -rdynamic
6bd06384
UD
237
238$(objpfx)restest1.out: $(test-modules)
3d91edb2 239
e18db2b0 240preloadtest-preloads = testobj1 testobj2 testobj3 testobj4 testobj5
10584d2e 241$(objpfx)preloadtest: $(objpfx)testobj6.so
10584d2e 242LDFLAGS-preloadtest = -rdynamic
e18db2b0
UD
243$(objpfx)preloadtest.out: $(preloadtest-preloads:%=$(objpfx)%.so)
244preloadtest-ENV = \
245 LD_PRELOAD=$(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
1e262312 246
aaff4ba9 247$(objpfx)loadfail: $(libdl)
1e262312
UD
248LDFLAGS-loadfail = -rdynamic
249
61e0617a
UD
250$(objpfx)loadfail.out: $(objpfx)failobj.so
251
252$(objpfx)multiload: $(libdl)
253LDFLAGS-multiload = -rdynamic
bf726173 254CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
61e0617a
UD
255
256$(objpfx)multiload.out: $(objpfx)testobj1.so
dc5efe83
UD
257
258$(objpfx)origtest: $(libdl)
259$(objpfx)origtest.out: $(objpfx)testobj1.so
482eec0d 260\f
96bda0ea
RM
261# muwahaha
262
175b633d 263LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
40a55d20 264$(objpfx)libdl.so: $(objpfx)eval.os