From 6a028821b69c665eedd4bdee93ac321221c2b9ad Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 10 Dec 2017 09:18:04 +0100 Subject: [PATCH] x86 glue code: keep stack aligned. The glue code pushed 12 bytes to the stack, breaking the 16-byte stack alignment requirement. This would be fixed by the main() prologue from gcc, but all "init" and "fini" code (static/global constructors/ destructors) would run with a misaligned stack. This was already fixed for x86_64 in hrev49731. Note that the fix here is slightly different, the pointer is realigned after it is saved to EBP and the function epilogue restores it from EBP, so no changes to crtn.S are needed. --- src/system/glue/arch/x86/crti.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/system/glue/arch/x86/crti.S b/src/system/glue/arch/x86/crti.S index d9571d3533..711213cdfe 100644 --- a/src/system/glue/arch/x86/crti.S +++ b/src/system/glue/arch/x86/crti.S @@ -23,6 +23,7 @@ FUNCTION(_init): pushl %ebp movl %esp, %ebp + sub $4,%esp // Keep stack aligned pushl 8(%ebp) // put image ID on the stack again call __haiku_init_before // crtbegin.o stuff comes here @@ -31,6 +32,7 @@ FUNCTION(_init): FUNCTION(_fini): pushl %ebp movl %esp, %ebp + sub $4,%esp // Keep stack aligned pushl 8(%ebp) call __haiku_term_before // crtend.o stuff comes here