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