Skip to content

Conversation

@bgergely0
Copy link
Contributor

BOLT currently ignores functions with synchronous PAuth DWARF info.
When more than 10% of functions get ignored for inconsistencies, we
should emit a warning to only use asynchronous unwind tables.

See also: #165215

Copy link
Contributor Author

bgergely0 commented Oct 27, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Oct 27, 2025

@llvm/pr-subscribers-bolt

Author: Gergely Bálint (bgergely0)

Changes

BOLT currently ignores functions with synchronous PAuth DWARF info.
When more than 10% of functions get ignored for inconsistencies, we
should emit a warning to only use asynchronous unwind tables.

See also: #165215


Full diff: https://github.com/llvm/llvm-project/pull/165227.diff

2 Files Affected:

  • (modified) bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp (+7-1)
  • (added) bolt/test/runtime/AArch64/pacret-synchronous-unwind.cpp (+32)
diff --git a/bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp b/bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp index 2fc5a2fda086a..6bcb5a6bd1801 100644 --- a/bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp +++ b/bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp @@ -130,11 +130,17 @@ Error PointerAuthCFIAnalyzer::runOnFunctions(BinaryContext &BC) { ParallelUtilities::runOnEachFunction( BC, ParallelUtilities::SchedulingPolicy::SP_INST_LINEAR, WorkFun, SkipPredicate, "PointerAuthCFIAnalyzer"); + + float IgnoredPercent = (100.0 * FunctionsIgnored) / Total; BC.outs() << "BOLT-INFO: PointerAuthCFIAnalyzer ran on " << Total << " functions. Ignored " << FunctionsIgnored << " functions " - << format("(%.2lf%%)", (100.0 * FunctionsIgnored) / Total) + << format("(%.2lf%%)", IgnoredPercent) << " because of CFI inconsistencies\n"; + if (IgnoredPercent >= 10.0) + BC.outs() << "BOLT-WARNING: PointerAuthCFIAnalyzer only supports " + "asynchronous unwind tables.\n"; + return Error::success(); } diff --git a/bolt/test/runtime/AArch64/pacret-synchronous-unwind.cpp b/bolt/test/runtime/AArch64/pacret-synchronous-unwind.cpp new file mode 100644 index 0000000000000..e90882833323d --- /dev/null +++ b/bolt/test/runtime/AArch64/pacret-synchronous-unwind.cpp @@ -0,0 +1,32 @@ +// Test to demonstrate that functions compiled with synchronous unwind tables +// are ignored by the PointerAuthCFIAnalyzer. +// Exception handling is needed to have _any_ unwind tables, otherwise the +// PointerAuthCFIAnalyzer does not run on these functions, so it does not ignore +// any function. +// +// REQUIRES: system-linux,bolt-runtime +// +// RUN: %clangxx --target=aarch64-unknown-linux-gnu \ +// RUN: -mbranch-protection=pac-ret \ +// RUN: -fno-asynchronous-unwind-tables \ +// RUN: %s -o %t.exe -Wl,-q +// RUN: llvm-bolt %t.exe -o %t.bolt | FileCheck %s --check-prefix=CHECK +// +// CHECK: PointerAuthCFIAnalyzer ran on 3 functions. Ignored +// CHECK-NOT: 0 functions (0.00%) because of CFI inconsistencies +// CHECK-SAME: 1 functions (33.33%) because of CFI inconsistencies +// CHECK-NEXT: PointerAuthCFIAnalyzer only supports asynchronous unwind tables + +#include <cstdio> +#include <stdexcept> + +void foo() { throw std::runtime_error("Exception from foo()."); } + +int main() { + try { + foo(); + } catch (const std::exception &e) { + printf("Exception caught: %s\n", e.what()); + } + return 0; +} 
@bgergely0
Copy link
Contributor Author

Looks like the code formatting bot is broken, but the patch is formatted locally.

@bgergely0
Copy link
Contributor Author

As an input binary with sync unwind tables generates many warnings, it made sense to add the verbosity checking in this PR as well.

@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from a05ee35 to 66365dd Compare October 28, 2025 11:52
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from dd41705 to bd53804 Compare October 28, 2025 11:53
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 66365dd to e6791c1 Compare October 28, 2025 12:18
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from bd53804 to ae91e45 Compare October 28, 2025 12:18
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from e6791c1 to 3d0b614 Compare October 28, 2025 14:12
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch 3 times, most recently from 45beba7 to 5a72973 Compare October 31, 2025 15:18
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from b716be0 to 46d7fee Compare October 31, 2025 15:18
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from 5a72973 to 554aaec Compare October 31, 2025 15:28
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 46d7fee to c12cf77 Compare October 31, 2025 15:28
@bgergely0 bgergely0 marked this pull request as draft October 31, 2025 15:36
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch 2 times, most recently from d1ebe85 to 352b942 Compare November 17, 2025 10:15
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from 352b942 to b892645 Compare November 24, 2025 13:51
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 1959952 to 73f4bef Compare November 24, 2025 13:51
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from b892645 to e25002a Compare November 24, 2025 14:13
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch 2 times, most recently from 4aa24bf to 867d3ee Compare November 24, 2025 14:53
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from e25002a to ee00757 Compare November 24, 2025 14:53
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 867d3ee to 166cb9c Compare November 24, 2025 15:43
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from ee00757 to 4b220b3 Compare November 24, 2025 15:43
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 166cb9c to 1d61245 Compare November 26, 2025 12:30
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch 2 times, most recently from 93ceb02 to fff7be1 Compare November 26, 2025 12:37
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch 2 times, most recently from 6c3f064 to 2713157 Compare November 26, 2025 13:03
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from fff7be1 to 28b3151 Compare November 26, 2025 13:03
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 2713157 to a7fd7f2 Compare November 28, 2025 12:06
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from 28b3151 to 06d2c2b Compare November 28, 2025 12:06
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from a7fd7f2 to d569f73 Compare November 28, 2025 12:10
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from 06d2c2b to ed5fa9b Compare November 28, 2025 12:10
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from d569f73 to 8215199 Compare November 28, 2025 16:55
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch 2 times, most recently from 14a19b5 to cc68583 Compare December 1, 2025 10:01
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 8215199 to 8fa4949 Compare December 1, 2025 10:01
BOLT currently ignores functions with synchronous PAuth DWARF info. When more than 10% of functions get ignored for inconsistencies, we should emit a warning to only use asynchronous unwind tables. See also: #165215
- makes sure we do not divide by zero, to calculate the % of ignored functions.
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-warn-on-sync-unw branch from cc68583 to da2ca09 Compare December 1, 2025 11:03
@bgergely0 bgergely0 force-pushed the users/bgergely0/bolt-rename-pac-cfi-passes branch from 8fa4949 to b2f4103 Compare December 1, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 participants