[Lldb-commits] [lldb] [lldb] Strip metadata bits on function pointer in IndirectCallEdge::GetCallee (PR #196204)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Thu May 7 11:04:59 PDT 2026
https://github.com/bulbazord updated https://github.com/llvm/llvm-project/pull/196204
>From e94bfb296fab7675db572cf5824344c71c870ce5 Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford at apple.com>
Date: Wed, 6 May 2026 15:51:54 -0700
Subject: [PATCH 1/3] [lldb] Strip metadata bits on function pointer in
IndirectCallEdge::GetCallee
IndirectCallEdge::GetCallee calculates the raw address of a function
pointer and tries to resolve a load address for it. If the function
pointer has metadata bits in it (e.g. a signed pointer in arm64e) then
the resolution will fail.
---
lldb/source/Symbol/Function.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index cc8347fd5c510..e3cb42f248e73 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -235,6 +235,12 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,
return nullptr;
}
+ if (auto *process = exe_ctx.GetProcessPtr())
+ raw_addr = process->FixCodeAddress(raw_addr);
+ else
+ LLDB_LOG(log, "IndirectCallEdge: No Process available, unable to call "
+ "FixCodeAddress on function pointer");
+
Address callee_addr;
if (!exe_ctx.GetTargetPtr()->ResolveLoadAddress(raw_addr, callee_addr)) {
LLDB_LOG(log, "IndirectCallEdge: Could not resolve callee's load address");
>From cc85091ac03568b3017b81852be51e04ad32c5b6 Mon Sep 17 00:00:00 2001
From: Alex Langford <nirvashtzero at gmail.com>
Date: Thu, 7 May 2026 10:59:51 -0700
Subject: [PATCH 2/3] Update lldb/source/Symbol/Function.cpp
Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>
---
lldb/source/Symbol/Function.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index e3cb42f248e73..23ec058ae9c82 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -235,11 +235,12 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,
return nullptr;
}
- if (auto *process = exe_ctx.GetProcessPtr())
+ if (auto *process = exe_ctx.GetProcessPtr()) {
raw_addr = process->FixCodeAddress(raw_addr);
- else
+ } else {
LLDB_LOG(log, "IndirectCallEdge: No Process available, unable to call "
"FixCodeAddress on function pointer");
+ }
Address callee_addr;
if (!exe_ctx.GetTargetPtr()->ResolveLoadAddress(raw_addr, callee_addr)) {
>From a2f5354285141aa804107dc342bdbd06402a304a Mon Sep 17 00:00:00 2001
From: Alex Langford <nirvashtzero at gmail.com>
Date: Thu, 7 May 2026 11:04:48 -0700
Subject: [PATCH 3/3] Update Function.cpp
---
lldb/source/Symbol/Function.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 23ec058ae9c82..9b9dd3fbc0c65 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -237,7 +237,7 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,
if (auto *process = exe_ctx.GetProcessPtr()) {
raw_addr = process->FixCodeAddress(raw_addr);
- } else {
+ } else {
LLDB_LOG(log, "IndirectCallEdge: No Process available, unable to call "
"FixCodeAddress on function pointer");
}
More information about the lldb-commits
mailing list