gcc-plugins: Add support for plugin subdirectories

This adds support for building more complex gcc plugins that live in a
subdirectory instead of just in a single source file.

Reported-by: PaX Team <pageexec@freemail.hu>
Signed-off-by: Emese Revfy <re.emese@gmail.com>
[kees: clarified commit message]
Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Emese Revfy 2016-06-26 17:38:20 +02:00 committed by Kees Cook
parent 7040c83bfb
commit caefd8c9a9
2 changed files with 8 additions and 4 deletions

View File

@ -21,7 +21,7 @@ ifdef CONFIG_GCC_PLUGINS
GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR SANCOV_PLUGIN
ifneq ($(PLUGINCC),) ifneq ($(PLUGINCC),)
# SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
@ -30,6 +30,7 @@ ifdef CONFIG_GCC_PLUGINS
KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
GCC_PLUGIN := $(gcc-plugin-y) GCC_PLUGIN := $(gcc-plugin-y)
GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
endif endif
# If plugins aren't supported, abort the build before hard-to-read compiler # If plugins aren't supported, abort the build before hard-to-read compiler

View File

@ -12,15 +12,18 @@ else
export HOST_EXTRACXXFLAGS export HOST_EXTRACXXFLAGS
endif endif
export GCCPLUGINS_DIR HOSTLIBS
ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN)) ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN)) GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
endif endif
$(HOSTLIBS)-y := $(GCC_PLUGIN) export HOSTLIBS
$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
always := $($(HOSTLIBS)-y) always := $($(HOSTLIBS)-y)
$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o)) $(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o))
subdir-y := $(GCC_PLUGIN_SUBDIR)
subdir- += $(GCC_PLUGIN_SUBDIR)
clean-files += *.so clean-files += *.so