aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmese Revfy <re.emese@gmail.com>2016-06-26 11:38:20 -0400
committerKees Cook <keescook@chromium.org>2016-08-08 20:53:05 -0400
commitcaefd8c9a9fb06811e07bf3571e5d4450846b16a (patch)
tree675552008567fe3ce2cfe99a83ab1dce23e5e323
parent7040c83bfbaf2340d2f336dc7641ce909c8c2b4c (diff)
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>
-rw-r--r--scripts/Makefile.gcc-plugins3
-rw-r--r--scripts/gcc-plugins/Makefile9
2 files changed, 8 insertions, 4 deletions
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
index ffb928b9c74b..61f0e6db909b 100644
--- a/scripts/Makefile.gcc-plugins
+++ b/scripts/Makefile.gcc-plugins
@@ -21,7 +21,7 @@ ifdef CONFIG_GCC_PLUGINS
21 21
22 GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) 22 GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
23 23
24 export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN 24 export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR SANCOV_PLUGIN
25 25
26 ifneq ($(PLUGINCC),) 26 ifneq ($(PLUGINCC),)
27 # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. 27 # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
@@ -30,6 +30,7 @@ ifdef CONFIG_GCC_PLUGINS
30 30
31 KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) 31 KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
32 GCC_PLUGIN := $(gcc-plugin-y) 32 GCC_PLUGIN := $(gcc-plugin-y)
33 GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
33endif 34endif
34 35
35# If plugins aren't supported, abort the build before hard-to-read compiler 36# If plugins aren't supported, abort the build before hard-to-read compiler
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index ee0a75d2a1c7..8b29dc17c73c 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -12,15 +12,18 @@ else
12 export HOST_EXTRACXXFLAGS 12 export HOST_EXTRACXXFLAGS
13endif 13endif
14 14
15export GCCPLUGINS_DIR HOSTLIBS
16
17ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN)) 15ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
18 GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN)) 16 GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
19endif 17endif
20 18
21$(HOSTLIBS)-y := $(GCC_PLUGIN) 19export HOSTLIBS
20
21$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
22always := $($(HOSTLIBS)-y) 22always := $($(HOSTLIBS)-y)
23 23
24$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o)) 24$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o))
25 25
26subdir-y := $(GCC_PLUGIN_SUBDIR)
27subdir- += $(GCC_PLUGIN_SUBDIR)
28
26clean-files += *.so 29clean-files += *.so