commit 803115eaf6d0b2621bcd27fa2a7a5e9ff25b6fd7
parent 0f7b539ed5c32dd6ccfb96e3be8bc487bd7d20a8
Author: Nikola <nikola@radojevic.rs>
Date: Sat, 4 Jun 2022 21:49:45 +0200
rt: Fix stack alignment in _start
Until now, we assumed that the stack was 16 byte aligned by the OS when
the process was started. This is not guaranteed, so we should align the
stack ourselves.
This is a companion to the similar patch for harec.
Signed-off-by: Nikola <nikola@radojevic.rs>
Diffstat:
4 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/rt/+freebsd/start+aarch64-libc.s b/rt/+freebsd/start+aarch64-libc.s
@@ -5,4 +5,5 @@ _start:
mov x30, #0
mov x0, sp
add sp, x0, #-16
+ and sp, sp, #-16
b rt.start_freebsd
diff --git a/rt/+freebsd/start+x86_64-libc.s b/rt/+freebsd/start+x86_64-libc.s
@@ -2,4 +2,5 @@
.global _start
_start:
xor %rbp, %rbp
+ and $-16, %rsp
call rt.start_freebsd
diff --git a/rt/+linux/start+aarch64-libc.s b/rt/+linux/start+aarch64-libc.s
@@ -5,4 +5,5 @@ _start:
mov x30, #0
mov x0, sp
add sp, x0, #-16
+ and sp, sp, #-16
b rt.start_linux
diff --git a/rt/+linux/start+x86_64-libc.s b/rt/+linux/start+x86_64-libc.s
@@ -3,4 +3,5 @@
_start:
xor %rbp, %rbp
movq %rsp, %rdi
+ andq $-16, %rsp
call rt.start_linux