Re: [PATCH v5 bpf-next 4/9] bpf: Resolve BTF IDs in vmlinux image

Andrii Nakryiko
2020-07-07T00:39:07Z

On Fri, Jul 3, 2020 at 2:52 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Using BTF_ID_LIST macro to define lists for several helpers
> using BTF arguments.
>
> And running resolve_btfids on vmlinux elf object during linking,
> so the .BTF_ids section gets the IDs resolved.
>
> Acked-by: Andrii Nakryiko <andriin@fb.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> Makefile | 3 ++-
> kernel/trace/bpf_trace.c | 9 +++++++--
> net/core/filter.c | 9 +++++++--
> scripts/link-vmlinux.sh | 6 ++++++
> 4 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 8db4fd8097e0..def58d4f9ed7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -448,6 +448,7 @@ OBJSIZE = $(CROSS_COMPILE)size
> STRIP = $(CROSS_COMPILE)strip
> endif
> PAHOLE = pahole
> +RESOLVE_BTFIDS = $(srctree)/tools/bpf/resolve_btfids/resolve_btfids

Oh, this is probably wrong and why out-of-tree build fails. Why don't
you follow how this is done for objtool?

> LEX = flex
> YACC = bison
> AWK = awk
> @@ -510,7 +511,7 @@ GCC_PLUGINS_CFLAGS :=
> CLANG_FLAGS :=
>
> export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
> -export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
> +export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
> export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
> export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ
> export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE …