Skip to content

Commit ef20afc

Browse files
committed
rt: Get 64-bit Linux __morestack allocating new stacks
1 parent 4dcb0ee commit ef20afc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/rt/arch/x86_64/morestack.S

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
.type MORESTACK,@function
4949
#endif
5050

51+
#if defined(__linux)
5152
MORESTACK:
5253
.cfi_startproc
5354

@@ -71,19 +72,23 @@ MORESTACK:
7172
addq $16, %rcx // Add the saved %rbp, and return address
7273
addq %r11, %rcx // Add the size of stack arguments
7374

74-
pushq %r10 // The amount of stack needed
75-
pushq %rcx // Address of stack arguments
76-
pushq %r11 // Size of stack arguments
7775
pushq %rbp // Save the Rust stack pointer
76+
pushq %r11 // Size of stack arguments
77+
pushq %rcx // Address of stack arguments
78+
pushq %r10 // The amount of stack needed
7879

7980
// FIXME: Don't understand why I have to use the PLT here
8081
lea RUST_NEW_STACK2@PLT(%rip), %rsi
81-
lea 24(%rsp), %rdi
82+
mov %rsp, %rdi
8283
call UPCALL_CALL_C@PLT
8384

8485
mov (%rsp),%rdx // Grab the return pointer.
8586
inc %rdx // Skip past the `ret`.
8687
mov %rax,%rsp // Switch to the new stack.
8788
call *%rdx // Enter the new function.
8889

89-
.cfi_endproc
90+
.cfi_endproc
91+
#else
92+
MORESTACK:
93+
ret
94+
#endif

0 commit comments

Comments
 (0)