[llvm] [ELFDebugObjectPlugin] Gracefully handle missing section (PR #172622)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 17 01:51:51 PST 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/172622
On ppc64le some sections like .toc get merged into other sections by JITLink. As such, some sections in the object file may not be present in the link graph. Skip those sections.
>From f467d25d5961dbc70aa7bc5f3aedb521e52b68d4 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 17 Dec 2025 10:50:16 +0100
Subject: [PATCH] [ELFDebugObjectPlugin] Gracefully handle missing section
On ppc64le some sections like .toc get merged into other sections
by JITLink. As such, some sections in the object file may not be
present in the link graph. Skip those sections.
---
.../Orc/Debugging/ELFDebugObjectPlugin.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
index d4cefead488d9..5ffc6326938b3 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp
@@ -127,8 +127,9 @@ Error DebugObject::visitSectionLoadAddresses(GetLoadAddressFn Callback) {
if (Name->empty())
continue;
ExecutorAddr LoadAddress = Callback(*Name);
- const_cast<SectionHeader &>(Header).sh_addr =
- static_cast<typename ELFT::uint>(LoadAddress.getValue());
+ if (LoadAddress)
+ const_cast<SectionHeader &>(Header).sh_addr =
+ static_cast<typename ELFT::uint>(LoadAddress.getValue());
}
LLVM_DEBUG({
@@ -267,11 +268,16 @@ void ELFDebugObjectPlugin::modifyPassConfig(MaterializationResponsibility &MR,
// section headers in our debug object allocation
Error Err = DebugObj->visitSections(
[&G, &SectionsPatched, &HasDebugSections](StringRef Name) {
+ Section *S = G.findSectionByName(Name);
+ if (!S) {
+ // The section may have been merged into a different one during
+ // linking, ignore it.
+ return ExecutorAddr();
+ }
+
SectionsPatched += 1;
if (isDwarfSection(Name))
HasDebugSections = true;
- Section *S = G.findSectionByName(Name);
- assert(S && "No graph section for object section");
return SectionRange(*S).getStart();
});
More information about the llvm-commits
mailing list