[llvm] [BOLT][BTI] Refactor: move applyBTIFixup under MCPlusBuilder (PR #177164)

Gergely Bálint via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 05:34:55 PST 2026


https://github.com/bgergely0 updated https://github.com/llvm/llvm-project/pull/177164

>From 90b94f1125ebce12933eac73678b405631211964 Mon Sep 17 00:00:00 2001
From: Gergely Balint <gergely.balint at arm.com>
Date: Mon, 5 Jan 2026 14:11:23 +0000
Subject: [PATCH 1/2] [BOLT][BTI] Refactor: move applyBTIFixup under
 MCPlusBuilder

applyBTIFixup is checking the "type" of target functions of short/long
stubs, and applies BTI fixup at these targets.
While previously it was only used in LongJmp pass, this refactor allows
this function to be called from other passes inserting indirect
branches, such as:
- Hugify,
- PatchEntries.

As different passes have different information about their targets (e.g.
target BasicBlock, target Symbol, target Function), specialized versions
are created (applyBTIFixupToSymbol, applyBTIFixupToTarget), and each calls
applyBTIFixupCommon, which implements the original logic from before.
---
 bolt/include/bolt/Core/MCPlusBuilder.h        | 15 +++++
 bolt/lib/Passes/Hugify.cpp                    |  7 ++-
 bolt/lib/Passes/LongJmp.cpp                   | 60 ++----------------
 bolt/lib/Passes/PatchEntries.cpp              |  3 +
 .../Target/AArch64/AArch64MCPlusBuilder.cpp   | 63 +++++++++++++++++++
 bolt/test/AArch64/patch-entries-bti.s         | 39 ++++++++++++
 bolt/test/runtime/AArch64/hugify-bti.c        | 30 +++++++++
 7 files changed, 160 insertions(+), 57 deletions(-)
 create mode 100644 bolt/test/AArch64/patch-entries-bti.s
 create mode 100644 bolt/test/runtime/AArch64/hugify-bti.c

diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h
index e571e91d85135..b78270b312980 100644
--- a/bolt/include/bolt/Core/MCPlusBuilder.h
+++ b/bolt/include/bolt/Core/MCPlusBuilder.h
@@ -1787,6 +1787,21 @@ class MCPlusBuilder {
     llvm_unreachable("not implemented");
   }
 
+  virtual void applyBTIFixupToTarget(BinaryBasicBlock &StubBB) {
+    llvm_unreachable("not implemented");
+  }
+
+  virtual void applyBTIFixupToSymbol(BinaryContext &BC, const MCSymbol *Symbol,
+                                     MCInst &Call) {
+    llvm_unreachable("not implemented");
+  }
+
+  virtual void applyBTIFixupCommon(const MCSymbol *RealTargetSym,
+                                   BinaryFunction *TgtFunction,
+                                   BinaryBasicBlock *TgtBB, MCInst &Call) {
+    llvm_unreachable("not implemented");
+  }
+
   virtual bool analyzeVirtualMethodCall(InstructionIterator Begin,
                                         InstructionIterator End,
                                         std::vector<MCInst *> &MethodFetchInsns,
diff --git a/bolt/lib/Passes/Hugify.cpp b/bolt/lib/Passes/Hugify.cpp
index 1ac1b08573b86..2f240b7cdeb19 100644
--- a/bolt/lib/Passes/Hugify.cpp
+++ b/bolt/lib/Passes/Hugify.cpp
@@ -42,8 +42,11 @@ Error HugePage::runOnFunctions(BinaryContext &BC) {
       BC.getBinaryFunctionAtAddress(*BC.StartFunctionAddress);
   assert(Start && "Entry point function not found");
   const MCSymbol *StartSym = Start->getSymbol();
-  createSimpleFunction("__bolt_hugify_start_program",
-                       BC.MIB->createSymbolTrampoline(StartSym, BC.Ctx.get()));
+  InstructionListType Insts =
+      BC.MIB->createSymbolTrampoline(StartSym, BC.Ctx.get());
+  createSimpleFunction("__bolt_hugify_start_program", Insts);
+  if (BC.usesBTI())
+    BC.MIB->applyBTIFixupToSymbol(BC, StartSym, *(Insts.end() - 1));
   return Error::success();
 }
 } // namespace bolt
diff --git a/bolt/lib/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp
index 798e1ba08918a..5b8cbe623dea6 100644
--- a/bolt/lib/Passes/LongJmp.cpp
+++ b/bolt/lib/Passes/LongJmp.cpp
@@ -43,6 +43,8 @@ static void relaxStubToShortJmp(BinaryBasicBlock &StubBB, const MCSymbol *Tgt) {
   BC.MIB->createShortJmp(Seq, Tgt, BC.Ctx.get());
   StubBB.clear();
   StubBB.addInstructions(Seq.begin(), Seq.end());
+  if (BC.usesBTI())
+    BC.MIB->applyBTIFixupToTarget(StubBB);
 }
 
 static void relaxStubToLongJmp(BinaryBasicBlock &StubBB, const MCSymbol *Tgt) {
@@ -51,6 +53,8 @@ static void relaxStubToLongJmp(BinaryBasicBlock &StubBB, const MCSymbol *Tgt) {
   BC.MIB->createLongJmp(Seq, Tgt, BC.Ctx.get());
   StubBB.clear();
   StubBB.addInstructions(Seq.begin(), Seq.end());
+  if (BC.usesBTI())
+    BC.MIB->applyBTIFixupToTarget(StubBB);
 }
 
 static BinaryBasicBlock *getBBAtHotColdSplitPoint(BinaryFunction &Func) {
@@ -484,62 +488,12 @@ Error LongJmpPass::relaxStub(BinaryBasicBlock &StubBB, bool &Modified) {
       ~((1ULL << (RangeSingleInstr - 1)) - 1);
 
   const MCSymbol *RealTargetSym = BC.MIB->getTargetSymbol(*StubBB.begin());
-  BinaryBasicBlock *TgtBB = Func.getBasicBlockForLabel(RealTargetSym);
-  BinaryFunction *TargetFunction = BC.getFunctionForSymbol(RealTargetSym);
+  const BinaryBasicBlock *TgtBB = Func.getBasicBlockForLabel(RealTargetSym);
   uint64_t TgtAddress = getSymbolAddress(BC, RealTargetSym, TgtBB);
   uint64_t DotAddress = BBAddresses[&StubBB];
   uint64_t PCRelTgtAddress = DotAddress > TgtAddress ? DotAddress - TgtAddress
                                                      : TgtAddress - DotAddress;
 
-  auto applyBTIFixup = [&](BinaryFunction *TargetFunction,
-                           BinaryBasicBlock *RealTgtBB) {
-    // TODO: add support for editing each type, and remove errors.
-    if (!TargetFunction && !RealTgtBB) {
-      BC.errs() << "BOLT-ERROR: Cannot add BTI to function with symbol "
-                << RealTargetSym->getName() << "\n";
-      exit(1);
-    }
-    if (TargetFunction && TargetFunction->isPLTFunction()) {
-      BC.MIB->patchPLTEntryForBTI(*TargetFunction,
-                                  *StubBB.getLastNonPseudoInstr());
-      return;
-    }
-    if (TargetFunction && TargetFunction->isIgnored()) {
-      // Includes PLT functions.
-      BC.errs() << "BOLT-ERROR: Cannot add BTI landing pad to ignored function "
-                << TargetFunction->getPrintName() << "\n";
-      exit(1);
-    }
-    if (TargetFunction && !TargetFunction->hasCFG()) {
-      if (TargetFunction->hasInstructions()) {
-        auto FirstII = TargetFunction->instrs().begin();
-        MCInst FirstInst = FirstII->second;
-        if (BC.MIB->isCallCoveredByBTI(*StubBB.getLastNonPseudoInstr(),
-                                       FirstInst))
-          return;
-      }
-      BC.errs()
-          << "BOLT-ERROR: Cannot add BTI landing pad to function without CFG: "
-          << TargetFunction->getPrintName() << "\n";
-      exit(1);
-    }
-    if (!RealTgtBB)
-      // !RealTgtBB -> TargetFunction is not a nullptr
-      RealTgtBB = &*TargetFunction->begin();
-    if (RealTgtBB) {
-      if (!RealTgtBB->hasParent()) {
-        BC.errs() << "BOLT-ERROR: Cannot add BTI to block with no parent "
-                     "function. Targeted symbol: "
-                  << RealTargetSym->getName() << "\n";
-        exit(1);
-      }
-      // The BR is the last inst of the StubBB.
-      BC.MIB->insertBTI(*RealTgtBB, *StubBB.getLastNonPseudoInstr());
-      return;
-    }
-    BC.errs() << "BOLT-ERROR: unhandled case when applying BTI fixup\n";
-    exit(1);
-  };
   // If it fits in one instruction, do not relax
   if (!(PCRelTgtAddress & SingleInstrMask))
     return Error::success();
@@ -554,8 +508,6 @@ Error LongJmpPass::relaxStub(BinaryBasicBlock &StubBB, bool &Modified) {
                       << " RealTargetSym = " << RealTargetSym->getName()
                       << "\n");
     relaxStubToShortJmp(StubBB, RealTargetSym);
-    if (BC.usesBTI())
-      applyBTIFixup(TargetFunction, TgtBB);
     StubBits[&StubBB] = RangeShortJmp;
     Modified = true;
     return Error::success();
@@ -571,8 +523,6 @@ Error LongJmpPass::relaxStub(BinaryBasicBlock &StubBB, bool &Modified) {
                     << Twine::utohexstr(PCRelTgtAddress)
                     << " RealTargetSym = " << RealTargetSym->getName() << "\n");
   relaxStubToLongJmp(StubBB, RealTargetSym);
-  if (BC.usesBTI())
-    applyBTIFixup(TargetFunction, TgtBB);
   StubBits[&StubBB] = static_cast<int>(BC.AsmInfo->getCodePointerSize() * 8);
   Modified = true;
   return Error::success();
diff --git a/bolt/lib/Passes/PatchEntries.cpp b/bolt/lib/Passes/PatchEntries.cpp
index 55f7513615e7d..7f3bb6c5c4bfd 100644
--- a/bolt/lib/Passes/PatchEntries.cpp
+++ b/bolt/lib/Passes/PatchEntries.cpp
@@ -114,6 +114,9 @@ Error PatchEntries::runOnFunctions(BinaryContext &BC) {
       BinaryFunction *PatchFunction = BC.createInstructionPatch(
           Patch.Address, Instructions,
           NameResolver::append(Patch.Symbol->getName(), ".org.0"));
+      if (BC.usesBTI())
+        BC.MIB->applyBTIFixupToSymbol(BC, Patch.Symbol,
+                                      *(Instructions.end() - 1));
 
       // Verify the size requirements.
       uint64_t HotSize, ColdSize;
diff --git a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
index aa5cf3c671cdc..fea3a937046ad 100644
--- a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
+++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
@@ -1733,6 +1733,69 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
     BC.createInstructionPatch(PLTFunction.getAddress(), NewPLTSeq);
   }
 
+  void applyBTIFixupToSymbol(BinaryContext &BC, const MCSymbol *TargetSymbol,
+                             MCInst &Call) override {
+    BinaryFunction *TargetFunction = BC.getFunctionForSymbol(TargetSymbol);
+    applyBTIFixupCommon(TargetSymbol, TargetFunction, nullptr, Call);
+  }
+
+  void applyBTIFixupToTarget(BinaryBasicBlock &StubBB) override {
+    BinaryFunction &Func = *StubBB.getFunction();
+    BinaryContext &BC = Func.getBinaryContext();
+    const MCSymbol *RealTargetSym = BC.MIB->getTargetSymbol(*StubBB.begin());
+    BinaryFunction *TargetFunction = BC.getFunctionForSymbol(RealTargetSym);
+    BinaryBasicBlock *TgtBB = Func.getBasicBlockForLabel(RealTargetSym);
+    applyBTIFixupCommon(RealTargetSym, TargetFunction, TgtBB,
+                        *StubBB.getLastNonPseudoInstr());
+  }
+
+  void applyBTIFixupCommon(const MCSymbol *RealTargetSym,
+                           BinaryFunction *TargetFunction,
+                           BinaryBasicBlock *TargetBB, MCInst &Call) override {
+    // TODO: add support for editing each type, and remove errors.
+    if (!TargetFunction && !TargetBB) {
+      errs() << "BOLT-ERROR: Cannot add BTI to function with symbol "
+             << RealTargetSym->getName() << "\n";
+      exit(1);
+    }
+    if (TargetFunction && TargetFunction->isPLTFunction()) {
+      patchPLTEntryForBTI(*TargetFunction, Call);
+      return;
+    }
+    if (TargetFunction && TargetFunction->isIgnored()) {
+      errs() << "BOLT-ERROR: Cannot add BTI landing pad to ignored function "
+             << TargetFunction->getPrintName() << "\n";
+      exit(1);
+    }
+    if (TargetFunction && !TargetFunction->hasCFG()) {
+      if (TargetFunction->hasInstructions()) {
+        auto FirstII = TargetFunction->instrs().begin();
+        MCInst FirstInst = FirstII->second;
+        if (isCallCoveredByBTI(Call, FirstInst))
+          return;
+      }
+      errs()
+          << "BOLT-ERROR: Cannot add BTI landing pad to function without CFG: "
+          << TargetFunction->getPrintName() << "\n";
+      exit(1);
+    }
+    if (!TargetBB)
+      // !TargetBB -> TargetFunction is not a nullptr
+      TargetBB = &*TargetFunction->begin();
+    if (TargetBB) {
+      if (!TargetBB->hasParent()) {
+        errs() << "BOLT-ERROR: Cannot add BTI to block with no parent "
+                  "function. Targeted symbol: "
+               << RealTargetSym->getName() << "\n";
+        exit(1);
+      }
+      insertBTI(*TargetBB, Call);
+      return;
+    }
+    errs() << "BOLT-ERROR: unhandled case when applying BTI fixup\n";
+    exit(1);
+  }
+
   unsigned getInvertedBranchOpcode(unsigned Opcode) const {
     switch (Opcode) {
     default:
diff --git a/bolt/test/AArch64/patch-entries-bti.s b/bolt/test/AArch64/patch-entries-bti.s
new file mode 100644
index 0000000000000..0dea0f00367ee
--- /dev/null
+++ b/bolt/test/AArch64/patch-entries-bti.s
@@ -0,0 +1,39 @@
+# This test checks that BOLT can add BTI to targets at patched entries.
+
+# REQUIRES: system-linux
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
+# RUN:   %s -o %t.o
+# RUN: %clang %cflags -pie %t.o -o %t.exe -nostdlib -Wl,-q,-z,force-bti
+# RUN: llvm-bolt %t.exe -o %t.bolt --use-old-text=0 --lite=0 --skip-funcs=_start | FileCheck %s --check-prefix=CHECK-BOLT
+# RUN: llvm-objdump -dz %t.bolt | FileCheck %s
+
+# CHECK-BOLT: binary is using BTI
+
+# CHECK: <pathedEntries.org.0>:
+# CHECK-NEXT: adrp x16, 0x[[#%x,ADRP:]]
+# CHECK-NEXT: add x16, x16, #0x[[#%x,ADD:]]
+# CHECK-NEXT: br x16
+
+# CHECK: [[#ADRP + ADD]] <pathedEntries>:
+# CHECK-NEXT: [[#ADRP + ADD]]: {{.*}} bti c
+# CHECK-NEXT: ret
+
+.text
+.balign 4
+.global pathedEntries
+.type pathedEntries, %function
+pathedEntries:
+  .rept 32
+  nop
+  .endr
+  ret
+.size pathedEntries, .-pathedEntries
+
+.global _start
+.type _start, %function
+_start:
+  bl pathedEntries
+  .inst 0xdeadbeef
+  ret
+.size _start, .-_start
diff --git a/bolt/test/runtime/AArch64/hugify-bti.c b/bolt/test/runtime/AArch64/hugify-bti.c
new file mode 100644
index 0000000000000..6620bca0f63e7
--- /dev/null
+++ b/bolt/test/runtime/AArch64/hugify-bti.c
@@ -0,0 +1,30 @@
+// Make sure that during the Hugify pass BOLT adds a BTI instruction to _start.
+
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+  printf("Hello world\n");
+  return 0;
+}
+
+/*
+REQUIRES: system-linux,bolt-runtime
+
+RUN: %clang %cflags -mbranch-protection=standard -no-pie %s -o %t.nopie.exe \
+RUN: -Wl,-q,-z,force-bti
+RUN: %clang %cflags -mbranch-protection=standard -fpic %s -o %t.pie.exe \
+RUN: -Wl,-q,-z,force-bti
+
+RUN: llvm-bolt %t.nopie.exe --lite=0 -o %t.nopie --hugify | FileCheck %s \
+RUN: -check-prefix=CHECK-BOLT
+RUN: llvm-bolt %t.pie.exe --lite=0 -o %t.pie --hugify | FileCheck %s \
+RUN: -check-prefix=CHECK-BOLT
+
+CHECK-BOLT: binary is using BTI
+
+RUN: llvm-objdump -D %t.nopie | FileCheck %s -check-prefix=CHECK-OBJDUMP
+RUN: llvm-objdump -D %t.pie | FileCheck %s -check-prefix=CHECK-OBJDUMP
+
+CHECK-OBJDUMP: <_start>:
+CHECK-OBJDUMP-NEXT: bti
+*/

>From a39730f1b1126422cad8049f917ed92406ecf6c9 Mon Sep 17 00:00:00 2001
From: Gergely Balint <gergely.balint at arm.com>
Date: Tue, 10 Feb 2026 11:48:51 +0000
Subject: [PATCH 2/2] Review nits

---
 bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp   |  3 ++-
 .../AArch64/{inline-bti-dbg.s => bti-inline-dbg.s} |  0
 bolt/test/AArch64/{inline-bti.s => bti-inline.s}   |  0
 ...ng-jmp-bti-ignored.s => bti-long-jmp-ignored.s} |  0
 .../AArch64/{long-jmp-bti.s => bti-long-jmp.s}     |  0
 .../{no-bti-note.test => bti-note-unused.test}     |  0
 .../{patch-entries-bti.s => bti-patch-entries.s}   |  3 +--
 .../runtime/AArch64/{hugify-bti.c => bti-hugify.c} | 14 ++++++++++----
 ...d-call-bti.c => bti-instrumentation-ind-call.c} |  0
 .../{long-jmp-bti-plt.c => bti-long-jmp-plt.c}     |  0
 10 files changed, 13 insertions(+), 7 deletions(-)
 rename bolt/test/AArch64/{inline-bti-dbg.s => bti-inline-dbg.s} (100%)
 rename bolt/test/AArch64/{inline-bti.s => bti-inline.s} (100%)
 rename bolt/test/AArch64/{long-jmp-bti-ignored.s => bti-long-jmp-ignored.s} (100%)
 rename bolt/test/AArch64/{long-jmp-bti.s => bti-long-jmp.s} (100%)
 rename bolt/test/AArch64/{no-bti-note.test => bti-note-unused.test} (100%)
 rename bolt/test/AArch64/{patch-entries-bti.s => bti-patch-entries.s} (85%)
 rename bolt/test/runtime/AArch64/{hugify-bti.c => bti-hugify.c} (54%)
 rename bolt/test/runtime/AArch64/{instrumentation-ind-call-bti.c => bti-instrumentation-ind-call.c} (100%)
 rename bolt/test/runtime/AArch64/{long-jmp-bti-plt.c => bti-long-jmp-plt.c} (100%)

diff --git a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
index fea3a937046ad..ea043c12583c5 100644
--- a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
+++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
@@ -1780,7 +1780,8 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
       exit(1);
     }
     if (!TargetBB)
-      // !TargetBB -> TargetFunction is not a nullptr
+      // No need to check TargetFunction for nullptr, because
+      // !TargetBB &&!TargetFunction has already been checked.
       TargetBB = &*TargetFunction->begin();
     if (TargetBB) {
       if (!TargetBB->hasParent()) {
diff --git a/bolt/test/AArch64/inline-bti-dbg.s b/bolt/test/AArch64/bti-inline-dbg.s
similarity index 100%
rename from bolt/test/AArch64/inline-bti-dbg.s
rename to bolt/test/AArch64/bti-inline-dbg.s
diff --git a/bolt/test/AArch64/inline-bti.s b/bolt/test/AArch64/bti-inline.s
similarity index 100%
rename from bolt/test/AArch64/inline-bti.s
rename to bolt/test/AArch64/bti-inline.s
diff --git a/bolt/test/AArch64/long-jmp-bti-ignored.s b/bolt/test/AArch64/bti-long-jmp-ignored.s
similarity index 100%
rename from bolt/test/AArch64/long-jmp-bti-ignored.s
rename to bolt/test/AArch64/bti-long-jmp-ignored.s
diff --git a/bolt/test/AArch64/long-jmp-bti.s b/bolt/test/AArch64/bti-long-jmp.s
similarity index 100%
rename from bolt/test/AArch64/long-jmp-bti.s
rename to bolt/test/AArch64/bti-long-jmp.s
diff --git a/bolt/test/AArch64/no-bti-note.test b/bolt/test/AArch64/bti-note-unused.test
similarity index 100%
rename from bolt/test/AArch64/no-bti-note.test
rename to bolt/test/AArch64/bti-note-unused.test
diff --git a/bolt/test/AArch64/patch-entries-bti.s b/bolt/test/AArch64/bti-patch-entries.s
similarity index 85%
rename from bolt/test/AArch64/patch-entries-bti.s
rename to bolt/test/AArch64/bti-patch-entries.s
index 0dea0f00367ee..005b811ff4d7c 100644
--- a/bolt/test/AArch64/patch-entries-bti.s
+++ b/bolt/test/AArch64/bti-patch-entries.s
@@ -5,7 +5,7 @@
 # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
 # RUN:   %s -o %t.o
 # RUN: %clang %cflags -pie %t.o -o %t.exe -nostdlib -Wl,-q,-z,force-bti
-# RUN: llvm-bolt %t.exe -o %t.bolt --use-old-text=0 --lite=0 --skip-funcs=_start | FileCheck %s --check-prefix=CHECK-BOLT
+# RUN: llvm-bolt %t.exe -o %t.bolt --use-old-text=0 --lite=0 --force-patch | FileCheck %s --check-prefix=CHECK-BOLT
 # RUN: llvm-objdump -dz %t.bolt | FileCheck %s
 
 # CHECK-BOLT: binary is using BTI
@@ -34,6 +34,5 @@ pathedEntries:
 .type _start, %function
 _start:
   bl pathedEntries
-  .inst 0xdeadbeef
   ret
 .size _start, .-_start
diff --git a/bolt/test/runtime/AArch64/hugify-bti.c b/bolt/test/runtime/AArch64/bti-hugify.c
similarity index 54%
rename from bolt/test/runtime/AArch64/hugify-bti.c
rename to bolt/test/runtime/AArch64/bti-hugify.c
index 6620bca0f63e7..9887a9746f113 100644
--- a/bolt/test/runtime/AArch64/hugify-bti.c
+++ b/bolt/test/runtime/AArch64/bti-hugify.c
@@ -15,16 +15,22 @@ RUN: -Wl,-q,-z,force-bti
 RUN: %clang %cflags -mbranch-protection=standard -fpic %s -o %t.pie.exe \
 RUN: -Wl,-q,-z,force-bti
 
-RUN: llvm-bolt %t.nopie.exe --lite=0 -o %t.nopie --hugify | FileCheck %s \
+RUN: llvm-bolt %t.nopie.exe --lite=0 -o %t.nopie.bolt --hugify | FileCheck %s \
 RUN: -check-prefix=CHECK-BOLT
-RUN: llvm-bolt %t.pie.exe --lite=0 -o %t.pie --hugify | FileCheck %s \
+RUN: llvm-bolt %t.pie.exe --lite=0 -o %t.pie.bolt --hugify | FileCheck %s \
 RUN: -check-prefix=CHECK-BOLT
 
 CHECK-BOLT: binary is using BTI
 
-RUN: llvm-objdump -D %t.nopie | FileCheck %s -check-prefix=CHECK-OBJDUMP
-RUN: llvm-objdump -D %t.pie | FileCheck %s -check-prefix=CHECK-OBJDUMP
+RUN: llvm-objdump -D %t.nopie.bolt | FileCheck %s -check-prefix=CHECK-OBJDUMP
+RUN: llvm-objdump -D %t.pie.bolt | FileCheck %s -check-prefix=CHECK-OBJDUMP
 
 CHECK-OBJDUMP: <_start>:
 CHECK-OBJDUMP-NEXT: bti
+
+CHECK-OBJDUMP: <__bolt_hugify_start_program>:
+CHECK-OBJDUMP-NEXT: adrp x16, 0x[[#%x,ADRP:]]
+CHECK-OBJDUMP-NEXT: add x16, x16, #0x[[#%x,ADD:]]
+CHECK-OBJDUMP-NEXT: br x16
+
 */
diff --git a/bolt/test/runtime/AArch64/instrumentation-ind-call-bti.c b/bolt/test/runtime/AArch64/bti-instrumentation-ind-call.c
similarity index 100%
rename from bolt/test/runtime/AArch64/instrumentation-ind-call-bti.c
rename to bolt/test/runtime/AArch64/bti-instrumentation-ind-call.c
diff --git a/bolt/test/runtime/AArch64/long-jmp-bti-plt.c b/bolt/test/runtime/AArch64/bti-long-jmp-plt.c
similarity index 100%
rename from bolt/test/runtime/AArch64/long-jmp-bti-plt.c
rename to bolt/test/runtime/AArch64/bti-long-jmp-plt.c



More information about the llvm-commits mailing list