Fix the address on stack where a structure is copied when it is a parameter of a function call. This address must be computed from the stack pointer and a possible padding offset.
Unified · Split
| @@ -1020,19 +1020,22 @@ static int copy_params(int nb_args, struct plan *plan, int todo) · 1019 unmodified lines | ||
| 1020 | 1020 | case CORE_STRUCT_CLASS: |
| 1021 | 1021 | case VFP_STRUCT_CLASS: |
| 1022 | 1022 | if ((pplan->sval->type.t & VT_BTYPE) == VT_STRUCT) { |
| 1023 | + int padding = 0; | |
| 1023 | 1024 | size = type_size(&pplan->sval->type, &align); |
| 1024 | 1025 | /* align to stack align size */ |
| 1025 | 1026 | size = (size + 3) & ~3; |
| 1026 | 1027 | if (i == STACK_CLASS && pplan->prev) |
| 1027 | − size += pplan->start - pplan->prev->end; /* Add padding if any */ | |
| 1028 | + padding = pplan->start - pplan->prev->end; | |
| 1029 | + size += padding; /* Add padding if any */ | |
| 1028 | 1030 | /* allocate the necessary size on stack */ |
| 1029 | 1031 | gadd_sp(-size); |
| 1030 | 1032 | /* generate structure store */ |
| 1031 | 1033 | r = get_reg(RC_INT); |
| 1032 | − o(0xE1A0000D|(intr(r)<<12)); /* mov r, sp */ | |
| 1034 | + o(0xE28D0000|(intr(r)<<12)|padding); /* add r, sp, padding */ | |
| 1033 | 1035 | vset(&vtop->type, r | VT_LVAL, 0); |
| 1034 | 1036 | vswap(); |
| 1035 | − vstore(); /* memcpy to current sp */ | |
| 1037 | + vstore(); /* memcpy to current sp + potential padding */ | |
| 1038 | + | |
| 1036 | 1039 | /* Homogeneous float aggregate are loaded to VFP registers |
| 1037 | 1040 | immediately since there is no way of loading data in multiple |
| 1038 | 1041 | non consecutive VFP registers as what is done for other |