DWARF Standard


040928.1 Don Darling Add Address Size to Frame Info Extension Accepted Jim Blandy


If one was to encounter a DW_OP_addr in the middle of a
DW_CFA_expression, how is one supposed to determine the size of a target
address, so they know how many bytes to read?  You could find the
debug_info compile unit that references the same code as the FDE, but
there are a lot of hoops to jump through to do this.  Also, some
compiler vendors always generate .debug_frame sections, even if no other
debugging information is generated.  Thus, they cannot rely on there
being a .debug_info compile unit header to find the address size.

The same is true for DW_CFA_set_loc.

We have always encoded all target addresses as 4-byte values for all
ISAs to avoid these issues, even if they are actually smaller.  I'm just
curious about how a completely generic DWARF reader might handle this,
without any knowledge of the target architecture.

Jim Blandy wrote:
|> >Does the .debug_frame section carry any indication of how large the
|> >addresses it contains should be?  I'm talking about the
|> >initial_location in the FDE, and the DW_CFA_set_loc operand.  One is
|> >tempted to suggest using some compilation unit's address size, but
|> >.debug_frame is supposed to be self-contained.
|> >It seems to me this is worth bumping the version number to fix.

Ron (Brender?) writes (attribution not really clear):
|> But does one good fix deserve another -- or three?
|> The .debug_line section has the same problem. Shall we bump its
|> version number (actually we already did) and add an address_size
|> byte there too?
|> Worse yet are the .debug_loc and .debug_ranges sections -- these
|> have no header at all, hence no version number to bump, hence no
|> possibility to upwardly add an address_size header field at all!
|> Sigh...

Daniel Jacobowitz wrote, 25 Apr 2004
|Is there any use in .debug_loc and .debug_ranges without first reading
|the .debug_info section, which does contain the address size?  For
|.debug_line there's a little more of an argument.

PROPOSAL (revised 4/2/2007):

This change requires changing the version number of .debug_frame.

In the .debug_frame section, add address size and segment size fields
to CIEs.  Specifically, in section 6.4.1, add, between 'augmentation'
and 'code_alignment_factor' in the CIE text:

    5.  address_size (ubyte)

    The size of a target address in this CIE and any FDEs that use it, in
    bytes.  If a Compilation Unit exists for this frame that Compilation
    Unit address size must match the address size here.

    6.  segment_size (ubyte)

    The size of a segment selector in this CIE and any FDEs that use it,
    in bytes.

In the FDE description, add the following to the end of the
description of 'initial location':

    If the 'segment_size' field of this FDE's CIE is non-zero, the
    initial location is preceded by a segment selector of the given

In section, "Row Creation instructions", change the word
'address' in the first sentence to 'target address', to make it
clearer that the size of the field is controlled by the CIE's
address_size field.  To the end of the paragraph, add the sentence:

    If the 'segment_size' field of this FDE's CIE is non-zero, the
    address operand is preceded by a segment selector of the given


Proposal accepted 6/5/2007.

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2017 by DWARF Standards Committee.