]>
Commit | Line | Data |
---|---|---|
d66e34cd RM |
1 | # Makefile for elf subdirectory of GNU C Library. |
2 | ||
a641835a | 3 | # Copyright (C) 1995, 1996 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 | |
17 | # License along with the GNU C Library; see the file COPYING.LIB. If | |
18 | # not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
19 | # Cambridge, MA 02139, USA. | |
20 | ||
d66e34cd RM |
21 | subdir := elf |
22 | ||
567c63af | 23 | headers = elf.h elfclass.h link.h dlfcn.h |
6e86a7c2 | 24 | routines = $(dl-routines) dl-open dl-close dl-symbol dl-support |
266180eb RM |
25 | |
26 | # The core dynamic linking functions are in libc for the static and | |
27 | # profiled libraries. | |
28 | dl-routines = $(addprefix dl-,load lookup object reloc deps \ | |
4d6acc61 | 29 | runtime error init fini debug) |
266180eb RM |
30 | # But they are absent from the shared libc, because that code is in ld.so. |
31 | elide-routines.so = $(dl-routines) dl-support | |
32 | ||
33 | # ld.so uses those routines, plus some special stuff for being the program | |
34 | # interpreter and operating independent of libc. | |
35 | rtld-routines := rtld $(dl-routines) dl-sysdep dl-minimal | |
36 | distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \ | |
96bda0ea | 37 | soinit.c sofini.c ldd.sh.in |
d66e34cd | 38 | |
266180eb | 39 | extra-libs = libdl |
a2b934be | 40 | libdl-routines := dlopen dlclose dlsym dlerror dladdr |
d66e34cd | 41 | |
01cc0be6 | 42 | |
bfc04a9f RM |
43 | all: # Make this the default target; it will be defined in Rules. |
44 | ||
d66e34cd RM |
45 | include ../Makeconfig |
46 | ||
47 | ifeq (yes,$(build-shared)) | |
0324daa0 | 48 | extra-objs = $(rtld-routines:=.so) soinit.so sofini.so |
db2286f6 | 49 | generated = librtld.so dl-allobjs.so |
094bacdb | 50 | install-others = $(slibdir)/$(rtld-installed-name) |
b122c703 | 51 | install-bin = ldd |
f49bc43f | 52 | endif |
86d2c878 | 53 | |
01cc0be6 | 54 | include ../Rules |
d66e34cd | 55 | |
86d2c878 | 56 | |
a89d30d4 RM |
57 | ifeq (yes, $(build-shared)) |
58 | # Make sure these things are built in the `make lib' pass so they can be used | |
59 | # to run programs during the `make others' pass. | |
60 | lib-noranlib: $(objpfx)$(rtld-installed-name) \ | |
61 | $(addprefix $(objpfx),$(extra-objs)) | |
62 | endif | |
63 | ||
db2286f6 RM |
64 | # Command to link into a larger single relocatable object. |
65 | reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@ | |
66 | ||
67 | $(objpfx)dl-allobjs.so: $(rtld-routines:%=$(objpfx)%.so) | |
68 | $(reloc-link) $^ | |
69 | ||
86d2c878 RM |
70 | # Link together the dynamic linker into a single relocatable object. |
71 | # We use this to produce both the ABI-compliant and Linux-compatible | |
72 | # dynamic linker shared objects below. | |
db2286f6 | 73 | $(objpfx)librtld.so: $(objpfx)dl-allobjs.so \ |
86d2c878 | 74 | $(patsubst %,$(common-objpfx)lib%_pic.a,\ |
ba79d61b | 75 | c $(LDLIBS-c.so:-l%=%)) |
db2286f6 | 76 | $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)' |
d66e34cd | 77 | |
e3845371 RM |
78 | $(objpfx)ld.so: $(objpfx)librtld.so |
79 | $(rtld-link) -Wl,-soname=$(rtld-installed-name) | |
e3845371 RM |
80 | |
81 | define rtld-link | |
82 | $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \ | |
83 | -Wl,-rpath=$(default-rpath) $^ | |
84 | endef | |
86d2c878 | 85 | |
266180eb RM |
86 | # The dl code in the static libc needs a default library path. |
87 | CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"' | |
88 | ||
852fc4b9 RM |
89 | ifneq (ld.so, $(rtld-installed-name)) |
90 | # Make sure ld-gnu.so.1 exists in the build directory so we can link | |
91 | # against it. | |
92 | $(objpfx)$(rtld-installed-name): $(objpfx)ld.so | |
93 | rm -f $@ | |
f332db02 | 94 | ln -s $(<F) $@ |
852fc4b9 RM |
95 | endif |
96 | ||
86d2c878 | 97 | |
266180eb RM |
98 | # Specify the dependencies of libdl.so; its commands come from the generic |
99 | # rule to build a shared library. | |
7e0e6f50 | 100 | $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so |
b122c703 | 101 | |
094bacdb | 102 | $(slibdir)/$(rtld-installed-name): $(objpfx)ld.so; $(do-install-program) |
b122c703 | 103 | |
f8adc70c RM |
104 | $(objpfx)ldd: ldd.sh.in Makefile |
105 | sed 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' < $< > $@.new | |
094bacdb | 106 | chmod 555 $@.new |
b122c703 | 107 | mv -f $@.new $@ |
96bda0ea RM |
108 | \f |
109 | # muwahaha | |
110 | ||
111 | $(objpfx)libdl.so: $(objpfx)eval.so |