blob: 1d16ca1b78c91e0c67418d2233bff9f376cc22df [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Kees Cook7ccb95e2018-07-11 17:38:52 -07002
Masahiro Yamada59f53852018-05-28 18:22:06 +09003gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so
Kees Cook7ccb95e2018-07-11 17:38:52 -07004gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \
5 += -DLATENT_ENTROPY_PLUGIN
Masahiro Yamada59f53852018-05-28 18:22:06 +09006ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
Kees Cook7ccb95e2018-07-11 17:38:52 -07007 DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
Emese Revfy6b90bd42016-05-24 00:09:38 +02008endif
Masahiro Yamada59f53852018-05-28 18:22:06 +09009export DISABLE_LATENT_ENTROPY_PLUGIN
10
Kees Cook7ccb95e2018-07-11 17:38:52 -070011gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
Masahiro Yamada59f53852018-05-28 18:22:06 +090012
Kees Cook7ccb95e2018-07-11 17:38:52 -070013gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so
14gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) \
15 += -fplugin-arg-structleak_plugin-verbose
Kees Cook81a56f62019-01-23 15:19:29 -080016gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF) \
17 += -fplugin-arg-structleak_plugin-byref
Kees Cook7ccb95e2018-07-11 17:38:52 -070018gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) \
19 += -fplugin-arg-structleak_plugin-byref-all
Brendan Higgins554afc32021-09-29 14:27:09 -070020ifdef CONFIG_GCC_PLUGIN_STRUCTLEAK
21 DISABLE_STRUCTLEAK_PLUGIN += -fplugin-arg-structleak_plugin-disable
22endif
23export DISABLE_STRUCTLEAK_PLUGIN
Kees Cook7ccb95e2018-07-11 17:38:52 -070024gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) \
25 += -DSTRUCTLEAK_PLUGIN
26
27gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so
28gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \
29 += -DRANDSTRUCT_PLUGIN
30gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) \
31 += -fplugin-arg-randomize_layout_plugin-performance-mode
32
Alexander Popov10e9ae92018-08-17 01:16:59 +030033gcc-plugin-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak_plugin.so
34gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
35 += -DSTACKLEAK_PLUGIN
36gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
37 += -fplugin-arg-stackleak_plugin-track-min-size=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE)
Alexander Popovfeee1b82020-06-24 15:33:29 +030038gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
39 += -fplugin-arg-stackleak_plugin-arch=$(SRCARCH)
Alexander Popov10e9ae92018-08-17 01:16:59 +030040ifdef CONFIG_GCC_PLUGIN_STACKLEAK
41 DISABLE_STACKLEAK_PLUGIN += -fplugin-arg-stackleak_plugin-disable
42endif
43export DISABLE_STACKLEAK_PLUGIN
44
Ard Biesheuvel189af462018-12-06 09:32:57 +010045gcc-plugin-$(CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK) += arm_ssp_per_task_plugin.so
46ifdef CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK
47 DISABLE_ARM_SSP_PER_TASK_PLUGIN += -fplugin-arg-arm_ssp_per_task_plugin-disable
48endif
49export DISABLE_ARM_SSP_PER_TASK_PLUGIN
50
Kees Cook7ccb95e2018-07-11 17:38:52 -070051# All the plugin CFLAGS are collected here in case a build target needs to
52# filter them out of the KBUILD_CFLAGS.
53GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
54# The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here.
55GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
56export GCC_PLUGINS_CFLAGS
57
58# Add the flags to the build!
Masahiro Yamada59f53852018-05-28 18:22:06 +090059KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
Kees Cook7ccb95e2018-07-11 17:38:52 -070060
61# All enabled GCC plugins are collected here for building below.
Masahiro Yamada59f53852018-05-28 18:22:06 +090062GCC_PLUGIN := $(gcc-plugin-y)
Kees Cook7ccb95e2018-07-11 17:38:52 -070063export GCC_PLUGIN