]> git.lizzy.rs Git - rust.git/blob - tests/assembly/x86_64-naked-fn-no-cet-prolog.rs
Rollup merge of #107740 - oli-obk:lock_tcx, r=petrochenkov
[rust.git] / tests / assembly / x86_64-naked-fn-no-cet-prolog.rs
1 // compile-flags: -C no-prepopulate-passes -Zcf-protection=full
2 // assembly-output: emit-asm
3 // needs-asm-support
4 // only-x86_64
5
6 #![crate_type = "lib"]
7 #![feature(naked_functions)]
8 use std::arch::asm;
9
10 // The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
11 // meaning "no prologue whatsoever, no, really, not one instruction."
12 // Unfortunately, x86's control-flow enforcement, specifically indirect branch protection,
13 // works by using an instruction for each possible landing site,
14 // and LLVM implements this via making sure of that.
15 #[no_mangle]
16 #[naked]
17 pub unsafe extern "sysv64" fn will_halt() -> ! {
18     // CHECK-NOT: endbr{{32|64}}
19     // CHECK: hlt
20     asm!("hlt", options(noreturn))
21 }
22
23 // what about aarch64?
24 // "branch-protection"=false