Skip to content

Commit 9002bfd

Browse files
committed
Auto merge of rust-lang#133045 - mrkajetanp:pauth-test-clang-lto-flag-merge, r=<try>
tests: Test pac-ret flag merging on clang with LTO Extend the test for pac-ret with clang and LTO by checking that different branch protection flags are preserved after the LTO step. There was an issue in older LLVM versions that was causing this to behave incorrectly. try-job: aarch64-gnu-debug
2 parents 76fd471 + 194471c commit 9002bfd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
//@ ignore-cross-compile
1111
// Reason: the compiled binary is executed
1212

13-
use run_make_support::{clang, env_var, llvm_ar, run, rustc, static_lib_name};
13+
use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, run, rustc, static_lib_name};
14+
15+
static PAUTH_A_KEY_PATTERN: &'static str = "paciasp";
16+
static PAUTH_B_KEY_PATTERN: &'static str = "pacibsp";
1417

1518
fn main() {
1619
clang()
1720
.arg("-v")
1821
.lto("thin")
19-
.arg("-mbranch-protection=bti+pac-ret+leaf")
20-
.arg("-O2")
22+
.arg("-mbranch-protection=bti+pac-ret+b-key+leaf")
2123
.arg("-c")
2224
.out_exe("test.o")
2325
.input("test.c")
@@ -32,5 +34,15 @@ fn main() {
3234
.input("test.rs")
3335
.output("test.bin")
3436
.run();
37+
38+
// Check that both a-key and b-key pac-ret survived LTO
39+
llvm_objdump()
40+
.disassemble()
41+
.input("test.bin")
42+
.run()
43+
.assert_stdout_contains_regex(PAUTH_A_KEY_PATTERN)
44+
.assert_stdout_contains_regex(PAUTH_B_KEY_PATTERN);
45+
46+
// Check that the binary actually runs
3547
run("test.bin");
3648
}

0 commit comments

Comments
 (0)