about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2016-12-26 10:08:48 +0100
committerFlorian Weimer <fweimer@redhat.com>2016-12-26 10:08:48 +0100
commit995635f95b707488c23bba07be8016c9682d4045 (patch)
tree4d3e953045cede87bf3f416f396c9a3bb210e0f3
parent10c85e76c09716e744b4a41006718400b1eb2e84 (diff)
downloadglibc-995635f95b707488c23bba07be8016c9682d4045.tar.gz
glibc-995635f95b707488c23bba07be8016c9682d4045.tar.xz
glibc-995635f95b707488c23bba07be8016c9682d4045.zip
Compile the dynamic linker without stack protection [BZ #7065]
Also compile corresponding routines in the static libc.a with the same
flag.
-rw-r--r--ChangeLog10
-rw-r--r--elf/Makefile12
-rw-r--r--elf/rtld-Rules2
-rw-r--r--sysdeps/i386/Makefile2
4 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 64ccdf7ca0..82fc4e29d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,16 @@
 2016-12-26  Nick Alcock  <nick.alcock@oracle.com>
 
 	[BZ #7065]
+	Compile the dynamic linker without stack protection.
+	* elf/Makefile (elide-stack-protector): New.
+	(CFLAGS-.os): Use it, eliding $(all-rtld-routines).
+	(CFLAGS-.o, CFLAGS-.op): Likewise, but for $(elide-routines.os).
+	* elf/rtld-Rules (rtld-CFLAGS): Add $(no-stack-protector).
+	* sysdeps/i386/Makefile (rtld-CFLAGS): Use +=, not =.
+
+2016-12-26  Nick Alcock  <nick.alcock@oracle.com>
+
+	[BZ #7065]
 	* config.make.in (have-ssp, no-stack-protector): New.
 	* csu/Makefile (CFLAGS-.o, CFLAGS-.op, CFLAGS-.os): Use it.
 	* misc/Makefile (CFLAGS-sbrk.o): Likewise.
diff --git a/elf/Makefile b/elf/Makefile
index cd26e16558..1e7d7240ef 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -51,6 +51,18 @@ CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
 
+# Compile rtld itself without stack protection.
+# Also compile all routines in the static library that are elided from
+# the shared libc because they are in libc.a in the same way.
+
+define elide-stack-protector
+$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
+endef
+
+CFLAGS-.o += $(call elide-stack-protector,.o,$(elide-routines.os))
+CFLAGS-.op += $(call elide-stack-protector,.op,$(elide-routines.os))
+CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines))
+
 ifeq ($(unwind-find-fde),yes)
 routines += unwind-dw2-fde-glibc
 shared-only-routines += unwind-dw2-fde-glibc
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
index c1bb50687e..84d9387746 100644
--- a/elf/rtld-Rules
+++ b/elf/rtld-Rules
@@ -144,4 +144,6 @@ cpp-srcs-left := $(rtld-modules:%.os=%)
 lib := rtld
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 
+rtld-CFLAGS += $(no-stack-protector)
+
 endif
diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile
index e94f2cbd66..e30e1339f0 100644
--- a/sysdeps/i386/Makefile
+++ b/sysdeps/i386/Makefile
@@ -88,7 +88,7 @@ endif
 # the first 3 mm/xmm/ymm/zmm registers are used to pass vector parameters
 # which must be preserved.
 # With SSE disabled, ensure -fpmath is not set to use sse either.
-rtld-CFLAGS = -mno-sse -mno-mmx -mfpmath=387
+rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387
 ifeq ($(subdir),elf)
 CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
 		   $(rtld-CFLAGS))