[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:49:50 PDT 2025


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

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

>From c6679a64e9eebaf0c7a5bf96689c9a53dbe33b81 Mon Sep 17 00:00:00 2001
From: Qi Zhao <zhaoqi01 at loongson.cn>
Date: Mon, 15 Sep 2025 14:11:17 +0800
Subject: [PATCH] [lldb][LoongArch] Preserve temporary symbols starting with
 `.L` in lldb symbol table

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
```
---
 lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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'))



More information about the lldb-commits mailing list