Add code for ABI-compatible va_arg in va_stack_arg_builtin.
@@ -60,7 +60,26 @@ void *va_arg_builtin (void *p, uint64_t t) {
return a;
}
-void *va_stack_arg_builtin (void *p, size_t s) { return *(void **) va_arg_builtin (p, MIR_T_I64); }
+void *va_stack_arg_builtin (void *p, size_t s) {
+#ifdef SWITCHITFORABI
+ struct aarch64_va_list *va = p;
+ void *a;
+ size_t size = (s + 7) / 8 * 8;
+
+ if (size > 2 * 8) size = 8;
+ if (va->__gr_offs < 0) {
+ a = (char *) va->__gr_top + va->__gr_offs;
+ va->__gr_offs += size;
+ } else {
+ a = va->__stack;
+ va->__stack = (char *) va->__stack + size;
+ }
+ if (s > 2 * 8) return *(void **) a; /* address */
+ return a;
+#else
+ return *(void **) va_arg_builtin (p, MIR_T_I64);
+#endif
+}
void va_start_interp_builtin (MIR_context_t ctx, void *p, void *a) {
struct aarch64_va_list *va = p;
