[Dwarf-Discuss] Resend Encoding large constant values

Cary Coutant ccoutant at google.com
Mon Sep 17 13:54:46 PDT 2012

Sorry, forgot to reply-all...

---------- Forwarded message ----------
From: Cary Coutant <ccoutant at google.com>
Date: Mon, Sep 17, 2012 at 1:36 PM
Subject: Re: [Dwarf-Discuss] Resend Encoding large constant values
To: Tommy Hoffner <thoffner at ca.ibm.com>

> Giving me a 16 byte conhstant. My attempt on encoding this was
> < 6>< 69><code: 6> DW_TAG_constant DW_CHILDREN_no
> < 72> DW_AT_name DW_FORM_string
> < 74> DW_AT_const_value DW_FORM_block1
> < 76> DW_AT_decl_file DW_FORM_data1
> < 78> DW_AT_decl_line DW_FORM_data1
> < 80> DW_AT_type DW_FORM_ref4
> The problem is that the standard section above doesn't mention
> DW_FORM_block1 as something that can contain a constant.

Sure it does. Section 4.1:

10. A DW_AT_const_value attribute for an entry describing a variable
or formal parameter whose value is constant and not represented by an
object in the address space of the program, or an entry describing a
named constant. (Note that such an entry does not have a location
attribute.) The value of this attribute may be a string or any of the
constant data or data block forms, as appropriate for the
representation of the variable’s value. The value is the actual
constant value of the variable, represented as it would be on the
target architecture.

This explicitly mentions the block forms as appropriate for DW_AT_const_value.

> It does however
> say:
> "In all forms, the length is the number of information bytes that follow.
> The information bytes may contain any mixture of relocated (or relocatable)
> addresses, references to other debugging information entries or data bytes."
> However since all the data types above can be expressed as expressions, I
> seen tools assuming that DW_FORM_block always contains an expression.

Bad tools. Before version 4, DWARF encoded location expressions in
DW_FORM_block, but only in contexts where a location was expected. For
DW_AT_const_value, the contents of a DW_FORM_block should be
interpreted as the constant value itself. In DWARF-4, we now have
DW_FORM_exprloc for that purpose, and the use of DW_FORM_block for a
location expression is deprecated.

> So I think the DW_FORM_block1 above should contain the raw floating point
> data (apart from the size field). While a number of tools expect an
> expression evaluating to the raw bit pattern (?) for the 16 byte data we
> want.

Yes, you have it right. The tools you refer to are wrong, if, in fact,
they're applying that interpretation to DW_FORM_block* for a
DW_AT_const_value attribute.


More information about the Dwarf-Discuss mailing list