This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: representation of struct field offsets
- From: Chris Lattner <clattner at apple dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Sandra Loosemore <sandra at codesourcery dot com>, gcc at gcc dot gnu dot org
- Date: Thu, 28 Sep 2006 13:52:46 -0700
- Subject: Re: representation of struct field offsets
- References: <451B2DA5.8070504@codesourcery.com> <451C33F8.6090900@codesourcery.com>
On Sep 28, 2006, at 1:43 PM, Mark Mitchell wrote:
Sandra Loosemore wrote:
I've been having a heck of a time figuring out how to translate
the offsets for struct fields from the DWARF encoding back to
GCC's internal encoding for the LTO project.
Yes, that's a nasty bit.
I think the DECL_FIELD_OFFSET/DECL_FIELD_BIT_OFFSET stuff is, quite
simply, mis-designed. The way I think it should work is for
DECL_FIELD_OFFSET to be the byte offset, and DECL_FIELD_BIT_OFFSET
to be the bit offset, always less than BITS_PER_UNIT.
An alternative design, which would save a field, is just to keep the
offset of a field, in bits, from the start of the structure.
The only trouble you'll probably run into is with fields whose offset
from the start of a structure is variable.
-Chris