@@ -1901,3 +1901,27 @@ void dwarves__set_btf_kind_max(struct conf_load *conf_load, int btf_kind_max)
if (btf_kind_max < BTF_KIND_ENUM64)
conf_load->skip_encoding_btf_enum64 = true;
}
+
+void btf__set_btf_kind_max(struct conf_load *conf_load, struct btf *btf)
+{
+ __u32 id, type_cnt = btf__type_cnt(btf);
+
+ for (id = 1; id < type_cnt; id++) {
+ const struct btf_type *t = btf__type_by_id(btf, id);
+ const struct btf_enum *e;
+ __u16 vlen, i;
+
+ if (!t || !btf_is_enum(t))
+ continue;
+ vlen = btf_vlen(t);
+ e = btf_enum(t);
+ for (i = 0; i < vlen; e++, i++) {
+ const char *name = btf__name_by_offset(btf, e->name_off);
+
+ if (!name || strcmp(name, "BTF_KIND_MAX"))
+ continue;
+ dwarves__set_btf_kind_max(conf_load, e->val);
+ return;
+ }
+ }
+}
@@ -27,4 +27,6 @@ struct btf *btf_encoder__btf(struct btf_encoder *encoder);
int btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other);
+void btf__set_btf_kind_max(struct conf_load *conf_load, struct btf *btf);
+
#endif /* _BTF_ENCODER_H_ */
@@ -3462,6 +3462,7 @@ int main(int argc, char *argv[])
base_btf_file, libbpf_get_error(conf_load.base_btf));
goto out;
}
+ btf__set_btf_kind_max(&conf_load, conf_load.base_btf);
if (!btf_encode && !ctf_encode) {
// Force "btf" since a btf_base is being informed
conf_load.format_path = "btf";
@@ -3505,6 +3506,7 @@ try_sole_arg_as_class_names:
base_btf_file, libbpf_get_error(conf_load.base_btf));
goto out;
}
+ btf__set_btf_kind_max(&conf_load, conf_load.base_btf);
}
}
When creating module BTF, the module likely will not have a DWARF specificiation of BTF_KIND_MAX, so look for it in the base BTF. For vmlinux base BTF, the enumeration value is present, so the base BTF can be checked to limit BTF kind representation. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> --- btf_encoder.c | 24 ++++++++++++++++++++++++ btf_encoder.h | 2 ++ pahole.c | 2 ++ 3 files changed, 28 insertions(+)