From 10750872419df9dc92421c4fd719f42e5561ee77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Date: Sat, 29 Mar 2014 17:50:40 +0100 Subject: [PATCH] ARM: Fix passing arrays to varadic functions TinyCC miscompiled void g(int,...); void f(void) { char b[4000]; g(1, 2, 3, 4, b); } in two ways: 1. It didn't align the stack to 8 bytes before the call 2. It added sizeof(b) to the stack pointer after the call --- arm-gen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arm-gen.c b/arm-gen.c index 1ee008f0..a9c05feb 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -959,7 +959,9 @@ static int assign_regs(int nb_args, int float_abi, struct plan *plan, int *todo) memset(plan->clsplans, 0, sizeof(plan->clsplans)); for(i = nb_args; i-- ;) { int j, start_vfpreg = 0; - size = type_size(&vtop[-i].type, &align); + CType type = vtop[-i].type; + type.t &= ~VT_ARRAY; + size = type_size(&type, &align); size = (size + 3) & ~3; align = (align + 3) & ~3; switch(vtop[-i].type.t & VT_BTYPE) {