[Dwarf-Discuss] DWARF piece questions

Cary Coutant ccoutant@gmail.com
Sat Jan 28 01:11:52 GMT 2017


>>> 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.

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.

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.

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.

-cary



More information about the Dwarf-discuss mailing list