Re: [PATCH bpf-next v2 04/13] resolve_btfids: Introduce finalize_btf() step

From: Eduard Zingerman

Date: Tue Jan 20 2026 - 13:19:13 EST


On Tue, 2026-01-20 at 10:11 -0800, Ihor Solodrai wrote:

[...]

> > > @@ -1099,12 +1116,22 @@ int main(int argc, const char **argv)
> > > if (obj.efile.idlist_shndx == -1 ||
> > > obj.efile.symbols_shndx == -1) {
> > > pr_debug("Cannot find .BTF_ids or symbols sections, skip symbols resolution\n");
> > > - goto dump_btf;
> > > + resolve_btfids = false;
> > > }
> > >
> > > - if (symbols_collect(&obj))
> > > + if (resolve_btfids)
> > > + if (symbols_collect(&obj))
> > > + goto out;
> >
> > Nit: check obj.efile.idlist_shndx and obj.efile.symbols_shndx inside symbols_collect()?
> > To avoid resolve_btfids flag and the `goto dump_btf;` below.
>
> Hi Eduard, thank you for review.
>
> The issue is that in case of .BTF_ids section absent we have to skip
> some of the steps, specifically:
> - symbols_collect()
> - sequence between symbols_resolve() and dump_raw_btf_ids()

> It's not an exit condition, we still have to do load/dump of the BTF.
>
> I tried in symbols_collect():
>
> if (obj.efile.idlist_shndx == -1 || obj.efile.symbols_shndx == -1)
> return 0;
>
> But then, we either have to do the same check in symbols_resolve() and
> co, or maybe store a flag in the struct object. So I decided it's
> better to have an explicit flag in the main control flow, instead of
> hiding it.

For symbols_resolve() is any special logic necessary?
I think that `id = btf_id__find(root, str);` will just return NULL for
every type, thus the whole function would be a noop passing through
BTF types once.

symbols_patch() will be a noop, as it will attempt traversing empty roots.
dump_raw_btf_ids() already returns if there are no .BTF_ids.

[...]