Commit a05cc561 authored by Martin Storsjö's avatar Martin Storsjö

checkasm: arm/aarch64: Fix the amount of space reserved for stack parameters

Even if MAX_ARGS - 2 (for arm) or MAX_ARGS - 7 (for aarch64) parameters
are passed on the stack to checkasm_checked_call, we actually only
need to store MAX_ARGS - 4 (for arm) or MAX_ARGS - 8 (for aarch64)
parameters on the stack when calling the tested function.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent 8e2ea691
...@@ -52,7 +52,7 @@ endconst ...@@ -52,7 +52,7 @@ endconst
// max number of args used by any asm function. // max number of args used by any asm function.
#define MAX_ARGS 15 #define MAX_ARGS 15
#define ARG_STACK ((8*(MAX_ARGS - 7) + 15) & ~15) #define ARG_STACK ((8*(MAX_ARGS - 8) + 15) & ~15)
function checkasm_checked_call, export=1 function checkasm_checked_call, export=1
stp x29, x30, [sp, #-16]! stp x29, x30, [sp, #-16]!
...@@ -81,7 +81,7 @@ function checkasm_checked_call, export=1 ...@@ -81,7 +81,7 @@ function checkasm_checked_call, export=1
sub sp, sp, #ARG_STACK sub sp, sp, #ARG_STACK
.equ pos, 0 .equ pos, 0
// the first stacked arg is copied to x7 // the first stacked arg is copied to x7
.rept MAX_ARGS-7 .rept MAX_ARGS-8
ldr x9, [x29, #16 + 8 + pos] ldr x9, [x29, #16 + 8 + pos]
str x9, [sp, #pos] str x9, [sp, #pos]
.equ pos, pos + 8 .equ pos, pos + 8
......
...@@ -50,7 +50,7 @@ endconst ...@@ -50,7 +50,7 @@ endconst
@ max number of args used by any asm function. @ max number of args used by any asm function.
#define MAX_ARGS 15 #define MAX_ARGS 15
#define ARG_STACK 4*(MAX_ARGS - 2) #define ARG_STACK 4*(MAX_ARGS - 4)
@ align the used stack space to 8 to preserve the stack alignment @ align the used stack space to 8 to preserve the stack alignment
#define ARG_STACK_A (((ARG_STACK + pushed + 7) & ~7) - pushed) #define ARG_STACK_A (((ARG_STACK + pushed + 7) & ~7) - pushed)
...@@ -74,7 +74,7 @@ function checkasm_checked_call_\variant, export=1 ...@@ -74,7 +74,7 @@ function checkasm_checked_call_\variant, export=1
sub sp, sp, #ARG_STACK_A sub sp, sp, #ARG_STACK_A
.equ pos, 0 .equ pos, 0
.rept MAX_ARGS-2 .rept MAX_ARGS-4
ldr r12, [sp, #ARG_STACK_A + pushed + 8 + pos] ldr r12, [sp, #ARG_STACK_A + pushed + 8 + pos]
str r12, [sp, #pos] str r12, [sp, #pos]
.equ pos, pos + 4 .equ pos, pos + 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment