]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Ignore __stack_chk_fail* in the rtld mapfile computation [BZ #7065]
authorNick Alcock <nick.alcock@oracle.com>
Mon, 26 Dec 2016 09:08:51 +0000 (10:08 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 26 Dec 2016 09:08:51 +0000 (10:08 +0100)
The previous commit prevented rtld itself from being built with
-fstack-protector, but this is not quite enough.  We identify which
objects belong in rtld via a test link and analysis of the resulting
mapfile.  That link is necessarily done against objects that are
stack-protected, so drags in __stack_chk_fail_local, __stack_chk_fail,
and all the libc and libio code they use.

To stop this happening, use --defsym in the test librtld.map-production
link to force the linker to predefine these two symbols (to 0, but it
could be to anything).  (In a real link, this would of course be
catastrophic, but these object files are never used for anything else.)

ChangeLog
elf/Makefile

index 82fc4e29d33185044ab896df128b911105069274..ae58d91110ac80f25e4694c53b2a5d083642faeb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-26  Nick Alcock  <nick.alcock@oracle.com>
+
+       [BZ #7065]
+       * elf/Makefile (dummy-stack-chk-fail): New.
+       (librtld.map): Use it.
+
 2016-12-26  Nick Alcock  <nick.alcock@oracle.com>
 
        [BZ #7065]
index 1e7d7240efaa6f5a89e5679ec8c94aab5048fbba..04d5f0721c532076fcb9569a9080c7d097692b38 100644 (file)
@@ -386,9 +386,22 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
 # are compiled with special flags, and puts these modules into rtld-libc.a
 # for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.
 
+# If the compiler can do SSP, build the mapfile with dummy __stack_chk_fail
+# and __stack_chk_fail_local symbols defined, to prevent the real things
+# being dragged into rtld even though rtld is never built with stack-
+# protection.
+
+ifeq ($(have-ssp),yes)
+dummy-stack-chk-fail := -Wl,--defsym='__stack_chk_fail=0' \
+                       -Wl,--defsym='__stack_chk_fail_local=0'
+else
+dummy-stack-chk-fail :=
+endif
+
 $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
        @-rm -f $@T
-       $(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
+       $(reloc-link) -o $@.o $(dummy-stack-chk-fail) \
+               '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
        rm -f $@.o
        mv -f $@T $@