about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-15 19:05:18 +0100
committerGitHub <noreply@github.com>2024-11-15 19:05:18 +0100
commit249a9100a36f8fd8d79f3733cfa8e6aec0d9f9a3 (patch)
tree2dd63036d99d1334c31081b8f517525ab22f7d69
parent6963572c78510873e6e4ed1b7052fde732573512 (diff)
parent194471cbd4a679ed18b22adfebd7ba4650417a69 (diff)
downloadrust-249a9100a36f8fd8d79f3733cfa8e6aec0d9f9a3.tar.gz
rust-249a9100a36f8fd8d79f3733cfa8e6aec0d9f9a3.zip
Rollup merge of #133045 - mrkajetanp:pauth-test-clang-lto-flag-merge, r=jieyouxu
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
-rw-r--r--tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs b/tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs
index cf6e3d86377..0a2186b0953 100644
--- a/tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs
+++ b/tests/run-make/pointer-auth-link-with-c-lto-clang/rmake.rs
@@ -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")
@@ -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");
 }