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
This commit is contained in:
parent
f272407353
commit
1075087241
1 changed files with 3 additions and 1 deletions
|
@ -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));
|
memset(plan->clsplans, 0, sizeof(plan->clsplans));
|
||||||
for(i = nb_args; i-- ;) {
|
for(i = nb_args; i-- ;) {
|
||||||
int j, start_vfpreg = 0;
|
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;
|
size = (size + 3) & ~3;
|
||||||
align = (align + 3) & ~3;
|
align = (align + 3) & ~3;
|
||||||
switch(vtop[-i].type.t & VT_BTYPE) {
|
switch(vtop[-i].type.t & VT_BTYPE) {
|
||||||
|
|
Loading…
Reference in a new issue