Add missing dependency for preloadtest binary.
[glibc.git] / elf / Makefile
blob185cd48fec76f4386910f5f32ad7146958579d7b
1 # Copyright (C) 1995, 1996, 1997, 1998, 1999 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.
21 subdir := elf
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
28 # profiled libraries.
29 dl-routines = $(addprefix dl-,load cache lookup object reloc deps \
30 runtime error init fini debug misc \
31 version profile)
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.bash.in eval.c \
40 genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
41 dl-librecon.h interp.c sln.c dl-origin.h hp-timing.h \
42 testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
43 testobj6.c testobj1_1.c failobj.c
45 include ../Makeconfig
47 extra-libs = libdl
48 extra-libs-others = $(extra-libs)
49 libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
50 ifeq ($(versioning),yes)
51 libdl-routines += dlopenold
52 libdl-shared-only-routines := dlopenold
53 endif
55 before-compile = $(objpfx)trusted-dirs.h
57 ifeq ($(versioning),yes)
58 ld-map = $(common-objpfx)libc.map
59 endif
61 ifeq (yes,$(build-shared))
62 extra-objs = $(rtld-routines:=.os) soinit.os sofini.os eval.os interp.os
63 generated = librtld.os dl-allobjs.os ld.so trusted-dirs.h trusted-dirs.st
64 install-others = $(inst_slibdir)/$(rtld-installed-name)
65 install-bin = ldd
66 generated += ldd
67 endif
69 others = sprof sln
70 install-bin += sprof
71 others-static = sln
72 install-rootsbin = sln
74 ifeq (yes,$(has-ldconfig))
75 others-static += ldconfig
76 others += ldconfig
77 install-rootsbin += ldconfig
78 endif
80 tests = loadtest restest1 preloadtest loadfail
82 include ../Rules
85 ifeq (yes,$(build-shared))
86 # Make sure these things are built in the `make lib' pass so they can be used
87 # to run programs during the `make others' pass.
88 lib-noranlib: $(objpfx)$(rtld-installed-name) \
89 $(addprefix $(objpfx),$(extra-objs))
90 endif
92 # Command to link into a larger single relocatable object.
93 reloc-link = $(LINK.o) -nostdlib -nostartfiles -r -o $@
95 $(objpfx)dl-allobjs.os: $(rtld-routines:%=$(objpfx)%.os)
96 $(reloc-link) $^
98 # Link together the dynamic linker into a single relocatable object.
99 $(objpfx)librtld.os: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
100 $(reloc-link) '-Wl,-(' $^ -lgcc '-Wl,-)'
102 # Do we need a linker script?
103 rtld-ldscript-in := $(firstword $(wildcard $(+sysdep_dirs:%=%/rtld-ldscript.in)))
105 ifneq (,$(rtld-ldscript-in))
106 rtld-ldscript = $(objpfx)rtld-ldscript
107 generated += rtld-ldscript
109 LDFLAGS-rtld = -T $(rtld-ldscript)
110 before-compile += $(rtld-ldscript)
112 rtld-parms = $(wildcard $(+sysdep_dirs:%=%/rtld-parms))
113 include $(rtld-parms)
115 $(rtld-ldscript): $(rtld-ldscript-in) $(rtld-parms)
116 sed -e 's#@@rtld-oformat@@#$(rtld-oformat)#' \
117 -e 's#@@rtld-arch@@#$(rtld-arch)#' \
118 -e 's#@@rtld-entry@@#$(rtld-entry)#' \
119 -e 's#@@rtld-base@@#$(rtld-base)#' $< >$@
120 endif
122 $(objpfx)ld.so: $(objpfx)librtld.os $(addprefix $(objpfx),$(rtld-ldscript)) \
123 $(ld-map)
124 $(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld) \
125 $(filter-out $(rtld-ldscript) $(map-file),$^) \
126 $(load-map-file) -Wl,-soname=$(rtld-installed-name)
128 # interp.c exists just to get this string into the libraries.
129 CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
131 ifneq (ld.so,$(rtld-installed-name))
132 # Make sure ld.so.1 exists in the build directory so we can link
133 # against it.
134 $(objpfx)$(rtld-installed-name): $(objpfx)ld.so
135 rm -f $@
136 ln -s $(<F) $@
137 generated += $(rtld-installed-name)
138 endif
140 # Build a file mentioning all trustworthy directories to look for shared
141 # libraries when using LD_LIBRARY_PATH in a setuid program. The user can
142 # add directories to the list by defining $(user-defined-trusted-dirs)
143 # before starting make.
144 $(objpfx)trusted-dirs.h: $(objpfx)trusted-dirs.st; @:
145 $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
146 $(make-target-directory)
147 dirs="$(subst :, ,$(default-rpath) $(user-defined-trusted-dirs))"; \
148 for dir in $$dirs; do \
149 echo " \"$$dir/\","; \
150 done > ${@:st=T}
151 $(move-if-change) ${@:st=T} ${@:st=h}
152 touch $@
153 CPPFLAGS-dl-load.c = -I$(objpfx).
154 CFLAGS-dl-load.c += -Wno-uninitialized
156 # Specify the dependencies of libdl.so; its commands come from the generic
157 # rule to build a shared library.
158 $(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
160 $(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
161 $(do-install-program)
163 $(inst_slibdir)/$(rtld-installed-name): \
164 $(inst_slibdir)/$(rtld-version-installed-name)
165 $(make-shlib-link)
167 # Special target called by parent to install just the dynamic linker.
168 .PHONY: ldso_install
169 ldso_install: $(inst_slibdir)/$(rtld-installed-name)
172 common-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
173 -e 's%@VERSION@%$(version)%g'
174 sh-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%/bin/sh%g;s/\$$"/"/g'
175 bash-ldd-rewrite = $(common-ldd-rewrite) -e 's%@BASH@%$(BASH)%g' \
176 -e 's%@TEXTDOMAINDIR@%$(localedir)%g'
178 ifneq ($(have-bash2),yes)
179 ldd-shell = sh
180 else
181 ldd-shell = bash
182 endif
184 ifeq ($(ldd-rewrite-script),no)
185 define gen-ldd
186 sed $($(ldd-shell)-ldd-rewrite) < $< > $@.new
187 endef
188 else
189 define gen-ldd
190 sed $($(ldd-shell)-ldd-rewrite) < $< | sed -f $(ldd-rewrite-script) > $@.new
191 endef
192 endif
194 $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
195 $(common-objpfx)config.make
196 $(gen-ldd)
197 chmod 555 $@.new
198 mv -f $@.new $@
201 ifeq ($(build-shared),yes)
202 $(objpfx)sprof: $(objpfx)libdl.so$(libdl.so-version)
203 else
204 $(objpfx)sprof: $(objpfx)libdl.a
205 endif
207 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
208 testobj1_1 failobj
209 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
210 generated += $(test-modules)
212 LDLIBS-testobj1.so = -ldl
213 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so
214 LDLIBS-testobj1_1.so = $(objpfx)testobj1.so
215 $(objpfx)testobj2.so: $(objpfx)testobj1.so
216 LDLIBS-testobj2.so = $(objpfx)testobj1.so -ldl
217 LDLIBS-testobj3.so = -ldl
218 LDLIBS-testobj4.so = -ldl
219 LDLIBS-testobj5.so = -ldl
220 LDLIBS-testobj6.so = -ldl
221 LDLIBS-failobj.so = $(objpfx)testobj6.so
223 $(test-modules): $(objpfx)%.so: $(objpfx)%.os
224 $(build-module)
226 $(objpfx)loadtest: $(objpfx)libdl.so
227 LDFLAGS-loadtest = -rdynamic
229 $(objpfx)loadtest.out: $(test-modules)
231 $(objpfx)restest1: $(objpfx)libdl.so
232 LDFLAGS-restest1 = -rdynamic $(objpfx)testobj1.so $(objpfx)testobj1_1.so
234 $(objpfx)restest1.out: $(test-modules)
236 $(objpfx)preloadtest: $(objpfx)testobj6.so
237 $(objpfx)preloadtest.out: $(test-modules)
238 LDFLAGS-preloadtest = -rdynamic
239 preloadtest-ENV = LD_PRELOAD=testobj1.so:testobj2.so:testobj3.so:testobj4.so:testobj5.so
241 $(objpfx)loadfail: $(objpfx)libdl.so
242 LDFLAGS-loadfail = -rdynamic
244 $(objpfx)loadfile.out: $(objpfx)failobj.so
246 # muwahaha
248 LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
249 $(objpfx)libdl.so: $(objpfx)eval.os