Skip to content

Commit c9bff74

Browse files
committed
Use jmp to implement __alloca fallthrough
1 parent b6091ab commit c9bff74

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/x86_64.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ pub unsafe fn ___chkstk_ms() {
3030
#[naked]
3131
#[cfg_attr(not(test), no_mangle)]
3232
pub unsafe fn __alloca() {
33-
asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx");
34-
// The original behavior had __alloca fall through to ___chkstk here, but
35-
// I don't believe that this behavior is guaranteed, and a program that uses
36-
// only __alloca could have ___chkstk removed by --gc-sections. Call
37-
// ___chkstk here to guarantee that neither of those happen.
38-
___chkstk();
33+
asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
34+
jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable");
35+
intrinsics::unreachable();
3936
}
4037

4138
#[cfg(windows)]

0 commit comments

Comments
 (0)