Skip to content

Commit e12cb5b

Browse files
committed
[BOLT] Rename pac-ret feature flag
- new name is update-branch-protection, which can be extended later to include a "strict mode", and to cover BTI rewriting.
1 parent fd3642a commit e12cb5b

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extern llvm::cl::opt<std::string> OutputFilename;
7878
extern llvm::cl::opt<std::string> PerfData;
7979
extern llvm::cl::opt<bool> PrintCacheMetrics;
8080
extern llvm::cl::opt<bool> PrintSections;
81-
extern llvm::cl::opt<bool> DisallowPacret;
81+
extern llvm::cl::opt<bool> UpdateBranchProtection;
8282

8383
// The format to use with -o in aggregation mode (perf2bolt)
8484
enum ProfileFormatKind { PF_Fdata, PF_YAML };

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,11 @@ static cl::opt<bool> ShortenInstructions("shorten-instructions",
279279
cl::init(true),
280280
cl::cat(BoltOptCategory));
281281

282-
// This flag is used to "gate" the negate-ra-state CFI handling.
283-
// Sometimes, binaries use pac-ret but not contain negate-ra-state CFIs. That
284-
// should cause no issues for BOLT.
285-
cl::opt<bool> DisallowPacret(
286-
"disallow-pacret",
287-
cl::desc("Disable processing binaries containing negate-ra-state DWARF "
288-
"CFIs (e.g. binaries using pac-ret hardening)"),
289-
cl::cat(BoltOptCategory));
282+
cl::opt<bool>
283+
UpdateBranchProtection("update-branch-protection",
284+
cl::desc("Rewrites pac-ret DWARF CFI instructions "
285+
"(AArch64-only, on by default)"),
286+
cl::init(true), cl::cat(BoltOptCategory));
290287
} // namespace opts
291288

292289
namespace llvm {

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,10 +3523,10 @@ void RewriteInstance::disassembleFunctions() {
35233523
// Check if fillCFIInfoFor removed any OpNegateRAState CFIs from the
35243524
// function.
35253525
if (Function.containedNegateRAState()) {
3526-
if (opts::DisallowPacret) {
3527-
BC->errs() << "BOLT-ERROR: --disallow-pacret flag was used, but "
3528-
<< Function.getPrintName()
3529-
<< " contains .cfi-negate-ra-state.\n";
3526+
if (!opts::UpdateBranchProtection) {
3527+
BC->errs()
3528+
<< "BOLT-ERROR: --update-branch-protection is set to false, but "
3529+
<< Function.getPrintName() << " contains .cfi-negate-ra-state.\n";
35303530
exit(1);
35313531
}
35323532
}

bolt/test/AArch64/negate-ra-state-disallow.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
22
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
3-
# RUN: not llvm-bolt %t.exe -o %t.exe.bolt --disallow-pacret 2>&1 | FileCheck %s
3+
# RUN: not llvm-bolt %t.exe -o %t.exe.bolt --update-branch-protection=false 2>&1 | FileCheck %s
44

5-
# CHECK: BOLT-ERROR: --disallow-pacret flag was used, but foo contains .cfi-negate-ra-state.
5+
# CHECK: BOLT-ERROR: --update-branch-protection is set to false, but foo contains .cfi-negate-ra-state.
66

77
.text
88
.globl foo

0 commit comments

Comments
 (0)