mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
Build libc-start with stack protector for SHARED
This does not change the emitted code since __libc_start_main does not return, but is important for formal flags compliance. This also cleans up the cosmetic inconsistency in the stack protector flags in csu, especially the incorrect value of STACK_PROTECTOR_LEVEL. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
941ea10f80
commit
8b8f13b60d
@ -856,6 +856,14 @@ ifneq ($(stack-protector),)
|
||||
+stack-protector=$(stack-protector)
|
||||
endif
|
||||
|
||||
# Some routines are unsafe to build with stack-protection since they're called
|
||||
# before the stack check guard is set up. Provide a way to disable stack
|
||||
# protector. The first argument is the extension (.o, .os, .oS) and the second
|
||||
# is a list of routines that this path should be applied to.
|
||||
define elide-stack-protector
|
||||
$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
|
||||
endef
|
||||
|
||||
# This is the program that generates makefile dependencies from C source files.
|
||||
# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
|
||||
# targets for headers so that removed headers don't break the build.
|
||||
|
22
csu/Makefile
22
csu/Makefile
@ -45,18 +45,20 @@ install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
|
||||
# code is compiled with special flags.
|
||||
tests =
|
||||
|
||||
CFLAGS-.o += $(no-stack-protector)
|
||||
CFLAGS-.op += $(no-stack-protector)
|
||||
CFLAGS-.os += $(no-stack-protector)
|
||||
|
||||
# Dummy object not actually used for anything. It is linked into
|
||||
# crt1.o nevertheless, which in turn is statically linked into
|
||||
# static-reloc.os is a dummy object not actually used for anything. It is
|
||||
# linked into crt1.o nevertheless, which in turn is statically linked into
|
||||
# applications, so that build flags matter.
|
||||
# See <https://sourceware.org/ml/libc-alpha/2018-07/msg00101.html>.
|
||||
# NB: Using $(stack-protector) in this way causes a wrong definition
|
||||
# STACK_PROTECTOR_LEVEL due to the preceding $(no-stack-protector),
|
||||
# but it does not matter for this source file.
|
||||
CFLAGS-static-reloc.os += $(stack-protector)
|
||||
#
|
||||
# libc-start.os is safe to be built with stack protector since
|
||||
# __libc_start_main is called after stack canary setup is done.
|
||||
ssp-safe.os = static-reloc libc-start
|
||||
|
||||
CFLAGS-.o += $(call elide-stack-protector,.o,$(routines))
|
||||
CFLAGS-.op += $(call elide-stack-protector,.op,$(routines))
|
||||
CFLAGS-.oS += $(call elide-stack-protector,.oS,$(routines))
|
||||
CFLAGS-.os += $(call elide-stack-protector,.os,$(filter-out \
|
||||
$(ssp-safe.os),$(routines)))
|
||||
|
||||
ifeq (yes,$(build-shared))
|
||||
extra-objs += S$(start-installed-name) gmon-start.os
|
||||
|
@ -83,10 +83,6 @@ endif
|
||||
# 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))
|
||||
|
Loading…
Reference in New Issue
Block a user