diff --git a/btf_encoder.c b/btf_encoder.c index 117656e..9d015f3 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -143,6 +143,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { [BTF_KIND_DATASEC] = "DATASEC", [BTF_KIND_FLOAT] = "FLOAT", [BTF_KIND_DECL_TAG] = "DECL_TAG", + [BTF_KIND_TYPE_TAG] = "TYPE_TAG", }; static const char *btf__printable_name(const struct btf *btf, uint32_t offset) @@ -393,6 +394,9 @@ static int32_t btf_encoder__add_ref_type(struct btf_encoder *encoder, uint16_t k case BTF_KIND_TYPEDEF: id = btf__add_typedef(btf, name, type); break; + case BTF_KIND_TYPE_TAG: + id = btf__add_type_tag(btf, name, type); + break; case BTF_KIND_FWD: id = btf__add_fwd(btf, name, kind_flag); break; @@ -862,6 +866,9 @@ static int btf_encoder__encode_tag(struct btf_encoder *encoder, struct tag *tag, case DW_TAG_typedef: name = namespace__name(tag__namespace(tag)); return btf_encoder__add_ref_type(encoder, BTF_KIND_TYPEDEF, ref_type_id, name, false); + case DW_TAG_LLVM_annotation: + name = tag__btf_type_tag(tag)->value; + return btf_encoder__add_ref_type(encoder, BTF_KIND_TYPE_TAG, ref_type_id, name, false); case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: diff --git a/dwarves.h b/dwarves.h index 4425d3c..52d162d 100644 --- a/dwarves.h +++ b/dwarves.h @@ -637,6 +637,11 @@ static inline struct btf_type_tag_ptr_type *tag__btf_type_tag_ptr(struct tag *ta return (struct btf_type_tag_ptr_type *)tag; } +static inline struct btf_type_tag_type *tag__btf_type_tag(struct tag *tag) +{ + return (struct btf_type_tag_type *)tag; +} + /** struct namespace - base class for enums, structs, unions, typedefs, etc * * @tags - class_member, enumerators, etc