2021-07-13 06:14:26 -05:00
|
|
|
// Test that the correct module flags are emitted with different branch protection flags.
|
|
|
|
|
2024-10-16 09:39:58 -05:00
|
|
|
//@ revisions: BTI PACRET LEAF BKEY PAUTHLR PAUTHLR_BKEY PAUTHLR_LEAF PAUTHLR_BTI NONE
|
2021-07-13 06:14:26 -05:00
|
|
|
//@ needs-llvm-components: aarch64
|
2022-01-31 13:47:07 -06:00
|
|
|
//@ [BTI] compile-flags: -Z branch-protection=bti
|
|
|
|
//@ [PACRET] compile-flags: -Z branch-protection=pac-ret
|
|
|
|
//@ [LEAF] compile-flags: -Z branch-protection=pac-ret,leaf
|
|
|
|
//@ [BKEY] compile-flags: -Z branch-protection=pac-ret,b-key
|
2024-10-16 09:39:58 -05:00
|
|
|
//@ [PAUTHLR] compile-flags: -Z branch-protection=pac-ret,pc
|
|
|
|
//@ [PAUTHLR_BKEY] compile-flags: -Z branch-protection=pac-ret,pc,b-key
|
|
|
|
//@ [PAUTHLR_LEAF] compile-flags: -Z branch-protection=pac-ret,pc,leaf
|
|
|
|
//@ [PAUTHLR_BTI] compile-flags: -Z branch-protection=bti,pac-ret,pc
|
2021-07-13 06:14:26 -05:00
|
|
|
//@ compile-flags: --target aarch64-unknown-linux-gnu
|
2024-07-24 09:47:56 -05:00
|
|
|
//@ min-llvm-version: 19
|
2021-07-13 06:14:26 -05:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(no_core, lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
#[lang = "sized"]
|
|
|
|
trait Sized {}
|
2021-07-13 06:14:26 -05:00
|
|
|
|
|
|
|
// A basic test function.
|
2024-07-24 09:47:56 -05:00
|
|
|
// CHECK: @test(){{.*}} [[ATTR:#[0-9]+]] {
|
|
|
|
#[no_mangle]
|
2024-05-28 23:11:20 -05:00
|
|
|
pub fn test() {}
|
2021-07-13 06:14:26 -05:00
|
|
|
|
2024-07-24 09:47:56 -05:00
|
|
|
// BTI: attributes [[ATTR]] = {{.*}} "branch-target-enforcement"
|
2022-01-31 13:47:07 -06:00
|
|
|
// BTI: !"branch-target-enforcement", i32 1
|
|
|
|
// BTI: !"sign-return-address", i32 0
|
2024-10-16 09:39:58 -05:00
|
|
|
// BTI: !"branch-protection-pauth-lr", i32 0
|
2022-01-31 13:47:07 -06:00
|
|
|
// BTI: !"sign-return-address-all", i32 0
|
|
|
|
// BTI: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
2024-07-24 09:47:56 -05:00
|
|
|
// PACRET: attributes [[ATTR]] = {{.*}} "sign-return-address"="non-leaf"
|
|
|
|
// PACRET-SAME: "sign-return-address-key"="a_key"
|
2022-01-31 13:47:07 -06:00
|
|
|
// PACRET: !"branch-target-enforcement", i32 0
|
|
|
|
// PACRET: !"sign-return-address", i32 1
|
2024-10-16 09:39:58 -05:00
|
|
|
// PACRET: !"branch-protection-pauth-lr", i32 0
|
2022-01-31 13:47:07 -06:00
|
|
|
// PACRET: !"sign-return-address-all", i32 0
|
|
|
|
// PACRET: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
2024-07-24 09:47:56 -05:00
|
|
|
// LEAF: attributes [[ATTR]] = {{.*}} "sign-return-address"="all"
|
|
|
|
// LEAF-SAME: "sign-return-address-key"="a_key"
|
2022-01-31 13:47:07 -06:00
|
|
|
// LEAF: !"branch-target-enforcement", i32 0
|
|
|
|
// LEAF: !"sign-return-address", i32 1
|
2024-10-16 09:39:58 -05:00
|
|
|
// LEAF: !"branch-protection-pauth-lr", i32 0
|
2022-01-31 13:47:07 -06:00
|
|
|
// LEAF: !"sign-return-address-all", i32 1
|
|
|
|
// LEAF: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
2024-07-24 09:47:56 -05:00
|
|
|
// BKEY: attributes [[ATTR]] = {{.*}} "sign-return-address"="non-leaf"
|
|
|
|
// BKEY-SAME: "sign-return-address-key"="b_key"
|
2022-01-31 13:47:07 -06:00
|
|
|
// BKEY: !"branch-target-enforcement", i32 0
|
|
|
|
// BKEY: !"sign-return-address", i32 1
|
2024-10-16 09:39:58 -05:00
|
|
|
// BKEY: !"branch-protection-pauth-lr", i32 0
|
2022-01-31 13:47:07 -06:00
|
|
|
// BKEY: !"sign-return-address-all", i32 0
|
|
|
|
// BKEY: !"sign-return-address-with-bkey", i32 1
|
|
|
|
|
2024-10-16 09:39:58 -05:00
|
|
|
// PAUTHLR: attributes [[ATTR]] = {{.*}} "sign-return-address"="non-leaf"
|
|
|
|
// PAUTHLR-SAME: "sign-return-address-key"="a_key"
|
|
|
|
// PAUTHLR: !"branch-target-enforcement", i32 0
|
|
|
|
// PAUTHLR: !"sign-return-address", i32 1
|
|
|
|
// PAUTHLR: !"branch-protection-pauth-lr", i32 1
|
|
|
|
// PAUTHLR: !"sign-return-address-all", i32 0
|
|
|
|
// PAUTHLR: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
|
|
|
// PAUTHLR_BKEY: attributes [[ATTR]] = {{.*}} "sign-return-address"="non-leaf"
|
|
|
|
// PAUTHLR_BKEY-SAME: "sign-return-address-key"="b_key"
|
|
|
|
// PAUTHLR_BKEY: !"branch-target-enforcement", i32 0
|
|
|
|
// PAUTHLR_BKEY: !"sign-return-address", i32 1
|
|
|
|
// PAUTHLR_BKEY: !"branch-protection-pauth-lr", i32 1
|
|
|
|
// PAUTHLR_BKEY: !"sign-return-address-all", i32 0
|
|
|
|
// PAUTHLR_BKEY: !"sign-return-address-with-bkey", i32 1
|
|
|
|
|
|
|
|
// PAUTHLR_LEAF: attributes [[ATTR]] = {{.*}} "sign-return-address"="all"
|
|
|
|
// PAUTHLR_LEAF-SAME: "sign-return-address-key"="a_key"
|
|
|
|
// PAUTHLR_LEAF: !"branch-target-enforcement", i32 0
|
|
|
|
// PAUTHLR_LEAF: !"sign-return-address", i32 1
|
|
|
|
// PAUTHLR_LEAF: !"branch-protection-pauth-lr", i32 1
|
|
|
|
// PAUTHLR_LEAF: !"sign-return-address-all", i32 1
|
|
|
|
// PAUTHLR_LEAF: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
|
|
|
// PAUTHLR_BTI: attributes [[ATTR]] = {{.*}} "sign-return-address"="non-leaf"
|
|
|
|
// PAUTHLR_BTI-SAME: "sign-return-address-key"="a_key"
|
|
|
|
// PAUTHLR_BTI: !"branch-target-enforcement", i32 1
|
|
|
|
// PAUTHLR_BTI: !"sign-return-address", i32 1
|
|
|
|
// PAUTHLR_BTI: !"branch-protection-pauth-lr", i32 1
|
|
|
|
// PAUTHLR_BTI: !"sign-return-address-all", i32 0
|
|
|
|
// PAUTHLR_BTI: !"sign-return-address-with-bkey", i32 0
|
|
|
|
|
2022-01-31 13:47:07 -06:00
|
|
|
// NONE-NOT: branch-target-enforcement
|
|
|
|
// NONE-NOT: sign-return-address
|
|
|
|
// NONE-NOT: sign-return-address-all
|
|
|
|
// NONE-NOT: sign-return-address-with-bkey
|