[llvm] Add support for large AArch64 binaries. (PR #185374)
Marios Pomonis via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 01:34:26 PDT 2026
https://github.com/marpom created https://github.com/llvm/llvm-project/pull/185374
In AArch64 calls have a +/-128MB range
(https://developer.arm.com/documentation/ddi0602/2025-12/Base-Instructions/BL--Branch-with-link-). In cases where the .text is larger than that, the linker adds functions that just jumps to the sanitizer functions and places them to some code location where the rest of the binary can call it. These functions have the prefix __AArch64ADRPThunk__.
This commit marks calls to this function as coverage points.
>From 3fa42088d492c60e1b086363b2c2c4949a1dfe12 Mon Sep 17 00:00:00 2001
From: Marios Pomonis <pomonis at google.com>
Date: Mon, 9 Mar 2026 01:31:02 -0700
Subject: [PATCH] Add support for large AArch64 binaries.
In AArch64 calls have a +/-128MB range
(https://developer.arm.com/documentation/ddi0602/2025-12/Base-Instructions/BL--Branch-with-link-).
In cases where the .text is larger than that, the linker adds functions
that just jumps to the sanitizer functions and places them to some code location
where the rest of the binary can call it. These functions have the
prefix __AArch64ADRPThunk__.
This commit marks calls to this function as coverage points.
---
llvm/tools/sancov/sancov.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index f2e71f97dda34..ec069a2c115b9 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -628,7 +628,12 @@ static bool isCoveragePointSymbol(StringRef Name) {
// Mac has '___' prefix
Name == "___sanitizer_cov" || Name == "___sanitizer_cov_with_check" ||
Name == "___sanitizer_cov_trace_func_enter" ||
- Name == "___sanitizer_cov_trace_pc_guard";
+ Name == "___sanitizer_cov_trace_pc_guard" ||
+ // Large Aarch64 binaries use thunks
+ Name == "__AArch64ADRPThunk___sanitizer_cov" ||
+ Name == "__AArch64ADRPThunk___sanitizer_cov_with_check" ||
+ Name == "__AArch64ADRPThunk___sanitizer_cov_trace_func_enter" ||
+ Name == "__AArch64ADRPThunk___sanitizer_cov_trace_pc_guard";
}
// Locate __sanitizer_cov* function addresses inside the stubs table on MachO.
More information about the llvm-commits
mailing list