[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:02 PST 2025
================
@@ -0,0 +1,35 @@
+# This test checks the situation where LongJmp adds a stub targeting an ignored (skipped) function.
+# The problem is that by default BOLT cannot modify ignored functions, so it cannot add the needed BTI.
+
+# Current behaviour is to emit an error.
+
+# REQUIRES: system-linux, asserts
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
+# RUN: -mattr=+bti -aarch64-mark-bti-property %s -o %t.o
+# RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q -Wl,-z,force-bti
+# RUN: not llvm-bolt %t.exe -o %t.bolt \
+# RUN: --align-text=0x10000000 --skip-funcs=far_away_func 2>&1 | FileCheck %s
+
+# CHECK: BOLT-ERROR: Cannot add BTI landing pad to ignored function far_away_func
+
+ .section .text
+ .global _start
+ .global far_away_func
+
+ .align 4
+ .global _start
+ .type _start, %function
+_start:
+ bti c
+ bl far_away_func
+ ret
+
+ .global far_away_func
----------------
peterwaller-arm wrote:
Worth a short comment to state that it is far away once bolt has run, because it is skipped, and why?
https://github.com/llvm/llvm-project/pull/171149
More information about the llvm-branch-commits
mailing list