From e24abdec272f3bbf5307b0afde3df40ab0ca27a4 Mon Sep 17 00:00:00 2001 From: Paschalis Mpeis Date: Tue, 24 Jun 2025 16:03:05 +0100 Subject: [PATCH 1/3] [BOLT][AArch64] Skip gadget pacret test on RHEL8 --- bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s | 3 ++- bolt/test/lit.cfg.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s b/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s index 284f0bea607a5..855fdb6465479 100644 --- a/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s +++ b/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s @@ -1,3 +1,5 @@ +// REQUIRES: !rhel8 + // RUN: %clang %cflags -march=armv9.5-a+pauth-lr -mbranch-protection=pac-ret %s %p/../../Inputs/asm_main.c -o %t.exe // RUN: llvm-bolt-binary-analysis --scanners=pacret %t.exe 2>&1 | FileCheck %s @@ -883,4 +885,3 @@ f_autib171615: // CHECK-NEXT: {{[0-9a-f]+}}: ret ret .size f_autib171615, .-f_autib171615 - diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py index 0d05229be2bf3..820a910430920 100644 --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -75,6 +75,11 @@ if lit.util.which("fuser"): config.available_features.add("fuser") +rhel_release="/etc/redhat-release" +if os.path.exists(rhel_release) and \ + "release 8" in open(rhel_release).read().lower(): + config.available_features.add("rhel8") + llvm_config.use_default_substitutions() llvm_config.config.environment["CLANG"] = config.bolt_clang From f324145b7676ecc88006b557c9121e1bef5104bf Mon Sep 17 00:00:00 2001 From: Paschalis Mpeis Date: Tue, 24 Jun 2025 16:14:36 +0100 Subject: [PATCH 2/3] fix: py code formatter --- bolt/test/lit.cfg.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py index 820a910430920..25c9e52d2e26f 100644 --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -75,9 +75,8 @@ if lit.util.which("fuser"): config.available_features.add("fuser") -rhel_release="/etc/redhat-release" -if os.path.exists(rhel_release) and \ - "release 8" in open(rhel_release).read().lower(): +rhel_release = "/etc/redhat-release" +if os.path.exists(rhel_release) and "release 8" in open(rhel_release).read().lower(): config.available_features.add("rhel8") llvm_config.use_default_substitutions() From e6a49de64ce611234a96c3b3ecb157e65b8b0585 Mon Sep 17 00:00:00 2001 From: Paschalis Mpeis Date: Wed, 25 Jun 2025 13:37:57 +0100 Subject: [PATCH 3/3] [BOLT][AArch64] Make gs-pacret-autiasp.s deterministic In gs-pacret-autiasp.s, the undefined call `bl g` causes inconsistent basic block splitting: in some platforms BOLT emits two blocks, on some others one. Defining a dummy `g` symbol forces a single basic block everywhere. --- .../AArch64/gs-pacret-autiasp.s | 77 ++++++++++++++++++- bolt/test/lit.cfg.py | 4 - 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s b/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s index 855fdb6465479..bbb42603dec57 100644 --- a/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s +++ b/bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s @@ -1,5 +1,3 @@ -// REQUIRES: !rhel8 - // RUN: %clang %cflags -march=armv9.5-a+pauth-lr -mbranch-protection=pac-ret %s %p/../../Inputs/asm_main.c -o %t.exe // RUN: llvm-bolt-binary-analysis --scanners=pacret %t.exe 2>&1 | FileCheck %s @@ -20,6 +18,10 @@ f1: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: ret @@ -42,6 +44,10 @@ f_intermediate_overwrite1: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: autiasp // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 @@ -65,6 +71,10 @@ f_intermediate_overwrite2: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: mov x30, x0 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autiasp @@ -104,6 +114,10 @@ f_intermediate_overwrite3: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: mov w30, w0 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autiasp @@ -128,6 +142,10 @@ f_nonx30_ret: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: mov x16, x30 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: mov x16, x30 @@ -314,6 +332,10 @@ f_autia1716: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autia1716 @@ -336,6 +358,10 @@ f_autib1716: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autib1716 @@ -358,6 +384,10 @@ f_autiax12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autia x12, sp @@ -380,6 +410,10 @@ f_autibx12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autib x12, sp @@ -431,6 +465,10 @@ f_autdax12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autda x12, sp @@ -453,6 +491,10 @@ f_autdbx12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autdb x12, sp @@ -504,6 +546,10 @@ f_autizax12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autiza x12 @@ -526,6 +572,10 @@ f_autizbx12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autizb x12 @@ -577,6 +627,10 @@ f_autdzax12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autdza x12 @@ -599,6 +653,10 @@ f_autdzbx12: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autdzb x12 @@ -857,6 +915,10 @@ f_autia171615: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autia171615 @@ -879,9 +941,20 @@ f_autib171615: // CHECK-NEXT: The 1 instructions that write to the affected registers after any authentication are: // CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: This happens in the following basic block: +// CHECK-NEXT: {{[0-9a-f]+}}: paciasp +// CHECK-NEXT: {{[0-9a-f]+}}: stp x29, x30, [sp, #-0x10]! +// CHECK-NEXT: {{[0-9a-f]+}}: mov x29, sp +// CHECK-NEXT: {{[0-9a-f]+}}: bl g // CHECK-NEXT: {{[0-9a-f]+}}: add x0, x0, #0x3 // CHECK-NEXT: {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10 // CHECK-NEXT: {{[0-9a-f]+}}: autib171615 // CHECK-NEXT: {{[0-9a-f]+}}: ret ret .size f_autib171615, .-f_autib171615 + + .globl g + .type g,@function +g: + nop + ret + .size g, .-g diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py index 25c9e52d2e26f..0d05229be2bf3 100644 --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -75,10 +75,6 @@ if lit.util.which("fuser"): config.available_features.add("fuser") -rhel_release = "/etc/redhat-release" -if os.path.exists(rhel_release) and "release 8" in open(rhel_release).read().lower(): - config.available_features.add("rhel8") - llvm_config.use_default_substitutions() llvm_config.config.environment["CLANG"] = config.bolt_clang