[PATCH dwarves v3 0/5] Emit global variables in BTF
Stephen Brennan <[email protected]> Wed, 2 Oct 2024 16:52:42 -0700
| Newsgroups | org.kernel.vger.linux-debuggers,org.kernel.vger.bpf,org.kernel.vger.dwarves |
|---|---|
| Message-ID | <[email protected]> |
Hello all,
This is v3 of the series to add global variables to pahole's generated BTF.
Patches 1-3 of v2 were already merged. This series splits the last patch of v2
and does some small updates. It should apply cleanly to the "next" branch.
https://github.com/acmel/dwarves/commits/btf_global_vars/
Changes since v2:
1. Split things out into several smaller patches as can be seen in the log
below.
2. Previously the global_var feature was defined with BTF_DEFAULT_FEATURE, but I
think we agreed in the discussion of v2 that it would be better as
BTF_NON_DEFAULT_FEATURE, so I changed it to align with our discussion.
3. Removed the "--encode_btf_global_vars" option.
3. I went through and straightened out my use of integer types for ELF section
index (size_t, as returned by libelf) as well as the variable addr and size.
To this end I did add a few checks to explicitly ensure we don't overflow the
uint32_t fields in the DATASEC.
To test this out on a Linux build, you'll want to make the following change:
---------
diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf
index b75f09f3f424..c88d9e526426 100644
--- a/scripts/Makefile.btf
+++ b/scripts/Makefile.btf
@@ -19,7 +19,7 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsis
else
# Switch to using --btf_features for v1.26 and later.
-pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
+pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs,global_var
ifneq ($(KBUILD_EXTMOD),)
module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base
---------
With a suitable kernel config that has BTF enabled, you could then build like
so:
PATH=path/to/pahole_build_dir make all
And you'll be able to examine the size of the results with readelf, or dump the
results with bpftool.
v2: https://lore.kernel.org/dwarves/[email protected]/T/
v1: https://lore.kernel.org/dwarves/[email protected]/
Stephen Brennan (5):
btf_encoder: use bitfield to control var encoding
btf_encoder: stop indexing symbols for VARs
btf_encoder: explicitly check addr/size for u32 overflow
btf_encoder: allow encoding VARs from many sections
pahole: add global_var BTF feature
btf_encoder.c | 348 +++++++++++++++++++++------------------------
btf_encoder.h | 7 +
dwarves.h | 1 +
man-pages/pahole.1 | 7 +-
pahole.c | 3 +-
5 files changed, 178 insertions(+), 188 deletions(-)
--
2.43.5