[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
Mon Sep 15 01:34:12 PDT 2025
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 <zhaoqi01 at loongson.cn>
Date: Mon, 15 Sep 2025 14:11:17 +0800
Subject: [PATCH 1/3] [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 <zhaoqi01 at loongson.cn>
Date: Mon, 15 Sep 2025 16:14:44 +0800
Subject: [PATCH 2/3] address comment
Co-authored-by: Lu Weining <luweining at loongson.cn>
---
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'))
>From 5548303e0f7c67f4b4f02dceae1c07c8be4fde2b Mon Sep 17 00:00:00 2001
From: Qi Zhao <zhaoqi01 at loongson.cn>
Date: Mon, 15 Sep 2025 16:31:25 +0800
Subject: [PATCH 3/3] clang format
---
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 45c8f0ac23e58..406d7d0df5ac8 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2122,7 +2122,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
// LoongArch64 always uses symbols for relocations, so temporary symbols
// starting with ".L" should be preserved.
if (llvm::StringRef(symbol_name).starts_with(".L") &&
- arch.GetMachine() != llvm::Triple::loongarch64)
+ arch.GetMachine() != llvm::Triple::loongarch64)
continue;
// No need to add non-section symbols that have no names
if (symbol.getType() != STT_SECTION &&
More information about the lldb-commits
mailing list