pahole: add support for kind layout, CRC encoding BTF features
PATCH 1/1 pahole: add support for kind layout, CRC encoding BTF features
add "kind_layout" and "crc" features for adding BTF kind layout section and adding CRCs to BTF headers respectively; this support depends on the libbpf support added in [1].
Bump version to 1.26 to allow kernel to recognize support for "--btf_fetaures"; vesion-based feature tests > 1.26 will be no longer needed now that --btf_features can silently ignore unknown features.
Signed-off-by Alan Maguire <[email protected]>
[1] https://lore.kernel.org/bpf/[email protected]/
--- CMakeLists.txt | 4 ++-- btf_encoder.c | 7 ++++++- dwarves.h | 2 ++ man-pages/pahole.1 | 4 ++++ pahole.c | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-)
CMakeLists.txt +2 -2
@@ -54,9 +54,9 @@ if (NOT DEFINED BUILD_SHARED_LIBS) endif (NOT DEFINED BUILD_SHARED_LIBS) # Just for grepping, DWARVES_VERSION isn't used anywhere anymore -# add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION="v1.25") +# add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION="v1.26") add_definitions(-D_GNU_SOURCE -DDWARVES_MAJOR_VERSION=1) -add_definitions(-D_GNU_SOURCE -DDWARVES_MINOR_VERSION=25) +add_definitions(-D_GNU_SOURCE -DDWARVES_MINOR_VERSION=26) find_package(DWARF REQUIRED) find_package(ZLIB REQUIRED) find_package(argp REQUIRED)
btf_encoder.c +6 -1
@@ -1630,12 +1630,17 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenamstruct btf_encoder *encoder =zalloc (sizeof (*encoder));if (encoder) { +LIBBPF_OPTS (btf_new_opts, new_opts); + + new_opts.base_btf = base_btf; + new_opts.add_crc = conf_load->btf_gen_crc; + new_opts.add_kind_layout = conf_load->btf_gen_kind_layout; encoder->raw_output = detached_filename !=NULL ; encoder->filename =strdup (encoder->raw_output ? detached_filename : cu->filename);if (encoder->filename ==NULL ) goto out_delete; - encoder->btf =btf__new_empty_split (base_btf); + encoder->btf =btf__new_empty_opts (&new_opts);if (encoder->btf ==NULL ) goto out_delete;
dwarves.h +2 -0
@@ -86,6 +86,8 @@ struct conf_load {bool skip_encoding_btf_inconsistent_proto;bool skip_encoding_btf_vars;bool btf_gen_floats; +bool btf_gen_crc; +bool btf_gen_kind_layout;bool btf_encode_force;uint8_t hashtable_bits;uint8_t max_hashtable_bits;
man-pages/pahole.1 +4 -0
@@ -293,6 +293,10 @@ Encode BTF using the specified feature list, or specify 'all' for all features s in some CUs and not others, or when the same function name has inconsistent BTF descriptions in different CUs. + crc Generate CRC in BTF header. + kind_layout Add BTF kind layout section, which describes the + layout of the known BTF kinds at time of + encoding. This helps parsers read BTF. .fi So for example, specifying \-\-btf_encode=var,enum64 will result in a BTF encoding that (as well as encoding basic BTF information) will contain variables and enum64 values.
pahole.c +2 -0
@@ -1278,6 +1278,8 @@ struct btf_feature {BTF_FEATURE (enum64, skip_encoding_btf_enum64, true),BTF_FEATURE (optimized_func, btf_gen_optimized, false),BTF_FEATURE (consistent_func, skip_encoding_btf_inconsistent_proto, false), +BTF_FEATURE (crc, btf_gen_crc, false), + BTF_FEATURE(kind_layout, btf_gen_kind_layout, false), };#define BTF_MAX_FEATURE_STR 1024
Signature · 1 line
2.31.1