History

kbuild,bpf: Add module-specific pahole flags for distilled base BTF

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.

Alan Maguire committed 2 years ago

Commit 46fb0b61 parent 8646db22 files · +6 −1Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/Makefile.btf +5 −0
  2. scripts/Makefile.modfinal +1 −1
scripts/Makefile.btf+5−0
@@ -21,8 +21,13 @@ else · 20 unmodified lines
21# Switch to using --btf_features for v1.26 and later.21# Switch to using --btf_features for v1.26 and later.
22pahole-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_kfuncs22pahole-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
23 23
24ifneq ($(KBUILD_EXTMOD),)
25module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base
26endif
27
24endif28endif
25 29
26pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust30pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust
27 31
28export PAHOLE_FLAGS := $(pahole-flags-y)32export PAHOLE_FLAGS := $(pahole-flags-y)
33export MODULE_PAHOLE_FLAGS := $(module-pahole-flags-y)
scripts/Makefile.modfinal+1−1
@@ -41,7 +41,7 @@ quiet_cmd_btf_ko = BTF [M] $@ · 40 unmodified lines
41 if [ ! -f vmlinux ]; then \41 if [ ! -f vmlinux ]; then \
42 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \42 printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
43 else \43 else \
44 LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \44 LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) $(MODULE_PAHOLE_FLAGS) --btf_base vmlinux $@; \
45 $(RESOLVE_BTFIDS) -b vmlinux $@; \45 $(RESOLVE_BTFIDS) -b vmlinux $@; \
46 fi;46 fi;
47 47