]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
kbuild,bpf: Add module-specific pahole flags for distilled base BTF
authorAlan Maguire <alan.maguire@oracle.com>
Thu, 20 Jun 2024 09:17:32 +0000 (10:17 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 21 Jun 2024 21:45:07 +0000 (14:45 -0700)
Support creation of module BTF along with distilled base BTF;
the latter is stored in a .BTF.base ELF section and supplements
split BTF references to base BTF with information about base types,
allowing for later relocation of split BTF with a (possibly
changed) base.  resolve_btfids detects the presence of a .BTF.base
section and will use it instead of the base BTF it is passed in
BTF id resolution.

Modules will be built with a distilled .BTF.base section for external
module build, i.e.

make -C. -M=path2/module

...while in-tree module build as part of a normal kernel build will
not generate distilled base BTF; this is because in-tree modules
change with the kernel and do not require BTF relocation for the
running vmlinux.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20240620091733.1967885-6-alan.maguire@oracle.com
scripts/Makefile.btf
scripts/Makefile.modfinal

index 2597e3d4d6e0118403e4f30f5329ef1ed0a08829..b75f09f3f4248d86b553da944f3e5fb7119e3cf4 100644 (file)
@@ -21,8 +21,13 @@ else
 # Switch to using --btf_features for v1.26 and later.
 pahole-flags-$(call test-ge, $(pahole-ver), 126)  = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
 
+ifneq ($(KBUILD_EXTMOD),)
+module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base
+endif
+
 endif
 
 pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE)         += --lang_exclude=rust
 
 export PAHOLE_FLAGS := $(pahole-flags-y)
+export MODULE_PAHOLE_FLAGS := $(module-pahole-flags-y)
index 3bec9043e4f38066e814a2d3765e886c0e17cf8d..1fa98b5e952b4f943a8605c7348d585b8ef5d9c4 100644 (file)
@@ -41,7 +41,7 @@ quiet_cmd_btf_ko = BTF [M] $@
        if [ ! -f vmlinux ]; then                                       \
                printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
        else                                                            \
-               LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
+               LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE_FLAGS) --btf_base vmlinux $@; \
                $(RESOLVE_BTFIDS) -b vmlinux $@;                        \
        fi;