1 # Makefile for elf subdirectory of GNU C Library.
3 # Copyright (C) 1995, 1996 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
18 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 # Cambridge, MA 02139, USA.
23 headers
= elf.h elfclass.h link.h dlfcn.h
24 routines
= $(dl-routines
) dl-open dl-close dl-symbol dl-support
26 # The core dynamic linking functions are in libc for the static and
28 dl-routines
= $(addprefix dl-
,load lookup object reloc deps \
29 runtime error init fini
)
30 # But they are absent from the shared libc, because that code is in ld.so.
31 elide-routines.so
= $(dl-routines
) dl-support
33 # ld.so uses those routines, plus some special stuff for being the program
34 # interpreter and operating independent of libc.
35 rtld-routines
:= rtld
$(dl-routines
) dl-sysdep dl-minimal
36 distribute
= $(rtld-routines
:=.c
) dynamic-link.h do-rel.h dl-machine.h \
37 soinit.c sofini.c ldd.sh.in linux-compat.c
40 libdl-routines
:= dlopen dlclose dlsym dlerror dladdr
43 all: # Make this the default target; it will be defined in Rules.
47 ifeq (yes
,$(build-shared
))
48 extra-objs
= $(rtld-routines
:=.so
) soinit.so sofini.so
49 generated
= librtld.so dl-allobjs.so
50 install-others
= $(slibdir
)/$(rtld-installed-name
)
53 ifneq (,$(filter linux
% linux
,$(config-os
)))
54 extra-objs
+= linux-compat.so
55 install-others
+= $(slibdir
)/ld-linux.so
.1
56 lib-noranlib
: $(objpfx
)ld-linux.so
.1
63 ifeq (yes
, $(build-shared
))
64 # Make sure these things are built in the `make lib' pass so they can be used
65 # to run programs during the `make others' pass.
66 lib-noranlib
: $(objpfx
)$(rtld-installed-name
) \
67 $(addprefix $(objpfx
),$(extra-objs
))
70 # Command to link into a larger single relocatable object.
71 reloc-link
= $(LINK.o
) -nostdlib
-nostartfiles
-r
-o
$@
73 $(objpfx
)dl-allobjs.so
: $(rtld-routines
:%=$(objpfx
)%.so
)
76 # Link together the dynamic linker into a single relocatable object.
77 # We use this to produce both the ABI-compliant and Linux-compatible
78 # dynamic linker shared objects below.
79 $(objpfx
)librtld.so
: $(objpfx
)dl-allobjs.so \
80 $(patsubst %,$(common-objpfx
)lib
%_pic.a
,\
81 c
$(LDLIBS-c.so
:-l
%=%))
82 $(reloc-link
) '-Wl,-(' $^
-lgcc
'-Wl,-)'
84 $(objpfx
)ld.so
: $(objpfx
)librtld.so
85 $(rtld-link
) -Wl
,-soname
=$(rtld-installed-name
)
86 $(objpfx
)ld-linux.so
.1: $(objpfx
)librtld.so
87 $(rtld-link
) -Wl
,-soname
=ld-linux.so
.1
90 $(LINK.o
) -nostdlib
-nostartfiles
-shared
-o
$@ \
91 -Wl
,-rpath
=$(default-rpath
) $^
94 # The dl code in the static libc needs a default library path.
95 CFLAGS-dl-support.c
= -D
'DEFAULT_RPATH="$(default-rpath)"'
97 ifneq (ld.so
, $(rtld-installed-name
))
98 # Make sure ld-gnu.so.1 exists in the build directory so we can link
100 $(objpfx
)$(rtld-installed-name
): $(objpfx
)ld.so
105 # The Linux-compatible dynamic linker shared object is just the same
106 # with one object file of compatibility initialization code added.
107 $(objpfx
)ld-linux.so
.1: $(objpfx
)linux-compat.so
110 # Specify the dependencies of libdl.so; its commands come from the generic
111 # rule to build a shared library.
112 $(objpfx
)libdl.so
: $(objpfx
)libdl_pic.a
$(common-objpfx
)libc.so
$(objpfx
)ld.so
114 $(slibdir
)/$(rtld-installed-name
): $(objpfx
)ld.so
; $(do-install-program
)
115 $(slibdir
)/ld-linux.so
.1: $(objpfx
)ld-linux.so
.1; $(do-install-program
)
117 $(objpfx
)ldd
: ldd.sh.in Makefile
118 sed
's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' < $< > $@.new