|
|
e354a5 |
commit abcc039d2e26b3c9c723d6419e086753a791b3d5
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Fri Feb 7 20:06:32 2020 +0100
|
|
|
e354a5 |
|
|
|
e354a5 |
elf: Introduce the rtld-stubbed-symbols makefile variable
|
|
|
e354a5 |
|
|
|
e354a5 |
This generalizes a mechanism used for stack-protector support, so
|
|
|
e354a5 |
that it can be applied to other symbols if required.
|
|
|
e354a5 |
|
|
|
e354a5 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
e354a5 |
index 4ab73dc48d9ac126..a1ea44f231d8cec5 100644
|
|
|
e354a5 |
--- a/elf/Makefile
|
|
|
e354a5 |
+++ b/elf/Makefile
|
|
|
e354a5 |
@@ -474,21 +474,25 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
|
|
|
e354a5 |
# are compiled with special flags, and puts these modules into rtld-libc.a
|
|
|
e354a5 |
# for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
|
|
|
e354a5 |
|
|
|
e354a5 |
-# If the compiler can do SSP, build the mapfile with dummy __stack_chk_fail
|
|
|
e354a5 |
-# and __stack_chk_fail_local symbols defined, to prevent the real things
|
|
|
e354a5 |
-# being dragged into rtld even though rtld is never built with stack-
|
|
|
e354a5 |
-# protection.
|
|
|
e354a5 |
+# These symbols need to be stubbed out during symbol discovery because
|
|
|
e354a5 |
+# their implementation is provided differently in rtld, and the symbol
|
|
|
e354a5 |
+# discovery mechanism is not compatible with the libc implementation
|
|
|
e354a5 |
+# when compiled for libc.
|
|
|
e354a5 |
+rtld-stubbed-symbols =
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+# The GCC arguments that implement $(rtld-stubbed-symbols).
|
|
|
e354a5 |
+rtld-stubbed-symbols-args = \
|
|
|
e354a5 |
+ $(patsubst %,-Wl$(comma)--defsym=%=0, $(rtld-stubbed-symbols))
|
|
|
e354a5 |
|
|
|
e354a5 |
ifeq ($(have-ssp),yes)
|
|
|
e354a5 |
-dummy-stack-chk-fail := -Wl,--defsym='__stack_chk_fail=0' \
|
|
|
e354a5 |
- -Wl,--defsym='__stack_chk_fail_local=0'
|
|
|
e354a5 |
-else
|
|
|
e354a5 |
-dummy-stack-chk-fail :=
|
|
|
e354a5 |
+# rtld is not built with the stack protector, so these references will
|
|
|
e354a5 |
+# go away in the rebuilds.
|
|
|
e354a5 |
+rtld-stubbed-symbols += __stack_chk_fail __stack_chk_fail_local
|
|
|
e354a5 |
endif
|
|
|
e354a5 |
|
|
|
e354a5 |
$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
|
|
|
e354a5 |
@-rm -f $@T
|
|
|
e354a5 |
- $(reloc-link) -o $@.o $(dummy-stack-chk-fail) \
|
|
|
e354a5 |
+ $(reloc-link) -o $@.o $(rtld-stubbed-symbols-args) \
|
|
|
e354a5 |
'-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
|
|
|
e354a5 |
rm -f $@.o
|
|
|
e354a5 |
mv -f $@T $@
|