Issue 161206.2: Clarify relationship between DW_OP_piece and DW_OP_bit_piece
Author: | Andreas Arnez |
---|---|
Champion: | Adrian Prantl |
Date submitted: | 2016-12-06 |
Date revised: | |
Date closed: | 2021-03-22 |
Type: | Clarification |
Status: | Rejected with clarification |
DWARF Version: | 6 |
Section 2.6.1.2, pg 42
The current specifications of DW_OP_piece and DW_OP_bit_piece do not make it sufficiently clear whether DW_OP_piece is just a backward-compatible short-hand notation for special cases of DW_OP_bit_piece. All DWARF producers/consumers I know of interpret it that way, but the current specification says otherwise:
- DW_OP_piece: "If the piece is located in a register, but does not occupy the entire register, the placement of the piece within that register is defined by the ABI."
- DW_OP_bit_piece: "If the location is a register, the offset is from the least significant bit end of the register."
This wording seems to imply that byte- and bit pieces may follow different rules for the placement of pieces within a register, one defined by the ABI, and the other being the LSB0 rule defined by DWARF.
Also, placement rules for other types of objects are only given for DW_OP_bit_piece and missing for DW_OP_piece.
Thus I propose to clarify the specification of DW_OP_piece in 2.6.1.2 "Composite Location Descriptions":
1. DW_OP_piece
The DW_OP_piece operation takes a single operand, which is
an unsigned LEB128 number. The number gives the size in
bytes of the piece of the object referenced by the
preceding simple location description. The placement of
the piece within that object is the same as defined by the
appropriate DW_OP_bit_piece operation with offset zero.
Thus the following operations are equivalent:
- DW_OP_piece <n>
- DW_OP_bit_piece <8*n> 0
RESOLUTION
We found that multiple big-endian ABIs (including MIPS, and Sparc) are defining DW_OP_piece as different from DW_OP_Bit_piece with offset 0. In order to avoid breaking compatibility, we add the following non-normative text to Section 2.6.1.2:
For instance, so that structure variables passed by register can be loaded and stored using register-sized transfers, a big-endian ABI may specify that the pieces of a structure are "left aligned" within a register (located in the most significant bytes of the register). Thus, DW_OP_piece
is not necessarily equivalent to DW_OP_bit_piece <8*n> 0.
2021-03-22 Rejected with clarification: Add non-normative text: Whether or not a DW_OP_piece operation is equivalent to any DW_OP_bit_piece operation with an offset of 0 is ABI dependent.