pyelftools
pyelftools copied to clipboard
Finding size of data of type DW_TAG_Typedef with DW_AT_TYPE form DW_FORM_ref_sig8
When trying to find the size of a field in a struct, the type of the field is a typedef'ed enum. When looking op the type of the field, the DW_AT_TYPE is DW_FORM_ref_sig8.
DIE DW_TAG_typedef, size=24, has_children=False
|DW_AT_name : AttributeValue(name='DW_AT_name', form='DW_FORM_string', value=b'language_t', raw_value=b'language_t', offset=4586852)
|DW_AT_type : AttributeValue(name='DW_AT_type', form='DW_FORM_ref_sig8', value=13158201686284400073, raw_value=13158201686284400073, offset=4586863)
|DW_AT_decl_file : AttributeValue(name='DW_AT_decl_file', form='DW_FORM_udata', value=6, raw_value=6, offset=4586871)
|DW_AT_decl_line : AttributeValue(name='DW_AT_decl_line', form='DW_FORM_udata', value=45, raw_value=45, offset=4586872)
|DW_AT_decl_column : AttributeValue(name='DW_AT_decl_column', form='DW_FORM_udata', value=3, raw_value=3, offset=4586873)
|10090 : AttributeValue(name=10090, form='DW_FORM_udata', value=12, raw_value=12, offset=4586874)
the debug dump output is:
<45fd63>: Abbrev Number: 28 (DW_TAG_typedef)
<45fd64> DW_AT_name : language_t
<45fd6f> DW_AT_type : <0xb69b52b7f2336e92>
<45fd77> DW_AT_decl_file : 6
<45fd78> DW_AT_decl_line : 45
<45fd79> DW_AT_decl_column : 3
<45fd7a> Unknown AT value: 276a: 12
In the dwarf 5 standard specification I read:
The .debug_names section offsets lists provide an offset for the skeleton compilation unit and eight byte signatures for the type units that appear only in the .debug_info.dwo. The DIE offsets for these compilation units and type units refer to the DIEs in the .debug_info.dwo section for the respective compilation unit and type units.
When I read this it seems to me that the 64bit DW_FORM_ref_sig8 should point to an entry in the .debug_names section containing information in which dwo section the info for this type is present. However I don't seem to be able to find access to this .debug_names section.
What can I do to find the size of this field?
After some additional research and the use of some other tools it seems that my issue is solved with the .debug_types section as provided in this pull request . My elf file has the type defined in the .debug_types section.
My experience with pull requests is fairly limited. Is there anything I can do to help get the changes from this pull request in the package distributed on pypi?
@sach-edna I guess I should take that as a prod.
The PR was generated when @eliben was in a limited time phase, and the commit was tangled with other commits in that PR. I later found out that he prefers to collapse PRs and so git wasn't able to figure out how to resolve the conflicts.
You may be able to change your dwarf options to work around this (.debug_types was added in DWARFv4 and obsoleted in DWARFv5, but I am not aware of v5 support. My undersanding is gcc has explict opt in and out for debug_types but I don't know about other toolchains).