On Tue, 2024-05-21 at 11:54 -0700, Andrii Nakryiko wrote: [...] > I'm probably leaning towards not doing automatic relocations in > btf__parse(), tbh. Distilled BTF is a rather special kernel-specific > feature, if we need to teach resolve_btfids and bpftool to do > something extra for that case (i.e., call another API for relocation, > if necessary), then it's fine, doesn't seems like a problem. My point is that with current implementation it does not even make sense to call btf__parse() for an ELF with distilled base, because it would fail. And selecting BTF encoding based on a few retries seems like a kludge if there is a simple way to check if distilled base has to be used (presence of the .BTF.base section). > Much worse is having to do some workarounds to prevent an API from > doing some undesired extra steps (like in resolve_btfids not wanting a > relocation). Orthogonality FTW, IMO. For resolve_btfids it is a bit different, imo. It does want some base: for in-tree modules it wants vmlinux, for out-of-tree it wants distilled base. So it has to be adjusted either way.