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

>From c6679a64e9eebaf0c7a5bf96689c9a53dbe33b81 Mon Sep 17 00:00:00 2001
From: Qi Zhao <[email protected]>
Date: Mon, 15 Sep 2025 14:11:17 +0800
Subject: [PATCH 1/2] [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'))

>From a091f3635bffa3ab37f37232a30fd8563130eb7b Mon Sep 17 00:00:00 2001
From: ZhaoQi <[email protected]>
Date: Mon, 15 Sep 2025 16:14:44 +0800
Subject: [PATCH 2/2] address comment

Co-authored-by: Lu Weining <[email protected]>
---
 lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 0f8bc5fc93e07..45c8f0ac23e58 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2121,10 +2121,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t 
start_id,
     // linkage.
     // 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;
-    }
+    if (llvm::StringRef(symbol_name).starts_with(".L") &&
+       arch.GetMachine() != llvm::Triple::loongarch64)
+      continue;
     // No need to add non-section symbols that have no names
     if (symbol.getType() != STT_SECTION &&
         (symbol_name == nullptr || symbol_name[0] == '\0'))

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to