Re: [PATCH] i386: fix stack alignment for signal handlers

From: Daniel Jacobowitz
Date: Wed Sep 14 2005 - 09:23:04 EST


On Tue, Sep 13, 2005 at 04:52:30PM -0700, Linus Torvalds wrote:
> Your test program does seems to imply that gcc wants the alignment before
> the return address (ie it prints out an address that is 4 bytes offset),
> but on the other hand I'm not even sure how careful gcc is about this
> alignment thing at all.

Very, on architectures where the ABI requires alignment. E.G. for
vector register loads that require 16-byte alignment to avoid a trap.

The comment for the relevant bits of the GCC configuration says it
won't assume this for x86, but I believe that comment is out of date.
I think it'll assume 16-byte alignment on entrance to non-main()
functions.

> In the "main()" function, gcc will actually generate a "andl $-16,%esp" to
> force the alignment, but ot in the handler function. Just a gcc special
> case? Random luck?

Special case. This is only done for main().

--
Daniel Jacobowitz
CodeSourcery, LLC
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/