@@ -6,7 +6,6 @@ use core::intrinsics;
66// calling convention which can't be implemented using a normal Rust function
77
88// NOTE These functions are never mangled as they are not tested against compiler-rt
9- // and mangling ___chkstk would break the `jmp ___chkstk` instruction in __alloca
109
1110intrinsics ! {
1211 #[ naked]
@@ -36,49 +35,6 @@ intrinsics! {
3635 options( noreturn, att_syntax)
3736 ) ;
3837 }
39-
40- #[ naked]
41- #[ cfg( all(
42- any( all( windows, target_env = "gnu" ) , target_os = "uefi" ) ,
43- not( feature = "no-asm" )
44- ) ) ]
45- pub unsafe extern "C" fn __alloca( ) {
46- core:: arch:: asm!(
47- "mov %rcx,%rax" , // x64 _alloca is a normal function with parameter in rcx
48- "jmp ___chkstk" , // Jump to ___chkstk since fallthrough may be unreliable"
49- options( noreturn, att_syntax)
50- ) ;
51- }
52-
53- #[ naked]
54- #[ cfg( all(
55- any( all( windows, target_env = "gnu" ) , target_os = "uefi" ) ,
56- not( feature = "no-asm" )
57- ) ) ]
58- pub unsafe extern "C" fn ___chkstk( ) {
59- core:: arch:: asm!(
60- "push %rcx" ,
61- "cmp $0x1000,%rax" ,
62- "lea 16(%rsp),%rcx" , // rsp before calling this routine -> rcx
63- "jb 1f" ,
64- "2:" ,
65- "sub $0x1000,%rcx" ,
66- "test %rcx,(%rcx)" ,
67- "sub $0x1000,%rax" ,
68- "cmp $0x1000,%rax" ,
69- "ja 2b" ,
70- "1:" ,
71- "sub %rax,%rcx" ,
72- "test %rcx,(%rcx)" ,
73- "lea 8(%rsp),%rax" , // load pointer to the return address into rax
74- "mov %rcx,%rsp" , // install the new top of stack pointer into rsp
75- "mov -8(%rax),%rcx" , // restore rcx
76- "push (%rax)" , // push return address onto the stack
77- "sub %rsp,%rax" , // restore the original value in rax
78- "ret" ,
79- options( noreturn, att_syntax)
80- ) ;
81- }
8238}
8339
8440// HACK(https://github.com/rust-lang/rust/issues/62785): x86_64-unknown-uefi needs special LLVM
0 commit comments