diff options
author | andrew <andrew@FreeBSD.org> | 2015-06-22 19:43:08 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2015-06-22 19:43:08 +0000 |
commit | 8f12ad25e4203f70aecc65ba785e6b8d24cf7dcf (patch) | |
tree | d6df06724240de4f71ea48d1f26b34365876310e /lib/csu | |
parent | abe0339f5a25adadc435ed699285d3b3bf92ee34 (diff) | |
download | FreeBSD-src-8f12ad25e4203f70aecc65ba785e6b8d24cf7dcf.zip FreeBSD-src-8f12ad25e4203f70aecc65ba785e6b8d24cf7dcf.tar.gz |
Add a workaround to correctly align the stack before calling into C code.
When enough time has passed for users to update their userland the kernel
fix will be applied. This will change the ABI to have x0 point to the args
and sp be correctly aligned.
It is expected this compatibility code can be removed when the kernel and
qemu usermode emulation have both been updated for the new ABI.
This fixes clang failures, and most likely other crashes.
Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/csu')
-rw-r--r-- | lib/csu/aarch64/crt1.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/csu/aarch64/crt1.c b/lib/csu/aarch64/crt1.c index 6518e8d..de4455e 100644 --- a/lib/csu/aarch64/crt1.c +++ b/lib/csu/aarch64/crt1.c @@ -58,9 +58,13 @@ __asm(" .text \n" " .align 0 \n" " .globl _start \n" " _start: \n" -" mov x3, x2 \n" /* cleanup */ -" ldr x0, [sp] \n" /* Load argc */ -" add x1, sp, #8 \n" /* load argv */ +/* TODO: Remove this when the kernel correctly aligns the stack */ +" cbnz x0, 1f \n" /* Are we using a new kernel? */ +" mov x0, sp \n" /* No, load the args from sp */ +" and sp, x0, #~0xf \n" /* And align the stack */ +"1: mov x3, x2 \n" /* cleanup */ +" add x1, x0, #8 \n" /* load argv */ +" ldr x0, [x0] \n" /* load argc */ " add x2, x1, x0, lsl #3 \n" /* env is after argv */ " add x2, x2, #8 \n" /* argv is null terminated */ " b __start "); |