[llvm-branch-commits] [llvm] [BOLT][BTI] Add needed BTIs in LongJmp or refuse to optimize binary (PR #171149)

Peter Waller via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 8 07:51:01 PST 2025


================
@@ -0,0 +1,46 @@
+# This test checks that BOLT can generate BTI landing pads for targets of stubs inserted in LongJmp.
+
+# REQUIRES: system-linux
+
+# RUN: %clang %s %cflags -Wl,-q -o %t -mbranch-protection=bti -Wl,-z,force-bti
+# RUN: link_fdata --no-lbr %s %t %t.fdata
+# RUN: llvm-bolt %t -o %t.bolt --data %t.fdata -split-functions \
+# RUN: --print-split --print-only foo --print-longjmp 2>&1 | FileCheck %s
+
+#CHECK: BOLT-INFO: Starting stub-insertion pass
+#CHECK: Binary Function "foo" after long-jmp
+
+#CHECK:      cmp     x0, #0x0
+#CHECK-NEXT: Successors: .LStub0
+
+#CHECK:      adrp    x16, .Ltmp0
+#CHECK-NEXT: add     x16, x16, :lo12:.Ltmp0
+#CHECK-NEXT: br      x16 # UNKNOWN CONTROL FLOW
+
+#CHECK: -------   HOT-COLD SPLIT POINT   -------
+
+#CHECK:      bti     c
+#CHECK-NEXT: mov     x0, #0x2
+#CHECK-NEXT: ret
----------------
peterwaller-arm wrote:

Consistency: all of the above should begin `# CHECK`.

https://github.com/llvm/llvm-project/pull/171149


More information about the llvm-branch-commits mailing list