diff --git a/btf_encoder.c b/btf_encoder.c index f9e7859..74bd1b9 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -85,6 +85,15 @@ static int32_t enumeration_type__encode(struct btf *btf, struct tag *tag) struct enumerator *pos; int32_t type_id; + /* if enumerator bit_size is not 32, generate an int type instead. */ + if (etype->size != 32) { + struct base_type bt = {}; + + bt.bit_size = etype->size; + bt.is_signed = true; + return btf__add_base_type(btf, &bt); + } + type_id = btf__add_enum(btf, etype->namespace.name, etype->size, etype->nr_members); if (type_id < 0) diff --git a/libbtf.c b/libbtf.c index 7256f38..2790cbb 100644 --- a/libbtf.c +++ b/libbtf.c @@ -228,7 +228,7 @@ int32_t btf__add_base_type(struct btf *btf, const struct base_type *bt) { struct btf_int_type int_type; struct btf_type *t = &int_type.type; - uint8_t encoding; + uint8_t encoding = 0; t->name_off = bt->name; t->info = BTF_INFO_ENCODE(BTF_KIND_INT, 0, 0);