public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] libbpf/bpftool: support merging split BTFs
@ 2026-02-20 16:48 Josef Bacik
  2026-02-20 16:48 ` [PATCH 1/3] libbpf: support appending split BTF in btf__add_btf() Josef Bacik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Bacik @ 2026-02-20 16:48 UTC (permalink / raw)
  To: bpf

Hello,

I'm extending systing to do introspection on vfio devices, which requires having
the structs I need from the kernel available in userspace. Normally these are
loadable modules, but in the case of vfio there's multiple structs across
multiple modules. Normally you'd do the following to generate your vmlinux.h
with a module

bpftool btf dump file /sys/kernel/btf/<module> format c \
	--base /sys/kernel/btf/vmlinux > vmlinux.h

but if you need multiple modules you have to hack together multiple dumps and
merge them together. This patch series adds support for merging multiple BTF
sources together, so you can do

bpftool btf dump file /sys/kernel/btf/<module1> \
	file /sys/kernel/btf/<module2> format c \
	--base /sys/kernel/btf/vmlinux > vmlinux.h

I tested this with my usecase and it works. Thanks,

Josef

Josef Bacik (3):
  libbpf: support appending split BTF in btf__add_btf()
  bpftool: support merging multiple module BTFs in btf dump
  selftests/bpf: add test for btf__add_btf() with split BTF sources

 tools/bpf/bpftool/btf.c                       | 126 ++++++++++++++++--
 tools/lib/bpf/btf.c                           |  38 ++++--
 .../selftests/bpf/prog_tests/btf_write.c      |  89 +++++++++++++
 3 files changed, 232 insertions(+), 21 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-02-20 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20 16:48 [PATCH 0/3] libbpf/bpftool: support merging split BTFs Josef Bacik
2026-02-20 16:48 ` [PATCH 1/3] libbpf: support appending split BTF in btf__add_btf() Josef Bacik
2026-02-20 16:48 ` [PATCH 2/3] bpftool: support merging multiple module BTFs in btf dump Josef Bacik
2026-02-20 16:48 ` [PATCH 3/3] selftests/bpf: add test for btf__add_btf() with split BTF sources Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox