Re: x86 code generation question

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

 



On Tue, Dec 14, 2021 at 12:40 PM Manuel Lauss via Gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
> Is there an explanation of how this whole stack magic works?  I wrote
> a small test for dlvsym() and its stack pointer is precisely
> aligned so that the vmovdqa with displacement 0xc points to a 16-byte
> aligned address.  However I don't get how the failing program gets its
> misaligned stack. Does it have to be built with special compiler flags or
> linker scripts?

No magic involved. The rule is that you are only allowed to invoke C
functions if $esp is divisible by 16 before execution of the call
instruction. $esp is forced to an aligned address at the beginning of
main, and the compiler will not generate functions that create odd
stack frames, so it will stay aligned at all times without further
runtime penalties. The only price to pay is a minuscule increase of 8
bytes in stack frame size for some functions compared to the previous
rules (I think 4-byte alignment was never allowed).



[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