From e134202611a50b358c147c92bfb8a7f443030b8b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 8 Jul 2024 17:43:59 +0300 Subject: fix LLVM + Anything extern is right out as LLVM doesn't produce correct code for them. Maybe if I added some extra attributes but I'm skeptical. Replaced with static variables and getters/setters. + Inline ASM is apparently a bit buggy, so use an assembly stub when jumping to init. + Minimize work done in main() to minimize chance of LLVM doing something silly. Still not 100% certain that I shouldn't just write the main() as an assembly stub in arch/riscv64 to be absolutely sure everything works as intended. + Make .kernel.start section SHF_ALLOC, otherwise lld complains about pc-relative addressing Probably some other stuff as well that I'm forgetting right now. But at least with LLVM14 LTO seems to work, which is pretty cool? --- src/tcb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tcb.c') diff --git a/src/tcb.c b/src/tcb.c index ea00d3d..053ea6f 100644 --- a/src/tcb.c +++ b/src/tcb.c @@ -102,14 +102,14 @@ stat_t alloc_stack(struct tcb *t) /* get parent process */ struct tcb *p = get_tcb(t->eid); - t->thread_stack = __setup_thread_stack(p, __thread_stack_size); + t->thread_stack = __setup_thread_stack(p, thread_stack_size()); if (!t->thread_stack) return ERR_OOMEM; /** \todo this only allows for a global stack size, what if a user wants * per thread stack sizes? I guess allocate them yourself in userspace * or something? */ - t->thread_stack_size = __thread_stack_size; + t->thread_stack_size = thread_stack_size(); return OK; } -- cgit v1.3