diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-12-19 16:16:00 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-12-19 18:16:21 -0800 |
| commit | 1bfc4e2e6c931ca59d31e4621608e05035945f0b (patch) | |
| tree | 4c43c69a8f03ee8a4f89f6b043c64a4aa3eb0710 /src/rt/arch | |
| parent | c3569abb8c7f81e521bc6002b351c3b4fbfcce4c (diff) | |
| download | rust-1bfc4e2e6c931ca59d31e4621608e05035945f0b.tar.gz rust-1bfc4e2e6c931ca59d31e4621608e05035945f0b.zip | |
rt: Save and restore %rax/%eax in __morestack
This doesn't matter now since we use an out pointer for return values but it's sure to show up mysteriously someday.
Diffstat (limited to 'src/rt/arch')
| -rw-r--r-- | src/rt/arch/i386/morestack.S | 6 | ||||
| -rw-r--r-- | src/rt/arch/x86_64/morestack.S | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index c34d1a0fe88..c4090df109d 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -198,11 +198,17 @@ MORESTACK: // 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 diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S index 93ce0e4c698..f4d897f1cf4 100644 --- a/src/rt/arch/x86_64/morestack.S +++ b/src/rt/arch/x86_64/morestack.S @@ -100,8 +100,8 @@ MORESTACK: // 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__ @@ -111,7 +111,7 @@ MORESTACK: 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 |
