summary refs log tree commit diff
path: root/tests/assembly/aarch64-naked-fn-no-bti-prolog.rs
blob: 46e627eaa00bd5154256832b5c1e44fee8512b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ compile-flags: -C no-prepopulate-passes -Zbranch-protection=bti
//@ assembly-output: emit-asm
//@ needs-asm-support
//@ only-aarch64

#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
// Unfortunately, aarch64's "branch target identification" works via hints at landing sites.
// LLVM implements this via making sure of that, even for functions with the naked attribute.
// So, we must emit an appropriate instruction instead!
#[no_mangle]
#[naked]
pub unsafe extern "C" fn _hlt() -> ! {
    // CHECK-NOT: hint #34
    // CHECK: hlt #0x1
    naked_asm!("hlt #1")
}