[x264-devel] checkasm: aarch64: Clobber the stack before calling functions
Martin Storsjö
git at videolan.org
Thu Dec 1 21:01:44 CET 2016
x264 | branch: master | Martin Storsjö <martin at martin.st> | Wed Nov 16 10:57:30 2016 +0200| [8ada354c9b5d72356c34c9ae3f787a6df4d61506] | committer: Henrik Gramner
checkasm: aarch64: Clobber the stack before calling functions
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=8ada354c9b5d72356c34c9ae3f787a6df4d61506
---
tools/checkasm-aarch64.S | 13 +++++++++++++
tools/checkasm.c | 8 +++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/tools/checkasm-aarch64.S b/tools/checkasm-aarch64.S
index af4ed31..1eb4546 100644
--- a/tools/checkasm-aarch64.S
+++ b/tools/checkasm-aarch64.S
@@ -56,6 +56,19 @@ error_message:
// max number of args used by any x264 asm function.
#define MAX_ARGS 15
+#define CLOBBER_STACK ((8*MAX_ARGS + 15) & ~15)
+
+function x264_checkasm_stack_clobber, export=1
+ mov x3, sp
+ mov x2, #CLOBBER_STACK
+1:
+ stp x0, x1, [sp, #-16]!
+ subs x2, x2, #16
+ b.gt 1b
+ mov sp, x3
+ ret
+endfunc
+
#define ARG_STACK ((8*(MAX_ARGS - 8) + 15) & ~15)
function x264_checkasm_call, export=1
diff --git a/tools/checkasm.c b/tools/checkasm.c
index 8785cc8..cd0e275 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -258,7 +258,13 @@ void x264_checkasm_stack_clobber( uint64_t clobber, ... );
uint64_t r = (rand() & 0xffff) * 0x0001000100010001ULL; \
x264_checkasm_stack_clobber( r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r ); /* max_args+6 */ \
x264_checkasm_call(( intptr_t(*)())func, &ok, 0, 0, 0, 0, __VA_ARGS__ ); })
-#elif ARCH_X86 || (ARCH_AARCH64 && !defined(__APPLE__)) || ARCH_ARM
+#elif ARCH_AARCH64 && !defined(__APPLE__)
+void x264_checkasm_stack_clobber( uint64_t clobber, ... );
+#define call_a1(func,...) ({ \
+ uint64_t r = (rand() & 0xffff) * 0x0001000100010001ULL; \
+ x264_checkasm_stack_clobber( r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r ); /* max_args+8 */ \
+ x264_checkasm_call(( intptr_t(*)())func, &ok, __VA_ARGS__ ); })
+#elif ARCH_X86 || ARCH_ARM
#define call_a1(func,...) x264_checkasm_call( (intptr_t(*)())func, &ok, __VA_ARGS__ )
#else
#define call_a1 call_c1
More information about the x264-devel
mailing list