From 7e238f997391be1ea5baf5e947eb99dcaf496ae2 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Wed, 17 Aug 2016 12:11:38 -0500 Subject: [PATCH] Use `jmp` to implement __alloca fallthrough --- library/compiler-builtins/src/x86_64.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/compiler-builtins/src/x86_64.rs b/library/compiler-builtins/src/x86_64.rs index 5df365c59318..8368593d6653 100644 --- a/library/compiler-builtins/src/x86_64.rs +++ b/library/compiler-builtins/src/x86_64.rs @@ -30,12 +30,9 @@ pub unsafe fn ___chkstk_ms() { #[naked] #[cfg_attr(not(test), no_mangle)] pub unsafe fn __alloca() { - 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 - // I don't believe that this behavior is guaranteed, and a program that uses - // only __alloca could have ___chkstk removed by --gc-sections. Call - // ___chkstk here to guarantee that neither of those happen. - ___chkstk(); + asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx + jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable"); + intrinsics::unreachable(); } #[cfg(windows)]