[PATCH] D98669: [RISCV] Make empty name symbols SF_FormatSpecific so that llvm-symbolizer ignores them for symbolization
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 16 14:12:30 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d037458a318: [RISCV] Make empty name symbols SF_FormatSpecific so that llvm-symbolizer… (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98669/new/
https://reviews.llvm.org/D98669
Files:
llvm/include/llvm/Object/ELFObjectFile.h
llvm/test/DebugInfo/Symbolize/ELF/riscv-empty-name-symbol.s
Index: llvm/test/DebugInfo/Symbolize/ELF/riscv-empty-name-symbol.s
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/Symbolize/ELF/riscv-empty-name-symbol.s
@@ -0,0 +1,26 @@
+# REQUIRES: riscv-registered-target
+## Ignore empty name symbols.
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t
+# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYM
+
+# SYM: 0000000000000004 0 NOTYPE LOCAL DEFAULT [[#]] {{$}}
+# SYM: 0000000000000000 0 NOTYPE GLOBAL DEFAULT [[#]] foo
+
+## Make sure we test at an address larger than or equal to an empty name symbol.
+# RUN: llvm-symbolizer --obj=%t 0 4 | FileCheck %s
+
+# CHECK: foo
+# CHECK-NEXT: ??:0:0
+# CHECK-EMPTY:
+# CHECK-NEXT: foo
+# CHECK-NEXT: ??:0:0
+
+.globl foo
+foo:
+ nop
+ .file 1 "/tmp" "a.s"
+ .loc 1 1 0
+ nop
+
+.section .debug_line,"", at progbits
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -728,6 +728,15 @@
}
if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
Result |= SymbolRef::SF_Thumb;
+ } else if (EF.getHeader().e_machine == ELF::EM_RISCV) {
+ if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
+ // Mark empty name symbols used for label differences.
+ if (NameOrErr->empty())
+ Result |= SymbolRef::SF_FormatSpecific;
+ } else {
+ // TODO: Actually report errors helpfully.
+ consumeError(NameOrErr.takeError());
+ }
}
if (ESym->st_shndx == ELF::SHN_UNDEF)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98669.331106.patch
Type: text/x-patch
Size: 1660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210316/2baf7162/attachment.bin>
More information about the llvm-commits
mailing list