This doesn't matter now since we use an out pointer for return
values but it's sure to show up mysteriously someday.
// Realign stack - remember that __morestack was called misaligned
subl $12, %esp
+ // Save the return value of the function we allocated space for
+ movl %eax, (%esp)
+
// Now that we're on the return path we want to avoid
// stomping on %eax. FIXME: Need to save and restore %eax to
// actually preserve it across the call to delete the stack
call UPCALL_DEL_STACK
+ // And restore it
+ movl (%esp), %eax
+
addl $12,%esp
popl %ebp
// Switch back to the rust stack
movq %rbp, %rsp
- // Align the stack again
- pushq $0
+ // Save the return value
+ pushq %rax
// FIXME: Should preserve %rax here
#ifdef __APPLE__
call UPCALL_DEL_STACK@PLT
#endif
- addq $8, %rsp
+ popq %rax // Restore the return value
popq %rbp
// FIXME: I don't think these rules are necessary
// since the unwinder should never encounter an instruction