Fix segfault on probestack with dynamic alloca.

master
Masaki Hara 2018-05-27 23:28:17 +09:00
parent 28daccd915
commit 56293ad7c7
1 changed files with 7 additions and 0 deletions

View File

@ -64,6 +64,8 @@ pub unsafe extern fn __rust_probestack() {
// bytes pushed on the stack orginally with our return address. Using
// `8(%rsp)` simulates us testing the stack pointer in the caller's
// context.
cmp $$0x1000,%r11
jna 3f
2:
sub $$0x1000,%rsp
test %rsp,8(%rsp)
@ -71,6 +73,7 @@ pub unsafe extern fn __rust_probestack() {
cmp $$0x1000,%r11
ja 2b
3:
// Finish up the last remaining stack space requested, getting the last
// bits out of r11
sub %r11,%rsp
@ -98,6 +101,9 @@ pub unsafe extern fn __rust_probestack() {
asm!("
push %ecx
mov %eax,%ecx
cmp $$0x1000,%ecx
jna 3f
2:
sub $$0x1000,%esp
test %esp,8(%esp)
@ -105,6 +111,7 @@ pub unsafe extern fn __rust_probestack() {
cmp $$0x1000,%ecx
ja 2b
3:
sub %ecx,%esp
test %esp,8(%esp)