Use `jmp` to implement __alloca fallthrough

This commit is contained in:
Matt Ickstadt 2016-08-17 12:11:38 -05:00
parent b6091ababa
commit c9bff743cd
1 changed files with 3 additions and 6 deletions

View File

@ -30,12 +30,9 @@ pub unsafe fn ___chkstk_ms() {
#[naked] #[naked]
#[cfg_attr(not(test), no_mangle)] #[cfg_attr(not(test), no_mangle)]
pub unsafe fn __alloca() { pub unsafe fn __alloca() {
asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx"); asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
// The original behavior had __alloca fall through to ___chkstk here, but jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable");
// I don't believe that this behavior is guaranteed, and a program that uses intrinsics::unreachable();
// only __alloca could have ___chkstk removed by --gc-sections. Call
// ___chkstk here to guarantee that neither of those happen.
___chkstk();
} }
#[cfg(windows)] #[cfg(windows)]