From 79d1509cb06ba9067f56e2c62394d7bc60fa6bf2 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 10 Oct 2017 11:39:45 -0700 Subject: [PATCH] x86: align alloca to 16-byte boundary Align the stack allocation to a 16-byte boundary. This ensures that the stack parameters are 16-byte aligned which is needed for some instructions. --- src/x86/ffi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 3b4e25e3..897498f6 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -32,6 +32,7 @@ #ifndef __x86_64__ #include #include +#include #include #include "internal.h" @@ -674,7 +675,8 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue) } bytes = cif->bytes; - argp = stack = alloca(bytes + sizeof(*frame) + rsize); + argp = stack = + (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16); frame = (struct call_frame *)(stack + bytes); if (rsize) rvalue = frame + 1;