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