From 995635f95b707488c23bba07be8016c9682d4045 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Mon, 26 Dec 2016 10:08:48 +0100 Subject: Compile the dynamic linker without stack protection [BZ #7065] Also compile corresponding routines in the static libc.a with the same flag. --- elf/Makefile | 12 ++++++++++++ elf/rtld-Rules | 2 ++ 2 files changed, 14 insertions(+) (limited to 'elf') 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 -- cgit v1.2.3