about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/arch/x86_64/ccall.S16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/rt/arch/x86_64/ccall.S b/src/rt/arch/x86_64/ccall.S
index d9221067175..7a69aecedbf 100644
--- a/src/rt/arch/x86_64/ccall.S
+++ b/src/rt/arch/x86_64/ccall.S
@@ -56,3 +56,19 @@ upcall_call_c_stack_float:
     pop %rbp
     ret
 
+#if defined(__APPLE__) || defined(_WIN32)
+.globl _upcall_call_c_stack_shim
+_upcall_call_c_stack_shim:
+#else
+.globl upcall_call_c_stack_shim
+upcall_call_c_stack_shim
+#endif
+    push %rbp
+    mov %rsp,%rbp          // save rsp
+    mov ARG1,%rsp          // switch stack
+    mov ARG0,%r11          // Remember target address
+    mov ARG1,ARG0          // setup the parameter shim expects
+    call *%r11
+    mov %rbp,%rsp
+    pop %rbp
+    ret