1 # Makefile for elf subdirectory of GNU C Library.
3 # Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
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 not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
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
44 extra-libs-others
= $(extra-libs
)
45 libdl-routines
:= dlopen dlclose dlsym dlvsym dlerror dladdr
46 libdl-map
:= libdl.map
48 before-compile
= $(objpfx
)trusted-dirs.h
$(objpfx
)rtldtbl.h
51 all: # Make this the default target; it will be defined in Rules.
55 ifeq (yes
,$(build-shared
))
56 extra-objs
= $(rtld-routines
:=.os
) soinit.os sofini.os eval.os
57 generated
= librtld.os dl-allobjs.os
ld.so trusted-dirs.h rtldtbl.h
58 install-others
= $(inst_slibdir
)/$(rtld-installed-name
)
63 ifeq (yes
,$(has-ldconfig
))
65 install-rootsbin
= ldconfig
67 $(objpfx
)ldconfig
: $(objpfx
)ldconfig.o
68 $(CC
) -nostdlib
-nostartfiles
-o
$@
$(sysdep-LDFLAGS
) -static \
69 $(addprefix $(csu-objpfx
),start.o
) $(+preinit
) \
70 $(filter-out $(addprefix $(csu-objpfx
),start.o
) $(+preinit
) \
71 $(link-extra-libs
) $(common-objpfx
)libc
% $(+postinit
),$^
) \
72 $(link-extra-libs
) $(common-objpfx
)libc.a
$(gnulib
) $(+postinit
)
78 ifeq (yes
,$(build-shared
))
79 # Make sure these things are built in the `make lib' pass so they can be used
80 # to run programs during the `make others' pass.
81 lib-noranlib
: $(objpfx
)$(rtld-installed-name
) \
82 $(addprefix $(objpfx
),$(extra-objs
))
85 # Command to link into a larger single relocatable object.
86 reloc-link
= $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@
88 $(objpfx
)dl-allobjs.os
: $(rtld-routines
:%=$(objpfx
)%.os
)
91 # Link together the dynamic linker into a single relocatable object.
92 $(objpfx
)librtld.os
: $(objpfx
)dl-allobjs.os
$(common-objpfx
)libc_pic.a
93 $(reloc-link
) '-Wl,-(' $^
-lgcc
'-Wl,-)'
95 # Do we need a linker script?
96 rtld-ldscript-in
:= $(firstword $(wildcard $(+sysdep_dirs
:%=%/rtld-ldscript.in
)))
97 ifneq (,$(rtld-ldscript-in
))
98 LDFLAGS-rtld
= -T
$(objpfx
)rtld-ldscript
100 before-compile
+= $(objpfx
)rtld-ldscript
101 rtld-parms
= $(wildcard $(+sysdep_dirs
:%=%/rtld-parms
))
102 include $(rtld-parms
)
103 generated
+= rtld-ldscript
104 $(objpfx
)rtld-ldscript
: $(rtld-ldscript-in
) $(rtld-parms
)
105 sed
-e
's#@@rtld-oformat@@#$(rtld-oformat)#' \
106 -e
's#@@rtld-arch@@#$(rtld-arch)#' \
107 -e
's#@@rtld-entry@@#$(rtld-entry)#' \
108 -e
's#@@rtld-base@@#$(rtld-base)#' $< >$@
110 $(objpfx
)ld.so
: $(objpfx
)librtld.os
$(objpfx
)rtld-ldscript
111 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
114 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
115 -Wl
,-rpath
=$(default-rpath
) $(LDFLAGS-rtld
) \
116 $(filter-out $(objpfx
)rtld-ldscript
,$^
) \
117 -Wl
,--version-script
=$(rtld-map
)
120 $(objpfx
)ld.so
: $(objpfx
)librtld.os
121 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
124 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
125 -Wl
,-rpath
=$(default-rpath
) $^ \
126 -Wl
,--version-script
=$(rtld-map
)
130 # The dl code in the static libc needs a default library path.
131 CFLAGS-dl-support.c
= -D
'DEFAULT_RPATH="$(default-rpath)"'
133 ifneq (ld.so
,$(rtld-installed-name
))
134 # Make sure ld.so.1 exists in the build directory so we can link
136 $(objpfx
)$(rtld-installed-name
): $(objpfx
)ld.so
139 generated
+= $(rtld-installed-name
)
142 # Build a file mentioning all trustworthy directories to look for shared
143 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
144 # add directories to the list by defining $(user-defined-trusted-dirs)
145 # before starting make.
146 $(objpfx
)trusted-dirs.h
: Makefile
147 $(make-target-directory
)
148 (for
dir in
`echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
150 echo
" \"$$dir\","; \
153 $(objpfx
)rtldtbl.h
: Makefile
154 $(make-target-directory
)
155 echo
"$(default-rpath)" | awk
-f genrtldtbl.awk
> $@T
157 CPPFLAGS-dl-load.c
= -I
$(objdir
)/$(subdir
)
158 CFLAGS-dl-load.c
+= -Wno-uninitialized
160 # Specify the dependencies of libdl.so; its commands come from the generic
161 # rule to build a shared library.
162 $(objpfx
)libdl.so
: $(objpfx
)libdl_pic.a
$(common-objpfx
)libc.so
$(objpfx
)ld.so
164 $(inst_slibdir
)/$(rtld-version-installed-name
): $(objpfx
)ld.so
165 $(do-install-program
)
167 $(inst_slibdir
)/$(rtld-installed-name
): \
168 $(inst_slibdir
)/$(rtld-version-installed-name
)
171 # Special target called by parent to install just the dynamic linker.
173 ldso_install
: $(inst_slibdir
)/$(rtld-installed-name
)
175 ifneq ($(have-bash2
),yes
)
176 $(objpfx
)ldd
: ldd.sh.in
$(common-objpfx
)version.mk \
177 $(common-objpfx
)soversions.mk
$(common-objpfx
)config.make
178 sed
-e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
179 -e
's%@VERSION@%$(version)%g' < $< > $@.new
183 $(objpfx
)ldd
: ldd.bash.in
$(common-objpfx
)version.mk \
184 $(common-objpfx
)soversions.mk
$(common-objpfx
)config.make
185 sed
-e
's%@BASH@%$(BASH)%g' \
186 -e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
187 -e
's%@VERSION@%$(version)%g' \
188 -e
's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
195 LDFLAGS-dl.so
= -Wl
,-dynamic-linker
,$(slibdir
)/$(rtld-installed-name
)
196 $(objpfx
)libdl.so
: $(objpfx
)eval.os