Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sancov: Split plugin build from plugin CFLAGS

When the sancov_plugin is enabled, it gets added to gcc-plugin-y which
is used to populate both GCC_PLUGIN (for building the plugin) and
GCC_PLUGINS_CFLAGS (for enabling and options). Instead of adding sancov
to both and then removing it from GCC_PLUGINS_CFLAGS, create a separate
list, gcc-plugin-external-y, which is only added to GCC_PLUGIN.

This will also be used by the coming randstruct build changes.

Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220503205503.3054173-3-keescook@chromium.org

+8 -6
+8 -6
scripts/Makefile.gcc-plugins
··· 8 8 endif 9 9 export DISABLE_LATENT_ENTROPY_PLUGIN 10 10 11 - gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so 12 - 13 11 gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so 14 12 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) \ 15 13 += -fplugin-arg-structleak_plugin-verbose ··· 51 53 # All the plugin CFLAGS are collected here in case a build target needs to 52 54 # filter them out of the KBUILD_CFLAGS. 53 55 GCC_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. 55 - GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS)) 56 56 export GCC_PLUGINS_CFLAGS 57 57 58 58 # Add the flags to the build! 59 59 KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) 60 60 61 - # All enabled GCC plugins are collected here for building below. 62 - GCC_PLUGIN := $(gcc-plugin-y) 61 + # Some plugins are enabled outside of this Makefile, but they still need to 62 + # be included in GCC_PLUGIN so they can get built. 63 + gcc-plugin-external-$(CONFIG_GCC_PLUGIN_SANCOV) \ 64 + += sancov_plugin.so 65 + 66 + # All enabled GCC plugins are collected here for building in 67 + # scripts/gcc-scripts/Makefile. 68 + GCC_PLUGIN := $(gcc-plugin-y) $(gcc-plugin-external-y) 63 69 export GCC_PLUGIN