2. .debug_info
compilation unit header
a series of debugging
information entries (DIE)
.debug_abbrev
length of .debug_info
dwarf version
offset into .debug_abbrev
(size of an address)
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x3a8
.value 0x2 // dwarf versino 2
.long .Ldebug_abbrev0
.byte 0x8 // 64 bits addressing
.uleb128 0x1
.long .LASF55
.byte 0xc
.long .LASF56
.long .LASF57
.quad .Ltext0
.quad .Letext0
.long .Ldebug_line0
a series of abbreviation
declarations
* DWARFv3 supports 64-bits DWARF format.
Initial length = 0xffffffff to indicate 64-bits DWARF.
The following 64-bits value is the real initial length.
(4-byte unsigned)
(2-byte unsigned)
(4-byte unsigned)
3. .debug_info
compilation unit header
a series of debugging
information entries (DIE)
.debug_abbrev
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x3a8
.value 0x2
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF55
.byte 0xc
.long .LASF56
.long .LASF57
.quad .Ltext0
.quad .Letext0
.long .Ldebug_line0
.uleb128 0x2
.long .LASF7
.byte 0x2
.byte 0xd8
.long 0x38
.uleb128 0x3
.byte 0x8
.byte 0x7
.long .LASF0
.uleb128 0x3
.byte 0x1
.byte 0x8
.long .LASF1
a series of abbreviation
declarations
abbreviation code
attribute values
Each abbreviation declaration specifies the tag and attributes for
a particular form of debugging information entry.
4. .section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x3a8
.value 0x2
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF55
.byte 0xc
.long .LASF56
.long .LASF57
.quad .Ltext0
.quad .Letext0
.long .Ldebug_line0
.uleb128 0x2
.long .LASF7
.byte 0x2
.byte 0xd8
.long 0x38
.uleb128 0x3
.byte 0x8
.byte 0x7
.long .LASF0
.uleb128 0x3
.byte 0x1
.byte 0x8
.long .LASF1
abbreviation code
attribute values
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x10
.uleb128 0x6
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x16
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x3
abbreviation code
tag, 0x11(DW_TAG_compile_unit)
has child or not
attribute’s name (DW_AT_producer)
attribute’s form (DW_FORM_strp)
end of attribute spec
end of attribute spec
.section .debug_str,"MS",@progbits,1
.LASF55:
.string "GNU C11 6.2.0 -mtune=generic -march=
attribute’s name
attribute’s form
attribute’s name
attribute’s form
attribute’s name
attribute’s form
attribute’s name
attribute’s form
attribute’s name
attribute’s form
attribute’s name
attribute’s form
5.
6.
7.
8. unsigned LEB128 encoding
12857 = 0011001000111001 Chop 7 bits as a chunk
_0111001_110010000 Place each chunk into a byte
Discard zero byte.
1_______0_______
There are other bytes.Last byte.
1011100101100100
First byte.Second byte.
9. signed LEB128 encoding
-2 = 11111111111111111111111111111110 Chop 7 bits as a chunk
_1111110_1111111
Place each chunk into a byte
If all sign bits, discard. 0_______
Last byte.
01111110
First byte.
_1111111_11111111111
10. signed LEB128 encoding
127 = 00000000000000000000000001111111 Chop 7 bits as a chunk
_1111111_0000000 Place each chunk into a byte
11111111
First byte.
1_______0_______
There are other bytes.Last byte.
00000000
Second byte.
11. .debug_pubnames
header
entries of
global names
in the
.debug_info
length of this set
dwarf version
offset into .debug_info
length of the .debug_info
compilation
unit
compilation
unit
compilation
unit
.debug_info
.debug_info
.debug_info
set
.debug_pubtypes (DWARFv3)
12. .debug_aranges
header
entries of
addresses
in the
.debug_info
length of this set
dwarf version
offset into .debug_info
compilation
unit
compilation
unit
compilation
unit
.debug_info
.debug_info
.debug_info
set
(size of an address)
(size of a segment descriptor)
(padding if necessary)
First entry is aligned with the size of one entry,
2 x (size of an address).
13. Activation Record
• An activation consists of
• A code location that is within the subroutine.
• An area of memory that is allocated on a stack
called a “call frame.”
• A set of registers that are in use by the
subroutine at the code location.
14. Call Frame Information
• Recording how procedures save and restore
registers throughout their lifetimes.
• Construct a very large table as following:
LOC CFA R0 R1 … RN
L0
L1
…
LM
• The table is a mapping between program addresses
and architecture registers.
• The table is a mapping between program addresses
and architecture registers.
• The table entries are the rules to find the register
values in the previous frame.
15. The Register Rules
• undefined
• Has no value in the previous frame. (It is not callee-save
register.)
• same value
• This register has not been modified from the previous frame. (It
is callee-save register, but the callee has not modified it.)
• offset(N)
• The previous value of this register is saved at the address CFA
+N.
• register(R)
• The previous value of this register is stored in another register
numbered R.
• architectural
• Architecture defined.
16. .debug_frame
CIE
FDE
CIE
length of this CIE (uword)
CIE_id (uword)
augmentation (string)
code_alignment_factor (uleb218)
FDE
FDE
FDE
FDE
FDE
FDE
FDE
FDE
FDE
version (ubyte)
data_alignment_factor (sleb128)
return_address_register (ubyte)
initial_instructions
padding
code_alignment_factor:
A constant that is factored out of all advance location instructions.
data_alignment_factor:
A constant that is factored out of all offset instructions.
initial_instructions:
A sequence of rules that are interpreted to create the
initial setting of each column in the table.
(uleb128 for DWARFv3)
17. .debug_frame
CIE
FDE
CIE
length of this FDE (uword)
CIE_pointer (uword)
address_range (addressing unit)
instructions
FDE
FDE
FDE
FDE
FDE
FDE
FDE
FDE
FDE
initial_location (addressing unit)
initial_location:
A constant indicates the address of the first location associated
with this table entry.
address_range:
A constant indicates the number of bytes of program instructions
described by this entry.
instructions:
A sequence of table defining instructions.
padding