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

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

 



Linus Torvalds wrote:

On Wed, 14 Sep 2005, Markus F.X.J. Oberhumer wrote:

You seem to be expecting that the address be aligned "before the return address push", which is a totally different thing. Quite frankly, I don't know which one gcc prefers or whether there's an ABI specifying any preferences.

I'm pretty sure that on both amd64 and i386 the alignment has to be _before_ the address push from the call, though I cannot find any exact ABI specs at the moment. Experts please advise.

What do you get when running this slightly modified version of your test program? My patch would fix the alignment of Aligned16 here.


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.

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?

I think that main() is a known name and therefore gets a special treatment - if you rename main() to foo() and then compare the disassembly you will see that the "andl $-16,%esp" has vanished.

OTOS the "andl" in main() exactly does show how gcc wants the stack to be aligned, i.e. _before_ the call-address push.

Another argument would be the 16-byte aligned stack-setup of glibc - please try runing this tiny program under gdb and look at "info reg":

    asm(".globl main\n main:\n int $3\n");

All of this would indicate that the kernel should get fixed.

~Markus


Andi - you know the gcc people, is there some documented rules somewhere? How does gcc itself try to align the stack when it generates the calls?

		Linus


--
Markus Oberhumer, <[email protected]>, http://www.oberhumer.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux