[Dwarf-Discuss] DWARF piece questions

Michael Eager eager@eagercon.com
Sat Jan 28 01:25:06 GMT 2017


On 01/27/2017 05:11 PM, Cary Coutant wrote:
>>>> I still haven't understood *why* DWARF insists on trying to establish a
>>>> universal register bit numbering scheme, and just for the definition of
>>>> DW_OP_bit_piece?  I don't know of any other normative source that tries
>>>> this; and DWARF usually avoids going into such low-level detail, leaving
>>>> it to the ABI instead.  The fact that it does in this case also breaks
>>>> the link to DW_OP_piece, where the placement *can* be freely defined by
>>>> the ABI.
>>>
>>> With the exception I mentioned above, DWARF doesn't mention bit
>>> numbering.  DWARF makes no mention of bit numbering with regard to
>>> registers, and clearly doesn't establish a universal register bit
>>> numbering scheme.
>>
>> It does at least implicitly, when defining the placement rule for
>> DW_OP_bit_piece.  This definition implies a "universal" bit numbering
>> scheme that starts with 0 at a register's "least significant bit".
>
> This is unfortunate, and we shouldn't be referring to an ABI-defined
> bit numbering scheme here.

Agreed.

> I think the original intent of this wording was to describe the bit
> offset of a field within a structure, given the byte address of the
> beginning of the structure. Said bit offset would be the total number
> of bits occupied by preceding fields plus internal padding, as
> demonstrated in the big- and little-endian examples in D.2.8. We
> should never have implied that this bit numbering was meant to match
> the bit numbering convention used in the ABI specification.

Unfortunately, that's exactly what DWARF says.

>
> This is not the only place we use this bit numbering convention -- we
> also use it for the DW_AT_data_bit_offset attribute, and it's defined
> in Section 5.7, with a reference to the examples in D.2.8.

Also, not what we want.

> I think it's also unfortunate that we allowed the offset field for
> DW_OP_bit_piece to apply to register values. That's a very different
> use for the value, and just adds to the confusion.

It's the same use when a register contains multiple fields of a struct.


-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Dwarf-discuss mailing list