From: Nick Alcock Date: Mon, 26 Dec 2016 09:08:48 +0000 (+0100) Subject: Compile the dynamic linker without stack protection [BZ #7065] X-Git-Tag: glibc-2.25~154 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=995635f95b707488c23bba07be8016c9682d4045;p=thirdparty%2Fglibc.git Compile the dynamic linker without stack protection [BZ #7065] Also compile corresponding routines in the static libc.a with the same flag. --- diff --git a/ChangeLog b/ChangeLog index 64ccdf7ca09..82fc4e29d33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2016-12-26 Nick Alcock + + [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 [BZ #7065] diff --git a/elf/Makefile b/elf/Makefile index cd26e165585..1e7d7240efa 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 c1bb50687e4..84d9387746a 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 e94f2cbd663..e30e1339f05 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))