On Tue, May 28, 2024 at 5:25 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote: > > 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@xxxxxxxxxx> > --- > scripts/Makefile.btf | 5 +++++ > scripts/Makefile.modfinal | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf > index bca8a8f26ea4..191b4903e864 100644 > --- a/scripts/Makefile.btf > +++ b/scripts/Makefile.btf > @@ -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 > > +ifneq ($(KBUILD_EXTMOD),) > +module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base Remind me, please. What's the state of pahole patches? Are they waiting on these libbpf changes to land first, right? > +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) > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal > index 79fcf2731686..6d2b8da98ee5 100644 > --- a/scripts/Makefile.modfinal > +++ b/scripts/Makefile.modfinal > @@ -39,7 +39,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; > > -- > 2.31.1 >