| Submitter | Andrew Haley |
|---|---|
| Date | July 7, 2010, 3:58 p.m. |
| Message ID | <4C34A43E.2020207@redhat.com> |
| Download | mbox | patch |
| Permalink | /patch/58128/ |
| State | New |
| Headers | show |
Comments
Patch
Index: libffi/src/x86/sysv.S =================================================================== --- libffi/src/x86/sysv.S (revision 161921) +++ libffi/src/x86/sysv.S (working copy) @@ -48,6 +48,9 @@ movl 16(%ebp),%ecx subl %ecx,%esp + /* Align the stack pointer to 16-bytes */ + andl $0xfffffff0, %esp + movl %esp,%eax /* Place all of the ffi_prep_args in position */
Applied for Neil Roberts to gcc trunk. Andrew. From 89d2865bcf30bc020399a74b3053d46ef7750a28 Mon Sep 17 00:00:00 2001 From: Neil Roberts <neil@linux.intel.com> Date: Fri, 26 Feb 2010 14:42:49 +0000 Subject: [PATCH] x86: Align the stack to 16-bytes before making the call If gcc is targetting i686 then it will use SSE registers for the floating point operations. It will then sometimes use 16-byte temporary variables on the stack to store the registers and it will use aligned instructions to access them. This will segfault if the variable is not aligned to 16-bytes. Apparently GCC assumes that the stack is 16-byte aligned when a function is entered and it uses this to position its temporary variables. Therefore libffi needs to align the stack or the called function will crash in some circumstances. 2010-07-07 Neil Roberts <neil@linux.intel.com> * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to 16-bytes.