[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:53 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: None (itrofimow)

<details>
<summary>Changes</summary>

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)

---
Full diff: https://github.com/llvm/llvm-project/pull/119307.diff


1 Files Affected:

- (modified) llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp (+7-1) 


``````````diff
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)

``````````

</details>


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


More information about the llvm-commits mailing list