[PATCH] D85623: [llvm-objdump] Change a PLT decoding error to a warning
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 17:29:45 PDT 2020
MaskRay updated this revision to Diff 284536.
MaskRay marked 3 inline comments as done.
MaskRay added a comment.
Improve test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85623/new/
https://reviews.llvm.org/D85623
Files:
llvm/test/tools/llvm-objdump/ELF/AArch64/plt.test
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1396,11 +1396,17 @@
for (auto PltEntry : ElfObj->getPltAddresses()) {
SymbolRef Symbol(PltEntry.first, ElfObj);
uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
-
- StringRef Name = unwrapOrError(Symbol.getName(), Obj->getFileName());
- if (!Name.empty())
- AllSymbols[*Plt].emplace_back(
- PltEntry.second, Saver.save((Name + "@plt").str()), SymbolType);
+ if (Expected<StringRef> NameOrErr = Symbol.getName()) {
+ if (!NameOrErr->empty())
+ AllSymbols[*Plt].emplace_back(PltEntry.second,
+ Saver.save((*NameOrErr + "@plt").str()),
+ SymbolType);
+ } else {
+ consumeError(NameOrErr.takeError());
+ reportWarning("PLT entry at 0x" + Twine::utohexstr(PltEntry.second) +
+ " references an invalid symbol",
+ Obj->getFileName());
+ }
}
}
}
Index: llvm/test/tools/llvm-objdump/ELF/AArch64/plt.test
===================================================================
--- llvm/test/tools/llvm-objdump/ELF/AArch64/plt.test
+++ llvm/test/tools/llvm-objdump/ELF/AArch64/plt.test
@@ -18,6 +18,12 @@
# CHECK-BTI-NEXT: bti c
# CHECK-BTI-NEXT: adrp x16, {{.*}}
+# RUN: yaml2obj -D SYM=0 %s -o %t.warn
+# RUN: llvm-objdump -d %t.warn 2>&1 | FileCheck %s --check-prefix=INVALID -DFILE=%t.warn
+
+# INVALID: warning: '[[FILE]]': PLT entry at 0x210030 references an invalid symbol
+# INVALID: Disassembly of section .text:
+
--- !ELF
FileHeader:
Class: ELFCLASS64
@@ -32,7 +38,7 @@
Info: .got.plt
Relocations:
- Offset: 0x0000000000230018
- Symbol: f1
+ Symbol: [[SYM=f1]]
Type: R_AARCH64_JUMP_SLOT
- Offset: 0x0000000000230020
Symbol: f2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85623.284536.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/d4b4f15a/attachment.bin>
More information about the llvm-commits
mailing list