[Lldb-commits] [lldb] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table (PR #158551)

via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 14 23:50:24 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: ZhaoQi (zhaoqi5)

<details>
<summary>Changes</summary>

LoongArch64 always uses symbols for relocations, so temporary symbols starting with ".L" should be preserved so that relocations in `.debug_info` can be fixed correctly.

After this commit, three tests passed:

```
lldb-shell :: SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll
lldb-shell :: SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
lldb-shell :: SymbolFile/DWARF/clang-gmodules-type-lookup.c
```

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


1 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+6-2) 


``````````diff
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 931baf5927a04..0f8bc5fc93e07 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2119,8 +2119,12 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
     // generated local labels used for internal purposes (e.g. debugging,
     // optimization) and are not relevant for symbol resolution or external
     // linkage.
-    if (llvm::StringRef(symbol_name).starts_with(".L"))
-      continue;
+    // LoongArch64 always uses symbols for relocations, so temporary symbols
+    // starting with ".L" should be preserved.
+    if (arch.GetMachine() != llvm::Triple::loongarch64) {
+      if (llvm::StringRef(symbol_name).starts_with(".L"))
+        continue;
+    }
     // No need to add non-section symbols that have no names
     if (symbol.getType() != STT_SECTION &&
         (symbol_name == nullptr || symbol_name[0] == '\0'))

``````````

</details>


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


More information about the lldb-commits mailing list