This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: making aliases into the middle of a structure
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: making aliases into the middle of a structure
- From: Jeffrey A Law <law at upchuck dot cygnus dot com>
- Date: Fri, 23 Apr 1999 00:14:34 -0600
- cc: Zack Weinberg <zack at rabi dot columbia dot edu>, egcs at egcs dot cygnus dot com
- Reply-To: law at cygnus dot com
In message <org15s33hj.fsf@lua.lbi.dcc.unicamp.br>you write:
> > Because the preprocessor can't compute offsetof() all the way down;
> > I'd have to compile and run a test program. Which loses when
> > cross-compiling.
>
> Well, you could try to extract this information from the assembly
> code, or from some RTL dump (since you're bound to gcc anyway), but I
> wouldn't like to be the one to implement it :-)
Cygnus implemented a switch to have the compiler dump offsets for fields
within structures in a format intended to be used by assembly code.
It's not something we've used a lot and haven't ever thought it worth
the effort to clean it up and submit it to egcs.
I've been kicking around the idea of using that code to build a testsuite
to look for unexpected changes in structure layouts between releases as
one component of a wider1 ABI compatibility testing plan.
Ie, we build a repository of tests which define a bunch of structs, unions,
classes. We compile those tests with the magic option which records the
offset for each field within the structure. We do this for each target we
care about.
Then we can compile a later release and compare the offsets for that target
to ensure they have not changed.
It's not a perfect solution for ABI testing, but it's a small step we can
use as a building block. Will it actually happen -- I don't know. It's
still a blue sky project.
Jeff