Skip to content

Commit

Permalink
Auto merge of rust-lang#133045 - mrkajetanp:pauth-test-clang-lto-flag…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
bors committed Nov 15, 2024
2 parents 76fd471 + 194471c commit 9002bfd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{clang, env_var, llvm_ar, run, rustc, static_lib_name};
use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, run, rustc, static_lib_name};

static PAUTH_A_KEY_PATTERN: &'static str = "paciasp";
static PAUTH_B_KEY_PATTERN: &'static str = "pacibsp";

fn main() {
clang()
.arg("-v")
.lto("thin")
.arg("-mbranch-protection=bti+pac-ret+leaf")
.arg("-O2")
.arg("-mbranch-protection=bti+pac-ret+b-key+leaf")
.arg("-c")
.out_exe("test.o")
.input("test.c")
Expand All @@ -32,5 +34,15 @@ fn main() {
.input("test.rs")
.output("test.bin")
.run();

// Check that both a-key and b-key pac-ret survived LTO
llvm_objdump()
.disassemble()
.input("test.bin")
.run()
.assert_stdout_contains_regex(PAUTH_A_KEY_PATTERN)
.assert_stdout_contains_regex(PAUTH_B_KEY_PATTERN);

// Check that the binary actually runs
run("test.bin");
}

0 comments on commit 9002bfd

Please sign in to comment.