llvm commit ([1]) added support for btf_decl_tag attribute with typedef declaration. Eventually, DW_TAG_LLVM_annotation tag may appear inside dwarf typedef declaration tag. kernel support for typedef BTF_KIND_DECL_TAG support is introduced in [2]. There is no additional libbpf change needed as the previous libbpf BTF_KIND_DECL_TAG support is generic enough to cover new typedef use cases. This patch added parsing of DW_TAG_LLVM_annotation for dwarf typedef decl. $ cat t.c $ clang -O2 -g -c t.c $ llvm-dwarfdump --debug-info t.o ...... 0x00000033: DW_TAG_typedef DW_AT_type (0x00000051 "structure ") DW_AT_name ("__t") DW_AT_decl_file ("/home/yhs/t.c") DW_AT_decl_line (3) 0x0000003e: DW_TAG_LLVM_annotation DW_AT_name ("btf_decl_tag") DW_AT_const_value ("tag1") 0x00000047: DW_TAG_LLVM_annotation DW_AT_name ("btf_decl_tag") DW_AT_const_value ("tag2") 0x00000050: NULL Previously, pahole will issue a warning if typedef tag contains any child tag. I removed this warning since it is not true any more. Note that dwarf standard doesn't prevent typedef decl tag from having nested tags. In the future if we need to process any tag inside typedef tag, we can just add code to process it. [1] https://reviews.llvm.org/D110127 [2] https://lore.kernel.org/bpf/20211021195628.4018847-1-yhs@xxxxxx Signed-off-by: Yonghong Song <yhs@xxxxxx> --- dwarf_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index c5bda81..f748bd7 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -1296,11 +1296,8 @@ static struct tag *die__create_new_typedef(Dwarf_Die *die, struct cu *cu, struct if (tdef == NULL) return NULL; - if (dwarf_haschildren(die)) { - struct dwarf_tag *dtag = tdef->namespace.tag.priv; - fprintf(stderr, "%s: DW_TAG_typedef %llx WITH children!\n", - __func__, (unsigned long long)dtag->id); - } + if (add_child_llvm_annotations(die, -1, conf, &tdef->namespace.annots)) + return NULL; return &tdef->namespace.tag; } -- 2.30.2