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 \
25 dl-addr enbl-secure dl-profstub
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-environ dl-minimal
38 distribute
= $(rtld-routines
:=.c
) dynamic-link.h do-rel.h dl-machine.h \
39 dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c \
40 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
41 dl-librecon.h interp.c sln.c
44 extra-libs-others
= $(extra-libs
)
45 libdl-routines
:= dlopen dlclose dlsym dlvsym dlerror dladdr
47 before-compile
= $(objpfx
)trusted-dirs.h
50 all: # Make this the default target; it will be defined in Rules.
54 ifeq ($(versioning
),yes
)
55 ld-map
= $(common-objpfx
)libc.map
58 ifeq (yes
,$(build-shared
))
59 extra-objs
= $(rtld-routines
:=.os
) soinit.os sofini.os eval.os interp.os
60 generated
= librtld.os dl-allobjs.os
ld.so trusted-dirs.h trusted-dirs.st
61 install-others
= $(inst_slibdir
)/$(rtld-installed-name
)
69 install-rootsbin
= sln
71 ifeq (yes
,$(has-ldconfig
))
72 others-static
+= ldconfig
74 install-rootsbin
+= ldconfig
80 ifeq (yes
,$(build-shared
))
81 # Make sure these things are built in the `make lib' pass so they can be used
82 # to run programs during the `make others' pass.
83 lib-noranlib
: $(objpfx
)$(rtld-installed-name
) \
84 $(addprefix $(objpfx
),$(extra-objs
))
87 # Command to link into a larger single relocatable object.
88 reloc-link
= $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@
90 $(objpfx
)dl-allobjs.os
: $(rtld-routines
:%=$(objpfx
)%.os
)
93 # Link together the dynamic linker into a single relocatable object.
94 $(objpfx
)librtld.os
: $(objpfx
)dl-allobjs.os
$(common-objpfx
)libc_pic.a
95 $(reloc-link
) '-Wl,-(' $^
-lgcc
'-Wl,-)'
97 # Do we need a linker script?
98 rtld-ldscript-in
:= $(firstword $(wildcard $(+sysdep_dirs
:%=%/rtld-ldscript.in
)))
100 ifneq (,$(rtld-ldscript-in
))
101 rtld-ldscript
= $(objpfx
)rtld-ldscript
102 generated
+= rtld-ldscript
104 LDFLAGS-rtld
= -T
$(rtld-ldscript
)
105 before-compile
+= $(rtld-ldscript
)
107 rtld-parms
= $(wildcard $(+sysdep_dirs
:%=%/rtld-parms
))
108 include $(rtld-parms
)
110 $(rtld-ldscript
): $(rtld-ldscript-in
) $(rtld-parms
)
111 sed
-e
's#@@rtld-oformat@@#$(rtld-oformat)#' \
112 -e
's#@@rtld-arch@@#$(rtld-arch)#' \
113 -e
's#@@rtld-entry@@#$(rtld-entry)#' \
114 -e
's#@@rtld-base@@#$(rtld-base)#' $< >$@
117 $(objpfx
)ld.so
: $(objpfx
)librtld.os
$(addprefix $(objpfx
),$(rtld-ldscript
)) \
119 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
120 -Wl
,-rpath
=$(default-rpath
) $(LDFLAGS-rtld
) \
121 $(filter-out $(rtld-ldscript
) $(map-file
),$^
) \
122 $(load-map-file
) -Wl
,-soname
=$(rtld-installed-name
)
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
: $(objpfx
)trusted-dirs.st
; @
:
144 $(objpfx
)trusted-dirs.st
: Makefile
$(..
)Makeconfig
145 $(make-target-directory
)
146 dirs
="$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))"; \
147 for
dir in
$$dirs; do \
148 echo
" \"$$dir/\","; \
150 $(move-if-change
) ${@
:st
=T
} ${@
:st
=h
}
152 CPPFLAGS-dl-load.c
= -I
$(objpfx
).
153 CFLAGS-dl-load.c
+= -Wno-uninitialized
155 # Specify the dependencies of libdl.so; its commands come from the generic
156 # rule to build a shared library.
157 $(objpfx
)libdl.so
: $(objpfx
)libdl_pic.a
$(common-objpfx
)libc.so
$(objpfx
)ld.so
159 $(inst_slibdir
)/$(rtld-version-installed-name
): $(objpfx
)ld.so
$(+force)
160 $(do-install-program
)
162 $(inst_slibdir
)/$(rtld-installed-name
): \
163 $(inst_slibdir
)/$(rtld-version-installed-name
)
166 # Special target called by parent to install just the dynamic linker.
168 ldso_install
: $(inst_slibdir
)/$(rtld-installed-name
)
171 common-ldd-rewrite
= -e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
172 -e
's%@VERSION@%$(version)%g'
173 sh-ldd-rewrite
= $(common-ldd-rewrite
) -e
's%@BASH@%/bin/sh%g;s/\$$"/"/g'
174 bash-ldd-rewrite
= $(common-ldd-rewrite
) -e
's%@BASH@%$(BASH)%g' \
175 -e
's%@TEXTDOMAINDIR@%$(localedir)%g'
177 ifneq ($(have-bash2
),yes
)
183 ifeq ($(ldd-rewrite-script
),no
)
185 sed
$($(ldd-shell
)-ldd-rewrite
) < $< > $@.new
189 sed
$($(ldd-shell
)-ldd-rewrite
) < $< | sed
-f
$(ldd-rewrite-script
) > $@.new
193 $(objpfx
)ldd
: ldd.bash.in
$(common-objpfx
)soversions.mk \
194 $(common-objpfx
)config.make
200 ifeq ($(build-shared
),yes
)
201 $(objpfx
)sprof
: $(objpfx
)libdl.so
$(libdl.so-version
)
203 $(objpfx
)sprof
: $(objpfx
)libdl.a
208 LDFLAGS-dl.so
= -Wl
,-dynamic-linker
,$(slibdir
)/$(rtld-installed-name
)
209 $(objpfx
)libdl.so
: $(objpfx
)eval.os