This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: making aliases into the middle of a structure



  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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]