[llvm] [llvm-gsymutil] Read function symbols from .gnu_debugdata in gsymutil (PR #227159)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 00:56:03 PDT 2026


================
@@ -893,3 +896,56 @@ StringRef ELFObjectFileBase::getCrelDecodeProblem(SectionRef Sec) const {
     return Obj->getCrelDecodeProblem(Data);
   return cast<ELF64BEObjectFile>(this)->getCrelDecodeProblem(Data);
 }
+
+static constexpr StringLiteral GnuDebugDataSectionName = ".gnu_debugdata";
+
+static std::optional<SectionRef>
+findGnuDebugDataSection(const ELFObjectFileBase &Obj) {
+  for (SectionRef Sec : Obj.sections()) {
+    Expected<StringRef> NameOrErr = Sec.getName();
+    // Ignore malformed names so they do not prevent finding a valid section.
+    if (!NameOrErr) {
+      consumeError(NameOrErr.takeError());
+      continue;
+    }
+    if (*NameOrErr == GnuDebugDataSectionName)
+      return Sec;
+  }
+  return std::nullopt;
+}
+
+bool ELFObjectFileBase::hasGnuDebugDataSection() const {
+  return findGnuDebugDataSection(*this).has_value();
+}
----------------
jh7370 wrote:

This seems like a pointless helper function. It doesn't do anything that couldn't be done at the call site.

https://github.com/llvm/llvm-project/pull/227159


More information about the llvm-commits mailing list