[x264-devel] checkasm: arm: preserve the stack alignment in x264_checkasm_checked_call
Janne Grunau
git at videolan.org
Thu Dec 1 21:01:43 CET 2016
x264 | branch: master | Janne Grunau <janne-x264 at jannau.net> | Mon Nov 14 23:54:50 2016 +0200| [cd15b354a887943d525e6fd8096ad4b75692d2b2] | committer: Henrik Gramner
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.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=cd15b354a887943d525e6fd8096ad4b75692d2b2
---
tools/checkasm-arm.S | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/checkasm-arm.S b/tools/checkasm-arm.S
index 57b4079..8242a58 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}
More information about the x264-devel
mailing list