[llvm] 76f023b - [RISCV] Make mapping symbols SF_FormatSpecific
Job Noorman via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 01:22:01 PDT 2023
Author: Job Noorman
Date: 2023-07-28T10:21:55+02:00
New Revision: 76f023bddfc282017729ff860265191bc9e7c149
URL: https://github.com/llvm/llvm-project/commit/76f023bddfc282017729ff860265191bc9e7c149
DIFF: https://github.com/llvm/llvm-project/commit/76f023bddfc282017729ff860265191bc9e7c149.diff
LOG: [RISCV] Make mapping symbols SF_FormatSpecific
This ensures that llvm-symbolizer ignores them for symbolization.
Note: unlike aarch64-mapping-symbol.s, the test included here does not
test if the mapping symbols are actually in the symbol table. The reason
is that llvm-mc support for RISC-V mapping symbols (D153260) has not
landed yet, so the mapping symbols simply aren't there. However, D153260
would like to depend on this patch together with D156190 to avoid having
to update a large amount of tests.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D156236
Added:
llvm/test/DebugInfo/Symbolize/ELF/riscv-mapping-symbol.s
Modified:
llvm/include/llvm/Object/ELFObjectFile.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index e57ece5443e846..dc3d6bb58710c7 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -772,8 +772,10 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const {
}
} else if (EF.getHeader().e_machine == ELF::EM_RISCV) {
if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
- // Mark empty name symbols used for label
diff erences.
- if (NameOrErr->empty())
+ StringRef Name = *NameOrErr;
+ // Mark empty name symbols (used for label
diff erences) and mapping
+ // symbols.
+ if (Name.empty() || Name.startswith("$d") || Name.startswith("$x"))
Result |= SymbolRef::SF_FormatSpecific;
} else {
// TODO: Actually report errors helpfully.
diff --git a/llvm/test/DebugInfo/Symbolize/ELF/riscv-mapping-symbol.s b/llvm/test/DebugInfo/Symbolize/ELF/riscv-mapping-symbol.s
new file mode 100644
index 00000000000000..d290c1736b56c7
--- /dev/null
+++ b/llvm/test/DebugInfo/Symbolize/ELF/riscv-mapping-symbol.s
@@ -0,0 +1,21 @@
+# REQUIRES: riscv-registered-target
+## Ignore RISC-V mapping symbols (with a prefix of $d or $x).
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t
+# RUN: llvm-symbolizer --obj=%t 0 4 0xc | FileCheck %s
+
+# CHECK: foo
+# CHECK-NEXT: ??:0:0
+# CHECK-EMPTY:
+# CHECK: foo
+# CHECK-NEXT: ??:0:0
+# CHECK-EMPTY:
+# CHECK: foo
+# CHECK-NEXT: ??:0:0
+
+ .global foo
+foo:
+ .word 32
+ nop
+ nop
+ .word 42
More information about the llvm-commits
mailing list