]> git.lizzy.rs Git - rust.git/blob - src/test/assembly/aarch64-naked-fn-no-bti-prolog.rs
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
[rust.git] / src / test / assembly / aarch64-naked-fn-no-bti-prolog.rs
1 // compile-flags: -C no-prepopulate-passes -Zbranch-protection=bti
2 // assembly-output: emit-asm
3 // needs-asm-support
4 // only-aarch64
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, aarch64's "branch target identification" works via hints at landing sites.
13 // LLVM implements this via making sure of that, even for functions with the naked attribute.
14 // So, we must emit an appropriate instruction instead!
15 #[no_mangle]
16 #[naked]
17 pub unsafe extern "C" fn _hlt() -> ! {
18     // CHECK-NOT: hint #34
19     // CHECK: hlt #0x1
20     asm!("hlt #1", options(noreturn))
21 }