From 3912d03d0036c899484af331f38f474c343de743 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 27 Nov 2015 10:48:13 -0800 Subject: Adjust stack before pushing arguments. Fixes new stack alignment code on 32-bit targets --- gen_x86.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gen_x86.c') diff --git a/gen_x86.c b/gen_x86.c index cfc826a..fec5790 100644 --- a/gen_x86.c +++ b/gen_x86.c @@ -2111,18 +2111,18 @@ uint32_t prep_args(code_info *code, uint32_t num_args, va_list args) #else #define stack_args num_args #endif - for (int i = stack_args -1; i >= 0; i--) - { - push_r(code, arg_arr[i]); - } - uint32_t stack_off_call = code->stack_off + sizeof(void *); + uint32_t stack_off_call = code->stack_off + sizeof(void *) * (stack_args + 1); uint32_t adjust = 0; if (stack_off_call & 0xF) { adjust = 16 - (stack_off_call & 0xF); sub_ir(code, adjust, RSP, SZ_PTR); code->stack_off += adjust; } - + for (int i = stack_args -1; i >= 0; i--) + { + push_r(code, arg_arr[i]); + } + return stack_args * sizeof(void *) + adjust; } -- cgit v1.2.3