[x264-devel] [PATCH 6/6] checkasm: aarch64: Add filler args to make sure all parameters are passed on the stack
Janne Grunau
janne-x264 at jannau.net
Wed Nov 16 00:02:41 CET 2016
On 2016-11-14 23:54:53 +0200, Martin Storsjö wrote:
> This, combined with clobbering the stack space prior to the call,
> increases the chances of finding cases where 32 bit parameters
> are erroneously treated as 64 bit.
> ---
> tools/checkasm-aarch64.S | 15 ++++++---------
> tools/checkasm.c | 2 +-
> 2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/tools/checkasm-aarch64.S b/tools/checkasm-aarch64.S
> index 1eb4546..7f66ead 100644
> --- a/tools/checkasm-aarch64.S
> +++ b/tools/checkasm-aarch64.S
> @@ -99,21 +99,18 @@ function x264_checkasm_call, export=1
>
> sub sp, sp, #ARG_STACK
> .equ pos, 0
> -// first two stacked args are copied to x6, x7
> .rept MAX_ARGS-8
> - ldr x9, [x29, #16 + 16 + pos]
> + // Skip the first 8 args, that are loaded into registers
> + ldr x9, [x29, #16 + 8*8 + pos]
> str x9, [sp, #pos]
> .equ pos, pos + 8
> .endr
>
> mov x12, x0
> - mov x0, x2
> - mov x1, x3
> - mov x2, x4
> - mov x3, x5
> - mov x4, x6
> - mov x5, x7
> - ldp x6, x7, [x29, #16]
> + ldp x0, x1, [x29, #16]
> + ldp x2, x3, [x29, #32]
> + ldp x4, x5, [x29, #48]
> + ldp x6, x7, [x29, #64]
> blr x12
> add sp, sp, #ARG_STACK
> ldr x2, [sp]
> diff --git a/tools/checkasm.c b/tools/checkasm.c
> index e10665c..8e3a928 100644
> --- a/tools/checkasm.c
> +++ b/tools/checkasm.c
> @@ -263,7 +263,7 @@ 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__ ); })
> + x264_checkasm_call(( intptr_t(*)())func, &ok, 0, 0, 0, 0, 0, 0, __VA_ARGS__ ); })
> #elif ARCH_AARCH64 && !defined(__APPLE__)
> #elif ARCH_X86 || ARCH_ARM
> #define call_a1(func,...) x264_checkasm_call( (intptr_t(*)())func, &ok, __VA_ARGS__ )
ok
Janne
More information about the x264-devel
mailing list