aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit fcea24fa12319bb4fc98504935cc910c24a626cd
parent ef65182c5a5d6dfd90dd8cb9eefb344a42493249
Author: anon <anon@example.com>
Date:   Tue, 20 Oct 2026 00:30:59 +0000

Match original guest stack reservations

Diffstat:
Msrc/runtime/linux_host.c | 6+++---
Msrc/runtime/linux_thread.c | 2+-
Msrc/tests/threads.c | 1+
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/runtime/linux_host.c b/src/runtime/linux_host.c @@ -267,12 +267,12 @@ int main(int argc, char **argv) module_count, linux_import_count()); /* Guest stack and thread information remain independent of the host ABI. */ - if (!guest_map("stack", 0x08000000u, 0x400000u) || + if (!guest_map("stack", 0x08000000u, 0x100000u) || !guest_map("thread information", 0x08400000u, 0x10000u)) abort(); - g_esp = 0x083fff00u; + g_esp = 0x080fff00u; g_fs_base = 0x08400000u; MEM32(g_fs_base) = 0xffffffffu; - MEM32(g_fs_base + 4) = 0x08400000u; + MEM32(g_fs_base + 4) = 0x08100000u; MEM32(g_fs_base + 8) = 0x08000000u; MEM32(g_fs_base + 0x18) = g_fs_base; MEM32(g_fs_base + 0x20) = getpid(); diff --git a/src/runtime/linux_thread.c b/src/runtime/linux_thread.c @@ -149,7 +149,7 @@ static void create_thread(uint32_t stack_size, uint32_t entry, uint32_t argument { g_eax = automatic ? UINT32_MAX : 0; if (!entry && !host_entry) { MEM32(guest_crt_errno_address()) = 22; return; } - if (!stack_size) stack_size = 0x400000; + if (!stack_size) stack_size = 0x100000; uint64_t rounded = ((uint64_t)stack_size + 0xffffu) & ~0xffffull; if (rounded > UINT32_MAX - 0x10000u) { MEM32(guest_crt_errno_address()) = 12; return; } diff --git a/src/tests/threads.c b/src/tests/threads.c @@ -56,6 +56,7 @@ void linux_thread_notify(uint32_t reason) assert(MEM32(g_fs_base + 0x18) == g_fs_base); assert(MEM32(g_fs_base) == UINT32_MAX); assert(g_esp > MEM32(g_fs_base + 8) && g_esp < MEM32(g_fs_base + 4)); + assert(MEM32(g_fs_base + 4) - MEM32(g_fs_base + 8) == 0x100000u); if (reason == 2) { assert(!notified && MEM32(MEM32(g_fs_base + 8)) == 0); MEM32(MEM32(g_fs_base + 8)) = 0xfeedcafe;