[x264-devel] [PATCHv2 5/6] checkasm: aarch64: Clobber the stack before calling functions

Janne Grunau janne-x264 at jannau.net
Wed Nov 16 19:15:12 CET 2016


On 2016-11-16 10:57:30 +0200, Martin Storsjö wrote:
> ---
> Removed the duplicate elif
> ---
>  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

ok

Janne


More information about the x264-devel mailing list