On Tue, 2024-05-21 at 15:01 -0700, Andrii Nakryiko wrote: > On Tue, May 21, 2024 at 12:08 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > > > 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. > > True (unless application loaded .BTF.base as stand-alone BTF first, > but it's pretty advanced scenario) In this scenario .BTF.base would be relocated against .BTF.base, which is useless but not a failure. Maybe having the _opts() variant with additional degree of control (e.g. whether to ignore .BTF.base) is interesting as well. On the other hand, for such use-cases libbpf provides btf__parse() that accepts raw binary input, and application can extract ELF contents by itself. [...] > I see what you are saying about resolve_btfids needing the changes > either way, and that's true. But instead of adding (unnecessary, IMO) > -R argument, resolve_btfids should be able to detect .BTF.base section > presence and infer that this is distilled BTF case, and thus proceed > with ignoring `-B <vmlinux>` argument (we can even complain that `-B > vmlinux` is specified if distilled BTF is used, not sure. +1 for complaining about -B vmlinux when .BTF.base should be used.