summaryrefslogtreecommitdiff
path: root/elf
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 /elf
parent10c85e76c09716e744b4a41006718400b1eb2e84 (diff)
downloadglibc-995635f95b707488c23bba07be8016c9682d4045.tar.gz
Compile the dynamic linker without stack protection [BZ #7065]
Also compile corresponding routines in the static libc.a with the same flag.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile12
-rw-r--r--elf/rtld-Rules2
2 files changed, 14 insertions, 0 deletions
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