[Dwarf-Discuss] Problems understanding attribute DW_AT_location of global variables (Form DW_FORM_BLOCK)

Jakub Jelinek jakub@redhat.com
Mon Apr 4 07:23:13 GMT 2011


On Mon, Apr 04, 2011 at 09:08:12AM +0200, happyfrank3d at web.de wrote:
> ?<1><275>: Abbrev Number: 12 (DW_TAG_variable) 
> ??? <276>?? DW_AT_name??????? : (indirect string, offset: 0x96): global20?????? 
> ??? <27a>?? DW_AT_decl_file?? : 1?????? 
> ??? <27b>?? DW_AT_decl_line?? : 24????? 
> ??? <27c>?? DW_AT_type??????? : <0x4f>? 
> ??? <280>?? DW_AT_external??? : 1?????? 
> ??? <281>?? DW_AT_location??? : 5 byte block: 3 4c 0 0 0 ?????? (DW_OP_addr: 4c) 
> 
> All variables are of type int(4 byte). 
> 
> 1. What does the value "5 byte block: 3 0 0 0 0" in this special case mean? 

It dumps the content of the block for the DW_AT_location attribute, then
interprets it.

> 2. What does the value "3" stand for? 

DW_OP_addr.

> 3. Is the virtual address of variable "global01" 0x0000? 

Most likely you are looking at ET_REL file, thus the value you are seeing in
the 4 bytes after DW_OP_addr opcode is (for 32-bit REL targets) just addend,
you need to look up the relocation against .debug_info+0x282.

> 4. What does the offset in the section .debug_pubtypes of the global variables mean? 

See DWARF 4 standard, 7.19 - the offsets are the relative DIE offsets within
the compilation unit referenced from the preceeding .debug_pubtypes header.

	Jakub




More information about the Dwarf-discuss mailing list