bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC dwarves 0/6] prep for compiler-generated BTF
@ 2025-08-07 14:42 Alan Maguire
  2025-08-07 14:42 ` [RFC dwarves 1/6] btf_loader: Make BTF representation match DWARF Alan Maguire
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Alan Maguire @ 2025-08-07 14:42 UTC (permalink / raw)
  To: dwarves; +Cc: bpf, Alan Maguire

This series is intended to help pave the way to allow pahole to
handle compiler-generated BTF as input to its encoding process.

The BTF loader currently supports loading BTF for data structure
and function query but not for BTF generation.  [1] describes how
gcc can generate (and the linker deduplicate) BTF but even there
we will need pahole to post-process the results so it is valuable
to support reading BTF in pahole as input to start exploring how
to handle cases like [1].

The intention of this series is not yet to fully support
linker-deduplicated BTF, but to start down that road by supporting
reading BTF from (multiple) object files and support its deduplication
and BTF output.  To that end a few changes are needed in the
intermediate representation generated by the BTF loader; these are
done in patch 1.  Patch 2 then fixes up a few cases where we needed
to special-case the intermediate representation when it came from
BTF.  Patches 3/4 ensure that we retrieve ELF info when loading BTF
for encoding.  Patch 5 is intended to support cases where we read BTF from
multiple objects and - if the "encode_force" BTF feature is specified -
we continue as long as BTF is found in at least one of those sources.
Finally patch 6 tests pahole when BTF is used as input.

This allows us to experiment with "gcc -gbtf".  For example adding
-gbtf to the KCFLAGS environment variable for a kernel build, we can
then run pahole across the set of vmlinux objects via

pahole --format_path=btf -J --btf_features=encode_force \
        --btf_encode_detached=/tmp/vmlinux.btf $(ar t vmlinux.a)

This is clearly not the right way to do this for kernel builds -
we want to make use of linker deduplication as in [1] - but the fact
that even a hack like this works does demonstrate the viability of
handling BTF as input to vmlinux BTF encoding.  It also allows us
to provide a comparison between compiler-generated BTF with pahole
deduplication and compiler-generated BTF with linker deduplication
when the latter becomes available.

[1] https://lore.kernel.org/dwarves/87ldqf1i19.fsf@esperi.org.uk/

Alan Maguire (6):
  btf_loader: Make BTF representation match DWARF
  pfunct: Fix up function display with updated prototype representation
  pahole: Add btf_encode to conf_load
  btf_loader: read ELF for BTF encoding
  btf_encoder: Do not error out if BTF is not found in some input files
  tests: Add test of pahole using BTF as input to BTF generation

 btf_loader.c       |  36 +++++++++++--
 dwarves.c          |  14 +++++-
 dwarves.h          |   1 +
 dwarves_fprintf.c  |   2 +-
 pahole.c           |  15 +++---
 pfunct.c           |   2 +-
 tests/btf_2_btf.sh | 122 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 176 insertions(+), 16 deletions(-)
 create mode 100755 tests/btf_2_btf.sh

-- 
2.43.5


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-08-08  5:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 14:42 [RFC dwarves 0/6] prep for compiler-generated BTF Alan Maguire
2025-08-07 14:42 ` [RFC dwarves 1/6] btf_loader: Make BTF representation match DWARF Alan Maguire
2025-08-07 14:42 ` [RFC dwarves 2/6] pfunct: Fix up function display with updated prototype representation Alan Maguire
2025-08-07 14:42 ` [RFC dwarves 3/6] pahole: Add btf_encode to conf_load Alan Maguire
2025-08-07 14:42 ` [RFC dwarves 4/6] btf_loader: read ELF for BTF encoding Alan Maguire
2025-08-07 14:42 ` [RFC dwarves 5/6] btf_encoder: Do not error out if BTF is not found in some input files Alan Maguire
2025-08-07 15:59   ` Alexei Starovoitov
2025-08-07 16:36     ` Jose E. Marchesi
2025-08-07 17:12       ` Alexei Starovoitov
2025-08-07 19:18         ` Eduard Zingerman
2025-08-08  5:39           ` Yonghong Song
2025-08-07 14:42 ` [RFC dwarves 6/6] tests: Add test of pahole using BTF as input to BTF generation Alan Maguire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).