diff --git a/btf_encoder.c b/btf_encoder.c index 982f59d..d26c0b6 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -237,7 +237,8 @@ static struct variable *hashaddr__find_variable(const struct hlist_head hashtabl return NULL; } -int cu__encode_btf(struct cu *cu, int verbose, bool force) +int cu__encode_btf(struct cu *cu, int verbose, bool force, + bool skip_encoding_vars) { bool add_index_type = false; uint32_t type_id_off; @@ -314,6 +315,8 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force) } } + if (skip_encoding_vars) + goto out; if (btfe->percpu_shndx == 0 || !btfe->symtab) goto out; diff --git a/btf_encoder.h b/btf_encoder.h index bca2348..46fb231 100644 --- a/btf_encoder.h +++ b/btf_encoder.h @@ -13,6 +13,7 @@ struct cu; int btf_encoder__encode(); -int cu__encode_btf(struct cu *cu, int verbose, bool force); +int cu__encode_btf(struct cu *cu, int verbose, bool force, + bool skip_encoding_vars); #endif /* _BTF_ENCODER_H_ */ diff --git a/man-pages/pahole.1 b/man-pages/pahole.1 index 950dd54..6f9986d 100644 --- a/man-pages/pahole.1 +++ b/man-pages/pahole.1 @@ -177,6 +177,10 @@ Show only structs with at least NR_HOLES holes. Show the file and line number where the tags were defined, if available in the debugging information. +.TP +.B \-\-skip_encoding_btf_vars +Do not encode VARs in BTF. + .TP .B \-l, \-\-show_first_biggest_size_base_type_member Show first biggest size base_type member. diff --git a/pahole.c b/pahole.c index e1cde61..4cc8d9f 100644 --- a/pahole.c +++ b/pahole.c @@ -26,6 +26,7 @@ static bool btf_encode; static bool ctf_encode; static bool first_obj_only; +static bool skip_encoding_btf_vars; static uint8_t class__include_anonymous; static uint8_t class__include_nested_anonymous; @@ -809,6 +810,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version; #define ARGP_header_type 314 #define ARGP_size_bytes 315 #define ARGP_range 316 +#define ARGP_skip_encoding_btf_vars 317 static const struct argp_option pahole__options[] = { { @@ -1087,6 +1089,11 @@ static const struct argp_option pahole__options[] = { .key = 'J', .doc = "Encode as BTF", }, + { + .name = "skip_encoding_btf_vars", + .key = ARGP_skip_encoding_btf_vars, + .doc = "Do not encode VARs in BTF." + }, { .name = "force", .key = 'j', @@ -1207,6 +1214,8 @@ static error_t pahole__options_parser(int key, char *arg, conf.range = arg; break; case ARGP_header_type: conf.header_type = arg; break; + case ARGP_skip_encoding_btf_vars: + skip_encoding_btf_vars = true; break; default: return ARGP_ERR_UNKNOWN; } @@ -2352,7 +2361,7 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, goto filter_it; if (btf_encode) { - cu__encode_btf(cu, global_verbose, force); + cu__encode_btf(cu, global_verbose, force, skip_encoding_btf_vars); return LSK__KEEPIT; }