Compile the dynamic linker without stack protection [BZ #7065]

Also compile corresponding routines in the static libc.a with the same
flag.
This commit is contained in:
Nick Alcock 2016-12-26 10:08:48 +01:00 committed by Florian Weimer
parent 10c85e76c0
commit 995635f95b
4 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,13 @@
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]

View File

@ -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

View File

@ -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

View File

@ -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))