[llvm] 1f12f6f - [llvm-nm][RISCV] Recognize mapping symbols
Job Noorman via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 06:43:48 PDT 2023
Author: Job Noorman
Date: 2023-07-28T15:43:39+02:00
New Revision: 1f12f6fff4476246f4b9089bf5363e93f8cdd104
URL: https://github.com/llvm/llvm-project/commit/1f12f6fff4476246f4b9089bf5363e93f8cdd104
DIFF: https://github.com/llvm/llvm-project/commit/1f12f6fff4476246f4b9089bf5363e93f8cdd104.diff
LOG: [llvm-nm][RISCV] Recognize mapping symbols
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D156514
Added:
llvm/test/tools/llvm-nm/special-syms-riscv.test
Modified:
llvm/tools/llvm-nm/llvm-nm.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-nm/special-syms-riscv.test b/llvm/test/tools/llvm-nm/special-syms-riscv.test
new file mode 100644
index 00000000000000..f16df3623fc61a
--- /dev/null
+++ b/llvm/test/tools/llvm-nm/special-syms-riscv.test
@@ -0,0 +1,29 @@
+## Test --special-syms flag.
+# RUN: yaml2obj %s -o %t
+
+# RUN: llvm-nm %t | count 0
+# RUN: llvm-nm %t --special-syms | FileCheck %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_RISCV
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Address: 0x1000
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_WRITE ]
+ Address: 0x2000
+Symbols:
+ - Name: $x.1
+ Section: .text
+ - Name: $d.1
+ Section: .data
+
+# CHECK: 2000 d $d.1
+# CHECK-NEXT: 1000 t $x.1
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 809641c8de34d9..10ce7fd95a6abd 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1803,9 +1803,9 @@ static bool getSymbolNamesFromObject(SymbolicFile &Obj,
// --special-syms option.
auto *ELFObj = dyn_cast<ELFObjectFileBase>(&Obj);
bool HasMappingSymbol =
- ELFObj &&
- llvm::is_contained({ELF::EM_ARM, ELF::EM_AARCH64, ELF::EM_CSKY},
- ELFObj->getEMachine());
+ ELFObj && llvm::is_contained({ELF::EM_ARM, ELF::EM_AARCH64,
+ ELF::EM_CSKY, ELF::EM_RISCV},
+ ELFObj->getEMachine());
if (!HasMappingSymbol && !DebugSyms &&
(*SymFlagsOrErr & SymbolRef::SF_FormatSpecific))
continue;
More information about the llvm-commits
mailing list