| 
7 | 7 | #![unstable(feature = "panic_abort", issue = "32837")]  | 
8 | 8 | #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]  | 
9 | 9 | #![panic_runtime]  | 
10 |  | -#![allow(unused_features)]  | 
11 |  | -#![feature(asm_experimental_arch)]  | 
12 |  | -#![feature(core_intrinsics)]  | 
13 | 10 | #![feature(panic_runtime)]  | 
14 | 11 | #![feature(std_internals)]  | 
15 | 12 | #![feature(staged_api)]  | 
16 | 13 | #![feature(rustc_attrs)]  | 
17 | 14 | #![allow(internal_features)]  | 
18 |  | -#![deny(unsafe_op_in_unsafe_fn)]  | 
19 | 15 | 
 
  | 
20 | 16 | #[cfg(target_os = "android")]  | 
21 | 17 | mod android;  | 
@@ -45,75 +41,13 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 {  | 
45 | 41 |         zkvm::zkvm_set_abort_message(_payload);  | 
46 | 42 |     }  | 
47 | 43 | 
 
  | 
48 |  | -    unsafe {  | 
49 |  | -        abort();  | 
 | 44 | +    unsafe extern "Rust" {  | 
 | 45 | +        // This is defined in std::rt.  | 
 | 46 | +        #[cfg_attr(not(bootstrap), rustc_std_internal_symbol)]  | 
 | 47 | +        safe fn __rust_abort() -> !;  | 
50 | 48 |     }  | 
51 | 49 | 
 
  | 
52 |  | -    cfg_if::cfg_if! {  | 
53 |  | -        if #[cfg(any(unix, target_os = "solid_asp3"))] {  | 
54 |  | -            unsafe fn abort() -> ! {  | 
55 |  | -                unsafe { libc::abort(); }  | 
56 |  | -            }  | 
57 |  | -        } else if #[cfg(any(target_os = "hermit",  | 
58 |  | -                            all(target_vendor = "fortanix", target_env = "sgx"),  | 
59 |  | -                            target_os = "xous",  | 
60 |  | -                            target_os = "uefi",  | 
61 |  | -        ))] {  | 
62 |  | -            unsafe fn abort() -> ! {  | 
63 |  | -                // call std::sys::abort_internal  | 
64 |  | -                unsafe extern "C" {  | 
65 |  | -                    pub fn __rust_abort() -> !;  | 
66 |  | -                }  | 
67 |  | -                unsafe { __rust_abort(); }  | 
68 |  | -            }  | 
69 |  | -        } else if #[cfg(all(windows, not(miri)))] {  | 
70 |  | -            // On Windows, use the processor-specific __fastfail mechanism. In Windows 8  | 
71 |  | -            // and later, this will terminate the process immediately without running any  | 
72 |  | -            // in-process exception handlers. In earlier versions of Windows, this  | 
73 |  | -            // sequence of instructions will be treated as an access violation,  | 
74 |  | -            // terminating the process but without necessarily bypassing all exception  | 
75 |  | -            // handlers.  | 
76 |  | -            //  | 
77 |  | -            // https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail  | 
78 |  | -            //  | 
79 |  | -            // Note: this is the same implementation as in std's `abort_internal`  | 
80 |  | -            unsafe fn abort() -> ! {  | 
81 |  | -                #[allow(unused)]  | 
82 |  | -                const FAST_FAIL_FATAL_APP_EXIT: usize = 7;  | 
83 |  | -                cfg_if::cfg_if! {  | 
84 |  | -                    if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {  | 
85 |  | -                        unsafe {  | 
86 |  | -                            core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));  | 
87 |  | -                        }  | 
88 |  | -                    } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] {  | 
89 |  | -                        unsafe {  | 
90 |  | -                            core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));  | 
91 |  | -                        }  | 
92 |  | -                    } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] {  | 
93 |  | -                        unsafe {  | 
94 |  | -                            core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack));  | 
95 |  | -                        }  | 
96 |  | -                    } else {  | 
97 |  | -                        core::intrinsics::abort();  | 
98 |  | -                    }  | 
99 |  | -                }  | 
100 |  | -            }  | 
101 |  | -        } else if #[cfg(target_os = "teeos")] {  | 
102 |  | -            mod teeos {  | 
103 |  | -                unsafe extern "C" {  | 
104 |  | -                    pub fn TEE_Panic(code: u32) -> !;  | 
105 |  | -                }  | 
106 |  | -            }  | 
107 |  | - | 
108 |  | -            unsafe fn abort() -> ! {  | 
109 |  | -                unsafe { teeos::TEE_Panic(1); }  | 
110 |  | -            }  | 
111 |  | -        } else {  | 
112 |  | -            unsafe fn abort() -> ! {  | 
113 |  | -                core::intrinsics::abort();  | 
114 |  | -            }  | 
115 |  | -        }  | 
116 |  | -    }  | 
 | 50 | +    __rust_abort()  | 
117 | 51 | }  | 
118 | 52 | 
 
  | 
119 | 53 | // This... is a bit of an oddity. The tl;dr; is that this is required to link  | 
 | 
0 commit comments