pyelftools icon indicating copy to clipboard operation
pyelftools copied to clipboard

DW_AT_type : signature: 0x9076313a8afb4d4d

Open guohengfeng opened this issue 5 years ago • 8 comments

hello I have a problem with using readelf,when i use readelf to parse file (.elf) i found some of DW_TAG_typedef the DW_AT_type : signature: 0x9076313a8afb4d4d. what dose it means, how to remove that signature: 0x9076313a8afb4d4d. and let the the DW_AT_type become a normal value thank you!!

guohengfeng avatar Oct 29 '20 03:10 guohengfeng

I presume you are trying to examine the value of the type attribute. The "signature:" line probably means the value is an object. Try dumping the type of the object:

type(die.attributes['DW_AT_type'].value)

See if that gives you a hint what to do with it. That said, the value of DW_AT_type is usually a reference to another DIE (the DIE of the referenced type). Depending on the compiler, the exact form of the reference might vary.

sevaa avatar Oct 29 '20 14:10 sevaa

thank you for your help

you said try dumping what dose that mean? if it means below? CMD:py readelf. py --debug-dumptype(die.attributes['DW_AT_type'].value) and what dose"DIE"means?

I am the first time to use ELF tools this is a very useful tool it helps me a lot

guohengfeng avatar Dec 03 '20 02:12 guohengfeng

That Python command is wrong. I see you are not writing a Python program, you are probably using readelf.py to see the debug info - is that right?

By the way, why are you doing all this? What is the ultimate goal?

DIE means "Debug Information Entry". It's the basic unit of information in the DWARF debug info, A DIE contains a name, called "tag", and a collection of attributes, where each attribute has a name and a value and a form. readelf.py outputs the tree of DIEs in a compiled ELF file.

Off the top of my head, I can't find anything in readelf.py that would produce an attribute value like that. Where exactly does the DW_AT_type : signature: 0x9076313a8afb4d4d come from?

sevaa avatar Dec 03 '20 02:12 sevaa

I have a similar problem since I need to update to a newer compiler (IAR V8.40). I analyze the debug information with objdump.exe which gives me a idea I like to show you:

<1><9aeff>: Abbrev Number: 29 (DW_TAG_typedef) <9af00> DW_AT_name : SafetyMgr__eState_t <9af14> DW_AT_type : **signature: 0xdb789b73685aec21** <9af1c> DW_AT_decl_file : 122 <9af1d> DW_AT_decl_line : 68 <9af1e> DW_AT_decl_column : 3 <9af1f> Unknown AT value: 276a: 21

DW_AT_type could contain a signature as mentioned in DWARF 4 specification. In my case (IAR compiler V8.40) the signature seems a reference to a CU like this:

Compilation Unit @ offset 0xb9eb: Length: 0x257 (32-bit) Version: 4 Abbrev Offset: 0xb293 Pointer Size: 4 Signature: **0xdb789b73685aec21** Type Offset: 0x8f <0><ba02>: Abbrev Number: 2 (DW_TAG_type_unit) <ba03> DW_AT_name : C:\workspace\Charger\SU613\src\SafetyMgr\SafetyMgr.h <ba38> DW_AT_producer : IAR ANSI C/C++ Compiler V8.40.2.214/W32 for ARM <ba68> DW_AT_language : 12 (ANSI C99) <ba69> DW_AT_stmt_list : 0xaa75d <ba6d> DW_AT_macro_info : 0xfda5 <ba71> DW_AT_use_UTF8 : 1 <ba71> Unknown AT value: 276d: 3

Unfortunately pyelftools does not seem to find CUs that looks like this; finally those debug information are missing. Is this something that might be supported in the near future (or maybe still on the go)?

Update: I found that compilation units with signatures all relates to a section .debug_types

uvwaldow avatar Feb 26 '21 11:02 uvwaldow

It should not be supported

elif attr.form in ('DW_FORM_ref_sig8'): # Implement search type units for matching signature raise NotImplementedError('%s (type unit by signature)' % attr.form)

leyue avatar Dec 19 '22 03:12 leyue