RE: local variable alignment on Solaris/SPARC, with gcc 4.x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Amruth,

I just took a look at the SPARC ABI ... 

+ Although the architecture requires only word alignment, software convention and the operating system require every stack frame to be doubleword aligned.

+ Every stack frame must have a 16-word save area for the in and local registers, in case of window overflow or underflow.  This save area always must exist at %sp+0.

Also of interest in the SPARC ABI (but irrelevant to your problem) is the use of var-args, which may result in misaligned data for (say) a double that straddles the wrong two words.

So it would seem to me that even a leaf-function should have a double-word aligned stack.

But that does not mean that a char foo[10]; local (stack) variable will be word or double-word aligned.  The compiler's optimizer is at liberty to perform deep voodoo optimization that may result in the foo being at a non-word boundary.  :-(

For GCC 4.1.0, I'd turn on the -O2 optimization and use the -fverbose-asm switch and -S to view the flags that are enabled by -O2, and then disable them a batch at a time (divide and conquer) until you isolate a flag that you can use to disable the behavior.

As it so happens, though, -O2 also enables optimizations that do not have a tweakable knob to explicitly disable.  And if the optimization is one of those, you may be in dire straights.

I'd also upgrade to GCC 4.1.2 or GCC 4.2.1, if possible.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux