From 956812bda521ca68072a699e5a59a49249d1678c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 31 Oct 2011 15:39:27 -0700 Subject: [PATCH] rt: Have __morestack conform to the calling convention that LLVM generates on x86 --- src/rt/arch/i386/morestack.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index 23492637fdbc..b6808e351a0e 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -8,31 +8,34 @@ #if defined(__APPLE__) || defined(_WIN32) #define RUST_NEW_STACK _rust_new_stack #define RUST_DEL_STACK _rust_del_stack +#define MORESTACK ___morestack #else #define RUST_NEW_STACK rust_new_stack #define RUST_DEL_STACK rust_del_stack +#define MORESTACK __morestack #endif .globl RUST_NEW_STACK .globl RUST_DEL_STACK -.globl __morestack +.globl MORESTACK -__morestack: - pushl %edx // param 2: size of arguments - leal 8(%esp),%eax - pushl %eax // param 1: starting addr of arguments - pushl %ecx // param 0: amount of space needed +MORESTACK: + pushl 8(%esp) // argsz > ra stksz argsz x x ra args + leal 28(%esp),%eax // argsz ra stksz argsz x x ra args + pushl %eax // argp > argsz ra stksz argsz x x ra args + pushl 12(%esp) // stksz > argp argsz ra stksz argsz x x ra args calll RUST_NEW_STACK + addl $12,%esp // ra stksz argsz x x ra args movl (%esp),%edx // Grab the return pointer. incl %edx // Skip past the `ret`. movl %eax,%esp // Switch to the new stack. - calll *%edx // Enter the new function. + calll *%edx // Re-enter the function that called us. // Now the function that called us has returned, so we need to delete the // old stack space. calll RUST_DEL_STACK - movl %eax,%esp // Switch back to the old stack. - retl + movl %eax,%esp + retl $8 // ra stksz argsz x x ra args