1 # Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
14 # You should have received a copy of the GNU Library General Public
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.
19 # Makefile for elf subdirectory of GNU C Library.
23 headers
= elf.h bits
/elfclass.h bits
/dlfcn.h link.h dlfcn.h
24 routines
= $(dl-routines
) dl-open dl-close dl-symbol dl-support \
27 # The core dynamic linking functions are in libc for the static and
29 dl-routines
= $(addprefix dl-
,load cache lookup object reloc deps \
30 runtime error init fini debug misc \
32 # But they are absent from the shared libc, because that code is in ld.so.
33 elide-routines.os
= $(dl-routines
) dl-support enbl-secure
35 # ld.so uses those routines, plus some special stuff for being the program
36 # interpreter and operating independent of libc.
37 rtld-routines
:= rtld
$(dl-routines
) dl-sysdep dl-minimal
39 distribute
= $(rtld-routines
:=.c
) dynamic-link.h do-rel.h dl-machine.h \
40 dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c \
41 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
42 dl-librecon.h interp.c
45 extra-libs-others
= $(extra-libs
)
46 libdl-routines
:= dlopen dlclose dlsym dlvsym dlerror dladdr
47 libdl-map
:= libdl.map
49 before-compile
= $(objpfx
)trusted-dirs.h
$(objpfx
)rtldtbl.h
52 all: # Make this the default target; it will be defined in Rules.
56 ifeq (yes
,$(build-shared
))
57 extra-objs
= $(rtld-routines
:=.os
) soinit.os sofini.os eval.os interp.os
58 generated
= librtld.os dl-allobjs.os
ld.so trusted-dirs.h rtldtbl.h
59 install-others
= $(inst_slibdir
)/$(rtld-installed-name
)
67 ifeq (yes
,$(has-ldconfig
))
68 others-static
+= ldconfig
70 install-rootsbin
= ldconfig
76 ifeq (yes
,$(build-shared
))
77 # Make sure these things are built in the `make lib' pass so they can be used
78 # to run programs during the `make others' pass.
79 lib-noranlib
: $(objpfx
)$(rtld-installed-name
) \
80 $(addprefix $(objpfx
),$(extra-objs
))
83 # Command to link into a larger single relocatable object.
84 reloc-link
= $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@
86 $(objpfx
)dl-allobjs.os
: $(rtld-routines
:%=$(objpfx
)%.os
)
89 # Link together the dynamic linker into a single relocatable object.
90 $(objpfx
)librtld.os
: $(objpfx
)dl-allobjs.os
$(common-objpfx
)libc_pic.a
91 $(reloc-link
) '-Wl,-(' $^
-lgcc
'-Wl,-)'
93 # Do we need a linker script?
94 rtld-ldscript-in
:= $(firstword $(wildcard $(+sysdep_dirs
:%=%/rtld-ldscript.in
)))
96 ifneq (,$(rtld-ldscript-in
))
97 rtld-ldscript
= $(objpfx
)rtld-ldscript
98 generated
+= rtld-ldscript
100 LDFLAGS-rtld
= -T
$(rtld-ldscript
)
101 before-compile
+= $(rtld-ldscript
)
103 rtld-parms
= $(wildcard $(+sysdep_dirs
:%=%/rtld-parms
))
104 include $(rtld-parms
)
106 $(rtld-ldscript
): $(rtld-ldscript-in
) $(rtld-parms
)
107 sed
-e
's#@@rtld-oformat@@#$(rtld-oformat)#' \
108 -e
's#@@rtld-arch@@#$(rtld-arch)#' \
109 -e
's#@@rtld-entry@@#$(rtld-entry)#' \
110 -e
's#@@rtld-base@@#$(rtld-base)#' $< >$@
113 $(objpfx
)ld.so
: $(objpfx
)librtld.os
$(addprefix $(objpfx
),$(rtld-ldscript
)) \
115 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
118 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
119 -Wl
,-rpath
=$(default-rpath
) $(LDFLAGS-rtld
) \
120 $(filter-out $(rtld-ldscript
) $($(@F
:.so
=)-map
),$^
) \
121 $(load-map-file
:%=-Wl
,--version-script
=%)
124 # The dl code in the static libc needs a default library path.
125 CFLAGS-dl-support.c
= -D
'DEFAULT_RPATH="$(default-rpath)"'
127 # interp.c exists just to get this string into the libraries.
128 CFLAGS-interp.c
= -D
'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
130 ifneq (ld.so
,$(rtld-installed-name
))
131 # Make sure ld.so.1 exists in the build directory so we can link
133 $(objpfx
)$(rtld-installed-name
): $(objpfx
)ld.so
136 generated
+= $(rtld-installed-name
)
139 # Build a file mentioning all trustworthy directories to look for shared
140 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
141 # add directories to the list by defining $(user-defined-trusted-dirs)
142 # before starting make.
143 $(objpfx
)trusted-dirs.h
: Makefile
$(..
)Makeconfig
144 $(make-target-directory
)
145 (for
dir in
`echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
147 echo
" \"$$dir/\","; \
150 $(objpfx
)rtldtbl.h
: Makefile
$(..
)Makeconfig genrtldtbl.awk
151 $(make-target-directory
)
152 echo
"$(default-rpath)" |
$(AWK
) -f genrtldtbl.awk
> $@T
154 CPPFLAGS-dl-load.c
= -I
$(objpfx
).
155 CFLAGS-dl-load.c
+= -Wno-uninitialized
157 # Specify the dependencies of libdl.so; its commands come from the generic
158 # rule to build a shared library.
159 $(objpfx
)libdl.so
: $(objpfx
)libdl_pic.a
$(common-objpfx
)libc.so
$(objpfx
)ld.so
161 $(inst_slibdir
)/$(rtld-version-installed-name
): $(objpfx
)ld.so
$(+force)
162 $(do-install-program
)
164 $(inst_slibdir
)/$(rtld-installed-name
): \
165 $(inst_slibdir
)/$(rtld-version-installed-name
)
168 # Special target called by parent to install just the dynamic linker.
170 ldso_install
: $(inst_slibdir
)/$(rtld-installed-name
)
173 sh-ldd-rewrite
= -e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
174 -e
's%@VERSION@%$(version)%g'
175 bash-ldd-rewrite
= $(sh-ldd-rewrite
) -e
's%@BASH@%$(BASH)%g' \
176 -e
's%@TEXTDOMAINDIR@%$(localedir)%g'
178 ifneq ($(have-bash2
),yes
)
184 ifeq ($(ldd-rewrite-script
),no
)
186 sed
$($(ldd-shell
)-ldd-rewrite
) < $< > $@.new
190 sed
$($(ldd-shell
)-ldd-rewrite
) < $< | sed
-f
$(ldd-rewrite-script
) > $@.new
194 $(objpfx
)ldd
: ldd.
$(ldd-shell
).in
$(common-objpfx
)soversions.mk \
195 $(common-objpfx
)config.make
201 ifeq ($(build-shared
),yes
)
202 $(objpfx
)sprof
: $(objpfx
)libdl.so
$(libdl.so-version
)
204 $(objpfx
)sprof
: $(objpfx
)libdl.a
209 LDFLAGS-dl.so
= -Wl
,-dynamic-linker
,$(slibdir
)/$(rtld-installed-name
)
210 $(objpfx
)libdl.so
: $(objpfx
)eval.os