[llvm] [GSYM] Allow executable symtab symbols with unknown type (PR #119307)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 17:48:16 PST 2024


https://github.com/itrofimow created https://github.com/llvm/llvm-project/pull/119307

This patch tweaks symtab processing logic in llvm-gsymutil conversion
by allowing unknown symbols to get into final GSYM, since such symbols
are common with handwritten assembly in the wild (lack ".type function" directive)

>From 872d6e271cbad9b34677c5a9317903f9d6826960 Mon Sep 17 00:00:00 2001
From: Ivan Trofimov <i.trofimow at yandex.ru>
Date: Tue, 10 Dec 2024 04:44:13 +0300
Subject: [PATCH] [GSYM] Allow executable symtab symbols with unknown type

---
 llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp b/llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp
index 122de4deea5dfd..d5059ce34f5221 100644
--- a/llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp
@@ -90,7 +90,10 @@ llvm::Error ObjectFileTransformer::convert(const object::ObjectFile &Obj,
       // TODO: Test this error.
       return AddrOrErr.takeError();
 
-    if (SymType.get() != SymbolRef::Type::ST_Function ||
+    if ((SymType.get() != SymbolRef::Type::ST_Function &&
+         // We allow unknown (yet with valid text address) symbols,
+         // since these are common with handwritten assembly in the wild.
+         SymType.get() != SymbolRef::Type::ST_Unknown) ||
         !Gsym.IsValidTextAddress(*AddrOrErr))
       continue;
     // Function size for MachO files will be 0
@@ -105,6 +108,9 @@ llvm::Error ObjectFileTransformer::convert(const object::ObjectFile &Obj,
         consumeError(Name.takeError());
       continue;
     }
+    // Could happen with ST_Unknown symbols.
+    if (Name->empty())
+      continue;
     // Remove the leading '_' character in any symbol names if there is one
     // for mach-o files.
     if (IsMachO)



More information about the llvm-commits mailing list