On Fri, 2024-05-17 at 11:22 +0100, Alan Maguire wrote: (Also, please note that CI fails for this series). [...] > Also explored Eduard's suggestion of doing an implicit fallback > to checking for .BTF.base section in btf__parse() when it is > called to get base BTF. However while it is doable, it turned > out to be difficult operationally. Since fallback is implicit > we do not know the source of the BTF - was it from .BTF or > .BTF.base? In bpftool, we want to try first standalone BTF, > then split, then split with distilled base. Having a way > to explicitly request .BTF.base via btf__parse_opts() fits > that model better. I don't think this is the case. Here is what I mean: https://github.com/eddyz87/bpf/tree/distilled-base-alternative-parse-elf The branch above is a modification for btf_parse_elf() and a few reverts on top of this patch-set. I modified btf_parse_elf() to follow the logic below: | base_btf | .BTF.base | Effect | | specified? | present? | | |------------+-----------+---------------------------------------------| | no | no | load btf from .BTF | |------------+-----------+---------------------------------------------| | yes | no | load btf from .BTF using base_btf as base | | | | | |------------+-----------+---------------------------------------------| | no | yes | load btf from .BTF using .BTF.base as base | | | | | |------------+-----------+---------------------------------------------| | yes | yes | load btf from .BTF using .BTF.base as base, | | | | relocate btf against base_btf | When organized like that, there is no need to modify libbpf clients to work with split BTF. The `bpftool btf dump file ./btf_testmod.ko` would print non-relocated BTF. The `bpftool btf -B ../../../vmlinux dump file ./btf_testmod.ko` would print relocated BTF, no need for separate -R flag. Imo, loading split BTF w/o relocation when .BTF.base is present is interesting only for debug purposes and could be handled separately as all building blocks are present in the library. [...]