From: Janne Grunau Date: Mon, 14 Nov 2016 21:54:50 +0000 (+0200) Subject: checkasm: arm: preserve the stack alignment in x264_checkasm_checked_call X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd15b354a887943d525e6fd8096ad4b75692d2b2;p=libx264 checkasm: arm: preserve the stack alignment in x264_checkasm_checked_call The stack used by x264_checkasm_checked_call_neon was a multiple of 4 when the checked function is called. AAPCS requires a double word (8 byte) aligned stack public interfaces. Since both calls are public interfaces the stack is misaligned when the checked is called. This can cause issues if code called within this (which includes the C implementations) relies on the stack alignment. --- diff --git a/tools/checkasm-arm.S b/tools/checkasm-arm.S index 57b4079b..8242a58c 100644 --- a/tools/checkasm-arm.S +++ b/tools/checkasm-arm.S @@ -47,6 +47,9 @@ error_message: #define ARG_STACK 4*(MAX_ARGS - 2) +@ align the used stack space to 8 to preserve the stack alignment +#define ARG_STACK_A (((ARG_STACK + pushed + 7) & ~7) - pushed) + .macro clobbercheck variant .equ pushed, 4*10 function x264_checkasm_call_\variant @@ -64,10 +67,10 @@ function x264_checkasm_call_\variant push {r1} - sub sp, sp, #ARG_STACK + sub sp, sp, #ARG_STACK_A .equ pos, 0 .rept MAX_ARGS-2 - ldr r12, [sp, #ARG_STACK + pushed + 8 + pos] + ldr r12, [sp, #ARG_STACK_A + pushed + 8 + pos] str r12, [sp, #pos] .equ pos, pos + 4 .endr @@ -75,9 +78,9 @@ function x264_checkasm_call_\variant mov r12, r0 mov r0, r2 mov r1, r3 - ldrd r2, r3, [sp, #ARG_STACK + pushed] + ldrd r2, r3, [sp, #ARG_STACK_A + pushed] blx r12 - add sp, sp, #ARG_STACK + add sp, sp, #ARG_STACK_A pop {r2} push {r0, r1}