]> sourceware.org Git - glibc.git/blame - elf/Makefile
Update.
[glibc.git] / elf / Makefile
CommitLineData
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
21subdir := elf
22
567c63af 23headers = elf.h elfclass.h link.h dlfcn.h
cddcfecf 24routines = $(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 29dl-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 32elide-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.
36rtld-routines := rtld $(dl-routines) dl-sysdep dl-minimal
37distribute = $(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
40extra-libs = libdl
41extra-libs-others = $(extra-libs)
c84142e8 42libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
714a562f 43libdl-map := libdl.map
d66e34cd 44
fd26970f
UD
45before-compile = $(objpfx)trusted-dirs.h
46
01cc0be6 47
bfc04a9f
RM
48all: # Make this the default target; it will be defined in Rules.
49
d66e34cd
RM
50include ../Makeconfig
51
52ifeq (yes,$(build-shared))
f0f1bf85 53extra-objs = $(rtld-routines:=.so) soinit.so sofini.so eval.so
db2286f6 54generated = librtld.so dl-allobjs.so
8d57beea 55install-others = $(inst_slibdir)/$(rtld-installed-name)
b122c703 56install-bin = ldd
f49bc43f 57endif
86d2c878 58
1ef32c3d 59ifeq (yes,$(has-ldconfig))
7cc27f44 60extra-objs += ldconfig.o
1ef32c3d
UD
61install-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)
69endif
70
01cc0be6 71include ../Rules
d66e34cd 72
86d2c878 73
1ef32c3d 74ifeq (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.
77lib-noranlib: $(objpfx)$(rtld-installed-name) \
78 $(addprefix $(objpfx),$(extra-objs))
79endif
80
db2286f6
RM
81# Command to link into a larger single relocatable object.
82reloc-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
94define rtld-link
95$(LINK.o) -nostdlib -nostartfiles -shared -o $@ \
96 -Wl,-rpath=$(default-rpath) $^
97endef
86d2c878 98
266180eb
RM
99# The dl code in the static libc needs a default library path.
100CFLAGS-dl-support.c = -D'DEFAULT_RPATH="$(default-rpath)"'
101
1ef32c3d 102ifneq (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
108endif
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 121CPPFLAGS-dl-load.c = -I$(objdir)/$(subdir)
56552e42 122CFLAGS-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 135ifneq ($(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 142else
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 $@
151endif
96bda0ea
RM
152\f
153# muwahaha
154
175b633d 155LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
96bda0ea 156$(objpfx)libdl.so: $(objpfx)eval.so
This page took 0.074138 seconds and 5 git commands to generate.