From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: Nick Alcock <nick.alcock@oracle.com>,
dwarves <dwarves@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com,
alan.maguire@oracle.com, stephen.brennan@oracle.com,
david.faust@oracle.com, elena.zannoni@oracle.com,
bruce.mcculloch@oracle.com
Subject: Re: Linking BTF
Date: Thu, 17 Jul 2025 09:40:46 +0200 [thread overview]
Message-ID: <87wm878dtt.fsf@oracle.com> (raw)
In-Reply-To: <5fdc2316c63b27d768503f056771ad6a77c803b3.camel@gmail.com>
> On Wed, 2025-07-16 at 16:15 +0100, Nick Alcock wrote:
>
> [...]
>
>> - So... a third option, which is probably the most BTFish because it's
>> something BTF already does, in a sense: put everything in one section,
>> call it .BTF or .BTFA or whatever, and make that section an archive of
>> named BTF members, and then stuff however many BTF outputs the
>> deduplication generates (or none, if we're just stuffing inputs into
>> outputs without dedupping) into archive members.
>>
>> So, here's a possibility which seems to provide the latter option while
>> still letting existing tools read the first member (likely vmlinux):
>>
>> The idea is that we add a *next member link field* in the BTF header, and a
>> name (a strtab offset). The next member link field is an end-of-header-
>> relative offset just like most of the other header fields, which chains BTF
>> members together in a linked list:
>>
>> parent BTF
>> |
>> v
>> children BTF -> BTF -> BTF -> ... -> BTF
>>
>> The parent is always first in the list.
>
> Hi Nick,
>
> You are talking about BTF section embedded in a final vmlinux binary, right?
More generally, a section embedded in any object which is the result of
linking two or more objects having .BTF sections:
ld foo.o (.BTF) bar.o (.BTF) -> baz.o (.BTF)
This covers the particular vmlinux case I think.
> Could you please elaborate a bit on why do you need multiple members
> within this section (in the context of your third option)?
> I re-read the email but don't get it :(
As I understand it:
The linker deduplicates types in the set of input .BTF sections. This
means that when linking foo.o and bar.o, if both compilation units refer
to a type 'quux', there are two possibilities:
a) The type 'quux' is the same (using C type equivalence rules) in both
compilation units. Then the type is "shared" and the linker puts it
only once in the first output BTF member in baz.o .BTF, the "parent".
b) The type 'quux' is different in both compilation units. These are
then conflicting types. Then two versions the type, foo.quux and
bar.quux, are placed by the linker in the corresponding "children"
member in baz.o.
Graphically, the .BTF section in a linked binary would contain a
one-level tree of members, with as many children as input compilation
units :
parent (common types)
|
+--- child1 (types only in child1)
+--- child2 (types only in child2)
.
+--- childN (types only in childN)
Hope this makes sense. Nick should be able to explain it better than I
do.
next prev parent reply other threads:[~2025-07-17 7:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 15:15 Linking BTF Nick Alcock
2025-07-16 21:52 ` Eduard Zingerman
2025-07-17 7:40 ` Jose E. Marchesi [this message]
2025-07-17 11:52 ` Nick Alcock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wm878dtt.fsf@oracle.com \
--to=jose.marchesi@oracle.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=bruce.mcculloch@oracle.com \
--cc=david.faust@oracle.com \
--cc=dwarves@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=elena.zannoni@oracle.com \
--cc=nick.alcock@oracle.com \
--cc=stephen.brennan@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox