1 # Makefile for elf subdirectory of GNU C Library.
3 # Copyright (C) 1995, 1996, 1997 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 \
25 dl-version enbl-secure
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
)
31 # But they are absent from the shared libc, because that code is in ld.so.
32 elide-routines.so
= $(dl-routines
) dl-support enbl-secure
34 # ld.so uses those routines, plus some special stuff for being the program
35 # interpreter and operating independent of libc.
36 rtld-routines
:= rtld
$(dl-routines
) dl-sysdep dl-minimal
37 distribute
= $(rtld-routines
:=.c
) dynamic-link.h do-rel.h dl-machine.h \
38 dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c
41 extra-libs-others
= $(extra-libs
)
42 libdl-routines
:= dlopen dlclose dlsym dlvsym dlerror dladdr
43 libdl-map
:= libdl.map
45 before-compile
= $(objpfx
)trusted-dirs.h
48 all: # Make this the default target; it will be defined in Rules.
52 ifeq (yes
,$(build-shared
))
53 extra-objs
= $(rtld-routines
:=.so
) soinit.so sofini.so eval.so
54 generated
= librtld.so dl-allobjs.so
55 install-others
= $(inst_slibdir
)/$(rtld-installed-name
)
59 ifeq (yes
,$(has-ldconfig
))
60 extra-objs
+= ldconfig.o
61 install-rootsbin
= ldconfig
63 $(objpfx
)ldconfig
: $(objpfx
)ldconfig.o
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
)
74 ifeq (yes
,$(build-shared
))
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.
77 lib-noranlib
: $(objpfx
)$(rtld-installed-name
) \
78 $(addprefix $(objpfx
),$(extra-objs
))
81 # Command to link into a larger single relocatable object.
82 reloc-link
= $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@
84 $(objpfx
)dl-allobjs.so
: $(rtld-routines
:%=$(objpfx
)%.so
)
87 # Link together the dynamic linker into a single relocatable object.
88 $(objpfx
)librtld.so
: $(objpfx
)dl-allobjs.so
$(common-objpfx
)libc_pic.a
89 $(reloc-link
) '-Wl,-(' $^
-lgcc
'-Wl,-)'
91 # Do we need a linker script?
92 rtld-ldscript-in
:= $(firstword $(wildcard $(+sysdep_dirs
:%=%/rtld-ldscript.in
)))
93 ifneq (,$(rtld-ldscript-in
))
94 LDFLAGS-rtld
= -T
$(objpfx
)rtld-ldscript
96 before-compile
+= $(objpfx
)rtld-ldscript
97 rtld-parms
= $(wildcard $(+sysdep_dirs
:%=%/rtld-parms
))
99 generated
+= rtld-ldscript
100 $(objpfx
)rtld-ldscript
: $(rtld-ldscript-in
) $(rtld-parms
)
101 sed
-e
's#@@rtld-oformat@@#$(rtld-oformat)#' \
102 -e
's#@@rtld-arch@@#$(rtld-arch)#' \
103 -e
's#@@rtld-entry@@#$(rtld-entry)#' \
104 -e
's#@@rtld-base@@#$(rtld-base)#' $< >$@
106 $(objpfx
)ld.so
: $(objpfx
)librtld.so
$(objpfx
)rtld-ldscript
107 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
110 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
111 -Wl
,-rpath
=$(default-rpath
) $(LDFLAGS-rtld
) \
112 $(filter-out $(objpfx
)rtld-ldscript
,$^
)
115 $(objpfx
)ld.so
: $(objpfx
)librtld.so
116 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
119 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
120 -Wl
,-rpath
=$(default-rpath
) $^
124 # The dl code in the static libc needs a default library path.
125 CFLAGS-dl-support.c
= -D
'DEFAULT_RPATH="$(default-rpath)"'
127 ifneq (ld.so
,$(rtld-installed-name
))
128 # Make sure ld.so.1 exists in the build directory so we can link
130 $(objpfx
)$(rtld-installed-name
): $(objpfx
)ld.so
135 # Build a file mentioning all trustworthy directories to look for shared
136 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
137 # add directories to the list by defining $(user-defined-trusted-dirs)
138 # before starting make.
139 $(objpfx
)trusted-dirs.h
: Makefile
140 $(make-target-directory
)
141 (for
dir in
`echo "$(default-rpath) $(user-defined-trusted-dirs)" | \
143 echo
" \"$$dir\","; \
146 CPPFLAGS-dl-load.c
= -I
$(objdir
)/$(subdir
)
147 CFLAGS-dl-load.c
+= -Wno-uninitialized
149 # Specify the dependencies of libdl.so; its commands come from the generic
150 # rule to build a shared library.
151 $(objpfx
)libdl.so
: $(objpfx
)libdl_pic.a
$(common-objpfx
)libc.so
$(objpfx
)ld.so
153 $(inst_slibdir
)/$(rtld-version-installed-name
): $(objpfx
)ld.so
154 $(do-install-program
)
156 $(inst_slibdir
)/$(rtld-installed-name
): \
157 $(inst_slibdir
)/$(rtld-version-installed-name
)
160 ifneq ($(have-bash2
),yes
)
161 $(objpfx
)ldd
: ldd.sh.in
$(common-objpfx
)version.mk \
162 $(common-objpfx
)soversions.mk
$(common-objpfx
)config.make
163 sed
-e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
164 -e
's%@VERSION@%$(version)%g' < $< > $@.new
168 $(objpfx
)ldd
: ldd.bash.in
$(common-objpfx
)version.mk \
169 $(common-objpfx
)soversions.mk
$(common-objpfx
)config.make
170 sed
-e
's%@BASH@%$(BASH)%g' \
171 -e
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
172 -e
's%@VERSION@%$(version)%g' \
173 -e
's%@TEXTDOMAINDIR@%$(localedir)%g' < $< > $@.new
180 LDFLAGS-dl.so
= -Wl
,-dynamic-linker
,$(slibdir
)/$(rtld-installed-name
)
181 $(objpfx
)libdl.so
: $(objpfx
)eval.so