+2015-02-12 Roland McGrath <roland@hack.frob.com>
+
+ * Makeconfig (after-link): New variable.
+ (+link-pie, +link-pie-tests): Use it.
+ (+link-static, +link-static-tests): Likewise.
+ (+link, +link-tests): Likewise.
+ * Makerules (build-module, build-module-asneeded): Likewise.
+ (lib%.so, $(common-objpfx)libc.so, $(common-objpfx)linkobj/libc.so):
+ Likewise.
+ * elf/Makefile ($(objpfx)ld.so): Likewise.
+
2015-02-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.net>
[BZ #17965]
LDFLAGS-rtld += $(hashstyle-LDFLAGS)
endif
+# Command to run after every final link (executable or shared object).
+# This is invoked with $(call after-link,...), so it should operate on
+# the file $1. This can be set to do some sort of post-processing on
+# binaries, or to perform some sort of static sanity check.
+ifndef after-link
+after-link =
+endif
+
# Command for linking PIE programs with the C library.
ifndef +link-pie
+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
$(common-objpfx)libc% $(+postinit),$^) \
$(link-extra-libs)
+link-pie-after-libc = $(+postctorS) $(+postinit)
-+link-pie = $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) \
- $(+link-pie-after-libc)
-+link-pie-tests = $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) \
- $(link-libc-tests) $(+link-pie-after-libc)
+define +link-pie
+$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc)
+$(call after-link,$@)
+endef
+define +link-pie-tests
+$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+ $(+link-pie-after-libc)
+$(call after-link,$@)
+endef
endif
# Command for statically linking programs with the C library.
ifndef +link-static
$(common-objpfx)libc% $(+postinit),$^) \
$(link-extra-libs-static)
+link-static-after-libc = $(+postctorT) $(+postinit)
-+link-static = $(+link-static-before-libc) $(link-libc-static) \
- $(+link-static-after-libc)
-+link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
- $(+link-static-after-libc)
+define +link-static
+$(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc)
+$(call after-link,$@)
+endef
+define +link-static-tests
+$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
+$(call after-link,$@)
+endef
endif
# Commands for linking programs with the C library.
ifndef +link
$(common-objpfx)libc% $(+postinit),$^) \
$(link-extra-libs)
+link-after-libc = $(+postctor) $(+postinit)
-+link = $(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) \
- $(+link-after-libc)
-+link-tests = $(+link-before-libc) $(rtld-tests-LDFLAGS) \
- $(link-libc-tests) $(+link-after-libc)
+define +link
+$(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
+$(call after-link,$@)
+endef
+define +link-tests
+$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+ $(+link-after-libc)
+$(call after-link,$@)
+endef
else
+link = $(+link-static)
+link-tests = $(+link-static-tests)
# to be as similar as possible to a default link with an installed libc.
lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
$(build-shlib) $(link-libc-args)
+ $(call after-link,$@)
define build-shlib-helper
$(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
define build-module
$(build-module-helper) -o $@ $(shlib-lds-flags) \
$(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
+$(call after-link,$@)
endef
define build-module-asneeded
$(build-module-helper) -o $@ $(shlib-lds-flags) \
$(csu-objpfx)abi-note.o \
-Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
$(link-libc-args)
+$(call after-link,$@)
endef
build-module-helper-objlist = \
$(elf-objpfx)ld.so \
$(shlib-lds)
$(build-shlib)
+ $(call after-link,$@)
$(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
$(common-objpfx)linkobj/libc_pic.a \
$(elf-objpfx)ld.so \
$(shlib-lds)
$(build-shlib)
+ $(call after-link,$@)
ifeq ($(build-shared),yes)
$(common-objpfx)libc.so: $(common-objpfx)libc.map