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 <alan.maguire@xxxxxxxxxx> [1] https://lore.kernel.org/bpf/20231110110304.63910-1-alan.maguire@xxxxxxxxxx/ --- 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(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98642e1..a250182 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/btf_encoder.c b/btf_encoder.c index fd04008..0167cc5 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -1630,12 +1630,17 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam struct 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; diff --git a/dwarves.h b/dwarves.h index 857b37c..b1bea14 100644 --- a/dwarves.h +++ b/dwarves.h @@ -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; diff --git a/man-pages/pahole.1 b/man-pages/pahole.1 index ea9045c..1d0a627 100644 --- a/man-pages/pahole.1 +++ b/man-pages/pahole.1 @@ -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. diff --git a/pahole.c b/pahole.c index 768a2fe..32bfe88 100644 --- a/pahole.c +++ b/pahole.c @@ -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 -- 2.31.1