]>
Commit | Line | Data |
---|---|---|
d66e34cd RM |
1 | # Makefile for elf subdirectory of GNU C Library. |
2 | ||
5290baf0 | 3 | # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
01cc0be6 RM |
4 | # This file is part of the GNU C Library. |
5 | ||
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Library General Public License as | |
8 | # published by the Free Software Foundation; either version 2 of the | |
9 | # License, or (at your option) any later version. | |
10 | ||
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Library General Public License for more details. | |
15 | ||
16 | # You should have received a copy of the GNU Library General Public | |
afd4eb37 UD |
17 | # License along with the GNU C Library; see the file COPYING.LIB. If not, |
18 | # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | # Boston, MA 02111-1307, USA. | |
01cc0be6 | 20 | |
d66e34cd RM |
21 | subdir := elf |
22 | ||
567c63af | 23 | headers = elf.h elfclass.h link.h dlfcn.h |
cddcfecf | 24 | routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \ |
c84142e8 | 25 | dl-version enbl-secure |
266180eb RM |
26 | |
27 | # The core dynamic linking functions are in libc for the static and | |
28 | # profiled libraries. | |
f18edac3 | 29 | dl-routines = $(addprefix dl-,load cache lookup object reloc deps \ |
0501d603 | 30 | runtime error init fini debug misc) |
266180eb | 31 | # But they are absent from the shared libc, because that code is in ld.so. |
cddcfecf | 32 | elide-routines.so = $(dl-routines) dl-support enbl-secure |
266180eb RM |
33 | |
34 | # ld.so uses those routines, plus some special stuff for being the program | |
35 | # interpreter and operating independent of libc. | |
36 | rtld-routines := rtld $(dl-routines) dl-sysdep dl-minimal | |
37 | distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \ | |
d705269e | 38 | dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c |
d66e34cd | 39 | |
f0f1bf85 UD |
40 | extra-libs = libdl |
41 | extra-libs-others = $(extra-libs) | |
c84142e8 | 42 | libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr |
714a562f | 43 | libdl-map := libdl.map |
d66e34cd | 44 | |
fd26970f UD |
45 | before-compile = $(objpfx)trusted-dirs.h |
46 | ||
01cc0be6 | 47 | |
bfc04a9f RM |
48 | all: # Make this the default target; it will be defined in Rules. |
49 | ||
d66e34cd RM |
50 | include ../Makeconfig |
51 | ||
52 | ifeq (yes,$(build-shared)) | |
f0f1bf85 | 53 | extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so |
db2286f6 | 54 | generated = librtld.so dl-allobjs.so |
8d57beea | 55 | install-others = $(inst_slibdir)/$(rtld-installed-name) |
b122c703 | 56 | install-bin = ldd |
f49bc43f | 57 | endif |
86d2c878 | 58 | |
1ef32c3d | 59 | ifeq (yes,$(has-ldconfig)) |
7cc27f44 | 60 | extra-objs += ldconfig.o |
1ef32c3d UD |
61 | install-rootsbin = ldconfig |
62 | ||
8d57beea | 63 | $(objpfx)ldconfig: $(objpfx)ldconfig.o |
1ef32c3d UD |
64 | $(CC) -nostdlib -nostartfiles -o $@ $(sysdep-LDFLAGS) -static \ |
65 | $(addprefix $(csu-objpfx),start.o) $(+preinit) \ | |
66 | $(filter-out $(addprefix $(csu-objpfx),start.o) $(+preinit) \ | |
67 | $(link-extra-libs) $(common-objpfx)libc% $(+postinit),$^) \ | |
68 | $(link-extra-libs) $(common-objpfx)libc.a $(gnulib) $(+postinit) | |
69 | endif | |
70 | ||
01cc0be6 | 71 | include ../Rules |
d66e34cd | 72 | |
86d2c878 | 73 | |
1ef32c3d | 74 | ifeq (yes,$(build-shared)) |
a89d30d4 RM |
75 | # Make sure these things are built in the `make lib' pass so they can be used |
76 | # to run programs during the `make others' pass. | |
77 | lib-noranlib: $(objpfx)$(rtld-installed-name) \ | |
78 | $(addprefix $(objpfx),$(extra-objs)) | |
79 | endif | |
80 | ||
db2286f6 RM |
81 | # Command to link into a larger single relocatable object. |
82 | reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@ | |
83 | ||
84 | $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so) | |
85 | $(reloc-link) $^ | |
86 | ||
86d2c878 | 87 | # Link together the dynamic linker into a single relocatable object. |
c7fd2f47 | 88 | $(objpfx)librtld.so: $(objpfx)dl-allobjs.so $(common-objpfx)libc_pic.a |
db2286f6 | 89 | $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)' |
d66e34cd | 90 | |
e3845371 RM |
91 | $(objpfx)ld.so: $(objpfx)librtld.so |
92 | $(rtld-link) -Wl,-soname=$(rtld-installed-name) | |
e3845371 RM |
93 | |
94 | define rtld-link | |
95 | $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \ | |
96 | -Wl,-rpath=$(default-rpath) $^ | |
97 | endef | |
86d2c878 | 98 | |
266180eb RM |
99 | # The dl code in the static libc needs a default library path. |
100 | CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"' | |
101 | ||
1ef32c3d | 102 | ifneq (ld.so,$(rtld-installed-name)) |
afd4eb37 | 103 | # Make sure ld.so.1 exists in the build directory so we can link |
852fc4b9 RM |
104 | # against it. |
105 | $(objpfx)$(rtld-installed-name): $(objpfx)ld.so | |
106 | rm -f $@ | |
f332db02 | 107 | ln -s $(<F) $@ |
852fc4b9 RM |
108 | endif |
109 | ||
fd26970f UD |
110 | # Build a file mentioning all trustworthy directories to look for shared |
111 | # libraries when using LD_LIBRARY_PATH in a setuid program. The user can | |
112 | # add directories to the list by defining $(user-defined-trusted-dirs) | |
113 | # before starting make. | |
114 | $(objpfx)trusted-dirs.h: Makefile | |
1ef32c3d | 115 | $(make-target-directory) |
fd26970f UD |
116 | (for dir in `echo "$(default-rpath) $(user-defined-trusted-dirs)" | \ |
117 | sed 's/:/ /g'`; do \ | |
118 | echo " \"$$dir\","; \ | |
119 | done;) > $@T | |
120 | mv -f $@T $@ | |
1ef32c3d | 121 | CPPFLAGS-dl-load.c = -I$(objdir)/$(subdir) |
56552e42 | 122 | CFLAGS-dl-load.c += -Wno-uninitialized |
86d2c878 | 123 | |
266180eb RM |
124 | # Specify the dependencies of libdl.so; its commands come from the generic |
125 | # rule to build a shared library. | |
7e0e6f50 | 126 | $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so |
b122c703 | 127 | |
8d57beea | 128 | $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so |
1ef32c3d UD |
129 | $(do-install-program) |
130 | ||
8d57beea UD |
131 | $(inst_slibdir)/$(rtld-installed-name): \ |
132 | $(inst_slibdir)/$(rtld-version-installed-name) | |
1ef32c3d | 133 | $(make-shlib-link) |
b122c703 | 134 | |
84384f5b | 135 | ifneq ($(have-bash2),yes) |
5290baf0 UD |
136 | $(objpfx)ldd: ldd.sh.in $(common-objpfx)version.mk \ |
137 | $(common-objpfx)soversions.mk $(common-objpfx)config.make | |
f0e44959 UD |
138 | sed -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \ |
139 | -e 's%@VERSION@%$(version)%g' < $< > $@.new | |
094bacdb | 140 | chmod 555 $@.new |
b122c703 | 141 | mv -f $@.new $@ |
84384f5b | 142 | else |
5290baf0 UD |
143 | $(objpfx)ldd: ldd.bash.in $(common-objpfx)version.mk \ |
144 | $(common-objpfx)soversions.mk $(common-objpfx)config.make | |
84384f5b UD |
145 | sed -e 's%@BASH@%$(BASH)%g' \ |
146 | -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \ | |
147 | -e 's%@VERSION@%$(version)%g' \ | |
148 | -e 's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new | |
149 | chmod 555 $@.new | |
150 | mv -f $@.new $@ | |
151 | endif | |
96bda0ea RM |
152 | \f |
153 | # muwahaha | |
154 | ||
175b633d | 155 | LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name) |
96bda0ea | 156 | $(objpfx)libdl.so: $(objpfx)eval.so |