checkasm: aarch64: Don't clobber x29 in checkasm_stack_clobber

Message ID 1476787889-7669-1-git-send-email-martin@martin.st
State Committed
Commit dd5d4a0e1e3a30a254d1a57ecbdcedf230c6014b
Headers show

Commit Message

Martin Storsjö Oct. 18, 2016, 10:51 a.m.
x29 (FP) is a callee saved register and should be restored on
return. Instead of backing up x29 and restoring it here, back up
sp in a register that we are allowed to overwrite.

This fixes crashes in checkasm on aarch64 since f1b3e1313851.
For some reason, gcc builds didn't crash, but clang builds do.
---
 tests/checkasm/aarch64/checkasm.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Martin Storsjö Oct. 18, 2016, 1:16 p.m. | #1
On Tue, 18 Oct 2016, Martin Storsjö wrote:

> x29 (FP) is a callee saved register and should be restored on
> return. Instead of backing up x29 and restoring it here, back up
> sp in a register that we are allowed to overwrite.
>
> This fixes crashes in checkasm on aarch64 since f1b3e1313851.
> For some reason, gcc builds didn't crash, but clang builds do.
> ---
> tests/checkasm/aarch64/checkasm.S | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

OK'd by Janne on irc.

// Martin

Patch

diff --git a/tests/checkasm/aarch64/checkasm.S b/tests/checkasm/aarch64/checkasm.S
index 65b3521..bc5ed9e 100644
--- a/tests/checkasm/aarch64/checkasm.S
+++ b/tests/checkasm/aarch64/checkasm.S
@@ -55,13 +55,13 @@  endconst
 #define CLOBBER_STACK ((8*MAX_ARGS + 15) & ~15)
 
 function checkasm_stack_clobber, export=1
-    mov         x29, sp
+    mov         x3,  sp
     mov         x2,  #CLOBBER_STACK
 1:
     stp         x0,  x1,  [sp, #-16]!
     subs        x2,  x2,  #16
     b.gt        1b
-    mov         sp,  x29
+    mov         sp,  x3
     ret
 endfunc