[kernel-hardening] Re: [PATCH v5 2/5] GCC plugin infrastructure

Emese Revfy
2016-03-14T20:52:17Z

On Fri, 11 Mar 2016 15:25:19 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> Maybe scripts/gcc-plugins/ is better than tools/gcc ?
>
> In the directory "scripts/", we have several tools used during
> building the kernel image.
> We have some optional programs in the directory "tools/", which are not used
> for building the kernel image itself.
>
> Please correct me if I am wrong.

I think scripts isn't the right place because there are tools there which don't get used
during the building of vmlinux (e.g., coccinelle, checkpatch).
The scripts name also doesn't describe gcc plugins well. Plugins take part in the image building process
in a different way than these tools and scripts do.
Since there doesn't seen to be a good place for compiler plugins, maybe we should create a new toplevel directory
called "build". Compiler plugins and other existing build tools could live there. What do you think?

> > +ccflags-y := $(GCC_PLUGINS_CFLAGS)
> > +asflags-y := $(GCC_PLUGINS_AFLAGS)
> > +
> > obj-y := main.o version.o mounts.o
> > ifneq ($(CONFIG_BLK_DEV_INITRD),y)
> > obj-y += noinitramfs.o
> > diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
> > new file mode 100644
> > index 0000000..7c85bf2
> > --- /dev/null
> > +++ b/scripts/Makefile.gcc-plugins
> > @@ -0,0 +1,28 @@
> > +ifdef CONFIG_GCC_PLUGINS
> > +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
> > +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
> > +else
> > +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
> > +endif
>
> The difference is only the first argument.
>
> Can you make it as follows?
>
> __HOSTCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
>
> PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh
> "$(__HOSTCC)" "$(HOSTCXX)" "$(CC)")
>
>
> I did not come up with a good name for __HOSTCC.
> Feel free to replace it with a better one.

Sure, I will do it.

--
Emese