@@ -686,55 +686,11 @@ ifneq ($(CONFIG_FRAME_WARN),0)
686
686
KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
687
687
endif
688
688
689
- # This selects the stack protector compiler flag. Testing it is delayed
690
- # until after .config has been reprocessed, in the prepare-compiler-check
691
- # target.
692
- ifdef CONFIG_CC_STACKPROTECTOR_AUTO
693
- stackp-flag := $(call cc-option,-fstack-protector-strong,$(call cc-option,-fstack-protector) )
694
- stackp-name := AUTO
695
- else
696
- ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
697
- stackp-flag := -fstack-protector
698
- stackp-name := REGULAR
699
- else
700
- ifdef CONFIG_CC_STACKPROTECTOR_STRONG
701
- stackp-flag := -fstack-protector-strong
702
- stackp-name := STRONG
703
- else
704
- # If either there is no stack protector for this architecture or
705
- # CONFIG_CC_STACKPROTECTOR_NONE is selected, we're done, and $(stackp-name)
706
- # is empty, skipping all remaining stack protector tests.
707
- #
708
- # Force off for distro compilers that enable stack protector by default.
709
- KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
710
- endif
711
- endif
712
- endif
713
- # Find arch-specific stack protector compiler sanity-checking script.
714
- ifdef stackp-name
715
- ifneq ($(stackp-flag ) ,)
716
- stackp-path := $(srctree ) /scripts/gcc-$(SRCARCH ) _$(BITS ) -has-stack-protector.sh
717
- stackp-check := $(wildcard $(stackp-path ) )
718
- # If the wildcard test matches a test script, run it to check functionality.
719
- ifdef stackp-check
720
- ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
721
- stackp-broken := y
722
- endif
723
- endif
724
- ifndef stackp-broken
725
- # If the stack protector is functional, enable code that depends on it.
726
- KBUILD_CPPFLAGS += -DCONFIG_CC_STACKPROTECTOR
727
- # Either we've already detected the flag (for AUTO) or we'll fail the
728
- # build in the prepare-compiler-check rule (for specific flag).
729
- KBUILD_CFLAGS += $(stackp-flag )
730
- else
731
- # We have to make sure stack protector is unconditionally disabled if
732
- # the compiler is broken (in case we're going to continue the build in
733
- # AUTO mode).
734
- KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
735
- endif
736
- endif
737
- endif
689
+ stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
690
+ stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector
691
+ stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong
692
+
693
+ KBUILD_CFLAGS += $(stackp-flags-y )
738
694
739
695
ifeq ($(cc-name ) ,clang)
740
696
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
@@ -1118,7 +1074,7 @@ endif
1118
1074
# prepare2 creates a makefile if using a separate output directory.
1119
1075
# From this point forward, .config has been reprocessed, so any rules
1120
1076
# that need to depend on updated CONFIG_* values can be checked here.
1121
- prepare2 : prepare3 prepare-compiler-check outputmakefile asm-generic
1077
+ prepare2 : prepare3 outputmakefile asm-generic
1122
1078
1123
1079
prepare1 : prepare2 $(version_h ) $(autoksyms_h ) include/generated/utsrelease.h \
1124
1080
include /config/auto.conf
@@ -1144,43 +1100,6 @@ uapi-asm-generic:
1144
1100
PHONY += prepare-objtool
1145
1101
prepare-objtool : $(objtool_target )
1146
1102
1147
- # Check for CONFIG flags that require compiler support. Abort the build
1148
- # after .config has been processed, but before the kernel build starts.
1149
- #
1150
- # For security-sensitive CONFIG options, we don't want to fallback and/or
1151
- # silently change which compiler flags will be used, since that leads to
1152
- # producing kernels with different security feature characteristics
1153
- # depending on the compiler used. (For example, "But I selected
1154
- # CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!")
1155
- PHONY += prepare-compiler-check
1156
- prepare-compiler-check : FORCE
1157
- # Make sure compiler supports requested stack protector flag.
1158
- ifdef stackp-name
1159
- # Warn about CONFIG_CC_STACKPROTECTOR_AUTO having found no option.
1160
- ifeq ($(stackp-flag),)
1161
- @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
1162
- Compiler does not support any known stack-protector >&2
1163
- else
1164
- # Fail if specifically requested stack protector is missing.
1165
- ifeq ($(call cc-option, $(stackp-flag)),)
1166
- @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
1167
- $(stackp-flag) not supported by compiler >&2 && exit 1
1168
- endif
1169
- endif
1170
- endif
1171
- # Make sure compiler does not have buggy stack-protector support. If a
1172
- # specific stack-protector was requested, fail the build, otherwise warn.
1173
- ifdef stackp-broken
1174
- ifeq ($(stackp-name),AUTO)
1175
- @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
1176
- $(stackp-flag ) available but compiler is broken : disabling >&2
1177
- else
1178
- @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
1179
- $(stackp-flag) available but compiler is broken >&2 && exit 1
1180
- endif
1181
- endif
1182
- @:
1183
-
1184
1103
# Generate some files
1185
1104
# ---------------------------------------------------------------------------
1186
1105
0 commit comments