forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add codegen option for branch protection and pointer authentication o…
…n AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets
- Loading branch information
1 parent
2446a21
commit 837cc16
Showing
12 changed files
with
266 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Test that PAC instructions are emitted when branch-protection is specified. | ||
|
||
// min-llvm-version: 10.0.1 | ||
// assembly-output: emit-asm | ||
// compile-flags: --target aarch64-unknown-linux-gnu | ||
// compile-flags: -C branch-protection=pac-ret+leaf | ||
// needs-llvm-components: aarch64 | ||
|
||
#![feature(no_core, lang_items)] | ||
#![no_std] | ||
#![no_core] | ||
#![crate_type = "lib"] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
// CHECK: hint #25 | ||
// CHECK: hint #29 | ||
#[no_mangle] | ||
pub fn test() -> u8 { | ||
42 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Test that the correct module flags are emitted with different branch protection flags. | ||
|
||
// revisions: bti pac-ret leaf b-key | ||
// min-llvm-version: 12.0.0 | ||
// needs-llvm-components: aarch64 | ||
// [bti] compile-flags: -C branch-protection=bti | ||
// [pac-ret] compile-flags: -C branch-protection=pac-ret | ||
// [leaf] compile-flags: -C branch-protection=pac-ret+leaf | ||
// [b-key] compile-flags: -C branch-protection=pac-ret+b-key | ||
// compile-flags: --target aarch64-unknown-linux-gnu | ||
|
||
#![crate_type = "lib"] | ||
#![feature(no_core, lang_items)] | ||
#![no_core] | ||
|
||
#[lang="sized"] | ||
trait Sized { } | ||
|
||
// A basic test function. | ||
pub fn test() { | ||
} | ||
|
||
// bti: !"branch-target-enforcement", i32 1 | ||
// bti: !"sign-return-address", i32 0 | ||
// bti: !"sign-return-address-all", i32 0 | ||
// bti: !"sign-return-address-with-bkey", i32 0 | ||
|
||
// pac-ret: !"branch-target-enforcement", i32 0 | ||
// pac-ret: !"sign-return-address", i32 1 | ||
// pac-ret: !"sign-return-address-all", i32 0 | ||
// pac-ret: !"sign-return-address-with-bkey", i32 0 | ||
|
||
// leaf: !"branch-target-enforcement", i32 0 | ||
// leaf: !"sign-return-address", i32 1 | ||
// leaf: !"sign-return-address-all", i32 1 | ||
// leaf: !"sign-return-address-with-bkey", i32 0 | ||
|
||
// b-key: !"branch-target-enforcement", i32 0 | ||
// b-key: !"sign-return-address", i32 1 | ||
// b-key: !"sign-return-address-all", i32 0 | ||
// b-key: !"sign-return-address-with-bkey", i32 1 |
14 changes: 14 additions & 0 deletions
14
src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-include ../tools.mk | ||
|
||
# only-aarch64 | ||
|
||
all: | ||
$(COMPILE_OBJ) $(TMPDIR)/test.o test.c | ||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o | ||
$(RUSTC) -C branch-protection=bti+pac-ret+leaf test.rs | ||
$(call RUN,test) | ||
|
||
$(COMPILE_OBJ) $(TMPDIR)/test.o test.c -mbranch-protection=bti+pac-ret+leaf | ||
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o | ||
$(RUSTC) -C branch-protection=bti+pac-ret+leaf test.rs | ||
$(call RUN,test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int foo() { return 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#[link(name = "test")] | ||
extern "C" { | ||
fn foo() -> i32; | ||
} | ||
|
||
fn main() { | ||
unsafe {foo();} | ||
} |