From: Rich Felker Date: Mon, 3 Jun 2013 21:32:42 +0000 (-0400) Subject: align stack properly for calling global ctors/dtors on x86[_64] X-Git-Tag: v0.9.11~45 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a6d272127bb6a2eb09dc182cc39c49e77310ade4;p=oweals%2Fmusl.git align stack properly for calling global ctors/dtors on x86[_64] failure to do so was causing crashes on x86_64 when ctors used SSE, which was first observed when ctors called variadic functions due to the SSE prologue code inserted into every variadic function. --- diff --git a/crt/i386/crti.s b/crt/i386/crti.s index 2eb23ed5..d2682a20 100644 --- a/crt/i386/crti.s +++ b/crt/i386/crti.s @@ -1,7 +1,9 @@ .section .init .global _init _init: + sub $12,%esp .section .fini .global _fini _fini: + sub $12,%esp diff --git a/crt/i386/crtn.s b/crt/i386/crtn.s index 055451ed..f3b61e01 100644 --- a/crt/i386/crtn.s +++ b/crt/i386/crtn.s @@ -1,5 +1,7 @@ .section .init + add $12,%esp ret .section .fini + add $12,%esp ret diff --git a/crt/x86_64/crti.s b/crt/x86_64/crti.s index 2eb23ed5..4788968b 100644 --- a/crt/x86_64/crti.s +++ b/crt/x86_64/crti.s @@ -1,7 +1,9 @@ .section .init .global _init _init: + push %rax .section .fini .global _fini _fini: + push %rax diff --git a/crt/x86_64/crtn.s b/crt/x86_64/crtn.s index 055451ed..29198b77 100644 --- a/crt/x86_64/crtn.s +++ b/crt/x86_64/crtn.s @@ -1,5 +1,7 @@ .section .init + pop %rax ret .section .fini + pop %rax ret