harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 2904bb6cffcf87e0461a4ba10909b04d2996caa9
parent 5da64f55da384b962092a0706e1752b0f566f6bf
Author: Nikola <nikola@radojevic.rs>
Date:   Sat,  4 Jun 2022 21:47:38 +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.

Fixes: https://todo.sr.ht/~sircmpwn/hare/656

Signed-off-by: Nikola <nikola@radojevic.rs>

Diffstat:
Mrt/+freebsd/start+aarch64.s | 1+
Mrt/+freebsd/start+x86_64.s | 1+
Mrt/+linux/start+aarch64.s | 1+
Mrt/+linux/start+x86_64.s | 1+
Mrt/+openbsd/start+aarch64.s | 1+
Mrt/+openbsd/start+x86_64.s | 1+
6 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/rt/+freebsd/start+aarch64.s b/rt/+freebsd/start+aarch64.s @@ -5,4 +5,5 @@ _start: mov x30, #0 mov x0, sp add sp, x0, #-16 + and sp, sp, #-16 b rt.start_ha diff --git a/rt/+freebsd/start+x86_64.s b/rt/+freebsd/start+x86_64.s @@ -3,4 +3,5 @@ _start: xor %rbp, %rbp movq %rsp, %rdi + andq $-16, %rsp call rt.start_ha diff --git a/rt/+linux/start+aarch64.s b/rt/+linux/start+aarch64.s @@ -5,4 +5,5 @@ _start: mov x30, #0 mov x0, sp add sp, x0, #-16 + and sp, sp, #-16 b rt.start_ha diff --git a/rt/+linux/start+x86_64.s b/rt/+linux/start+x86_64.s @@ -3,4 +3,5 @@ _start: xor %rbp, %rbp movq %rsp, %rdi + andq $-16, %rsp call rt.start_ha diff --git a/rt/+openbsd/start+aarch64.s b/rt/+openbsd/start+aarch64.s @@ -5,4 +5,5 @@ _start: mov x30, #0 mov x0, sp add sp, x0, #-16 + and sp, sp, #-16 b rt.start_ha diff --git a/rt/+openbsd/start+x86_64.s b/rt/+openbsd/start+x86_64.s @@ -12,4 +12,5 @@ _start: xor %rbp, %rbp movq %rsp, %rdi + andq $-16, %rsp call rt.start_ha