dwarf_loader: Hash DW_TAG_enumerator entries
PATCH 1/1 dwarf_loader: Hash DW_TAG_enumerator entries
As they are referenced by DW_TAG_imported_declaration, as we can see from these warnings:
⬢[acme@toolbox [email protected]]$ pdwtags popup.cpp.o > /dev/null
die__process_class: tag not supported 0x2f (template_type_parameter)!
die__process_class: tag not supported 0x30 (template_value_parameter)!
die__process_class: tag not supported 0x4107 (GNU_template_parameter_pack)!
die__process_function: tag not supported 0x4108 (GNU_formal_parameter_pack)!
tag__recode_dwarf_type: couldn't find 0x5706e type for 0xedb9 (imported_declaration)!
tag__recode_dwarf_type: couldn't find 0x57074 type for 0xedc1 (imported_declaration)!
tag__recode_dwarf_type: couldn't find 0x5707a type for 0xedc9 (imported_declaration)! namespace__recode_dwarf_types: couldn't find 0x5706e type for 0xedb9 (imported_declaration)! namespace__recode_dwarf_types: couldn't find 0x57074 type for 0xedc1 (imported_declaration)! namespace__recode_dwarf_types: couldn't find 0x5707a type for 0xedc9 (imported_declaration)! ⬢[acme@toolbox [email protected]]$
Looking at the DWARF info for one of those types not found:
⬢[acme@toolbox [email protected]]$ readelf -wi popup.cpp.o | grep -w edb9 -A5
<2><edb9>: Abbrev Number: 14 (DW_TAG_imported_declaration)
<edba> DW_AT_decl_file : 64
<edbb> DW_AT_decl_line : 100
<edbc> DW_AT_decl_column : 20
<edbd> DW_AT_import : <0x5706e> [Abbrev Number: 51 (DW_TAG_enumerator)] <2><edc1>: Abbrev Number: 14 (DW_TAG_imported_declaration)
⬢[acme@toolbox [email protected]]$
And then:
⬢[acme@toolbox [email protected]]$ readelf -wi popup.cpp.o | grep -w 5706e -A3
<3><5706e>: Abbrev Number: 51 (DW_TAG_enumerator)
<5706f> DW_AT_name : (indirect string, offset: 0xaec05): _S_single
<57073> DW_AT_const_value : 0 <3><57074>: Abbrev Number: 51 (DW_TAG_enumerator)
⬢[acme@toolbox [email protected]]$
So we need to hash those DW_TAG_enumerator and not just the DW_TAG_enumerator_type containing them.
This way tag__recode_dwarf_type() and namespace__recode_dwarf_types() will find them when looking them up using dwarf_cu__find_type_by_ref().
This was found first on the stratagus codebase (C++) at
https://github.com/Wargus/stratagus.git.
This didn't generate any difference in output from pahole, not influenced BTF generation as tested using tests/reproducible_build.sh.
--- dwarf_loader.c | 1 + 1 file changed, 1 insertion(+)
dwarf_loader.c +1 -0
@@ -1776,6 +1776,7 @@ static struct tag *die__create_new_enumeration(Dwarf_Die *die, struct cu *cu, st goto out_delete;enumeration__add (enumeration, enumerator); +cu__hash (cu, &enumerator->tag); }while (dwarf_siblingof (die, die) ==0 ); out:return &enumeration->namespace.tag;
Signature · 1 line
2.45.0