Skip to content

Commit ab13be7

Browse files
committed
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.
1 parent 583b25d commit ab13be7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +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")
22+
.arg("-mbranch-protection=bti+pac-ret+b-key+leaf")
2023
.arg("-O2")
2124
.arg("-c")
2225
.out_exe("test.o")
@@ -32,5 +35,15 @@ fn main() {
3235
.input("test.rs")
3336
.output("test.bin")
3437
.run();
38+
39+
// Check that both a-key and b-key pac-ret survived LTO
40+
llvm_objdump()
41+
.disassemble()
42+
.input("test.bin")
43+
.run()
44+
.assert_stdout_contains_regex(PAUTH_A_KEY_PATTERN)
45+
.assert_stdout_contains_regex(PAUTH_B_KEY_PATTERN);
46+
47+
// Check that the binary actually runs
3548
run("test.bin");
3649
}

0 commit comments

Comments
 (0)