Re: [PATCH 1/2] kbuild: move shared library build rules to scripts/gcc-plugins/Makefile

From: Masahiro Yamada
Date: Fri Jul 31 2020 - 00:17:15 EST


On Thu, Jul 30, 2020 at 6:18 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote:
>
> On Wed, Jul 29, 2020 at 12:15:36PM +0900, Masahiro Yamada wrote:
> > The shared library build rules are currently implemented in
> > scripts/Makefile.host, but actually GCC-plugin is the only user of
> > them. Hence, they do not need to be treewide available.
>
> Are none of the VDSOs intending to use these rules?


Right.

GCC plugin .so files are compiled for the _host_ architecture.
vDSO .so files are compiled for the _target_ architecture.

They are built in completely different ways.



> > Move all the relevant build rules to scripts/gcc-plugins/Makefile.
> >
> > I also optimized the build steps so *.so is directly built from .c
> > because every upstream plugin is compiled from a single source file.
> >
> > I am still keeping the infrastructure to build a plugin from multiple
> > files because Kees suggested to do so in my previous attempt.
> > (https://lkml.org/lkml/2019/1/11/1107)
> >
> > If the plugin, foo.so, is compiled from two files foo.c and foo2.c,
> > then you can do like follows:
> >
> > foo-objs := foo.o foo2.o
> >
> > Single-file plugins do not need the *-objs notation.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
>
> But, yeah, sure!
>
> Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> Unrelated, but I do note that objtool maybe has the wrong indentation,
> path name reporting, and tool names (HOSTLD vs CC)?


Right.
Many people know it.


objtool opts out the Kbuild instructure.

I wrote a patch to make objtool join the Kbuild:
https://patchwork.kernel.org/patch/10839051/

The objtool maintainers refused to do this.






> ...
> HOSTCC scripts/asn1_compiler
> HOSTCC scripts/extract-cert
> HOSTCC scripts/genksyms/genksyms.o
> YACC scripts/genksyms/parse.tab.[ch]
> LEX scripts/genksyms/lex.lex.c
> DESCEND objtool
> HOSTCXX scripts/gcc-plugins/cyc_complexity_plugin.so
> HOSTCXX scripts/gcc-plugins/latent_entropy_plugin.so
> HOSTCXX scripts/gcc-plugins/structleak_plugin.so
> GENSEED scripts/gcc-plugins/randomize_layout_seed.h
> HOSTCXX scripts/gcc-plugins/stackleak_plugin.so
> HOSTCC scripts/genksyms/parse.tab.o
> HOSTCC scripts/genksyms/lex.lex.o
> HOSTCC /home/kees/src/linux-build/plugins/tools/objtool/fixdep.o
> HOSTLD arch/x86/tools/relocs
> HOSTLD /home/kees/src/linux-build/plugins/tools/objtool/fixdep-in.o
> LINK /home/kees/src/linux-build/plugins/tools/objtool/fixdep
> CC /home/kees/src/linux-build/plugins/tools/objtool/exec-cmd.o
> CC /home/kees/src/linux-build/plugins/tools/objtool/help.o
> CC /home/kees/src/linux-build/plugins/tools/objtool/weak.o
> ...
>
> --
> Kees Cook



--
Best Regards
Masahiro Yamada