From e24f7afd1025dc234b713d3059d4eb174a51afef Mon Sep 17 00:00:00 2001 From: tkchia Date: Tue, 9 Aug 2022 09:13:07 +0000 Subject: [PATCH] Fix deterministic startup stack setup, especially for bare metal --- libc/runtime/cosmo.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libc/runtime/cosmo.S b/libc/runtime/cosmo.S index 954e2e263..ab11f6038 100644 --- a/libc/runtime/cosmo.S +++ b/libc/runtime/cosmo.S @@ -99,6 +99,8 @@ cosmo: push %rbp .init.start 304,_init_stack testb IsWindows() jnz 9f + testb IsMetal() + jnz 9f push %rdi push %rsi // allocate stack @@ -120,8 +122,9 @@ cosmo: push %rbp leave pop %rcx lea (%rax,%r8),%rsp - sub $ape_stack_align,%rsp # openbsd:stackbound - mov %rbp,(%rsp) + mov $ape_stack_align,%eax # openbsd:stackbound + neg %rax + and %rax,%rsp push %rcx push %rbp mov %rsp,%rbp