aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ELFObjectFile.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2020-08-13 08:13:26 -0700
committerFangrui Song <i@maskray.me>2020-08-13 08:13:42 -0700
commit7f8c49b016003a1a642235b14788648736809a58 (patch)
treee6f0732c28d4e8f85b7c82c9e24c0361bf084947 /llvm/lib/Object/ELFObjectFile.cpp
parent1ffc299628948ee0bee3ffb7451c9085b5a80e83 (diff)
downloadllvm-7f8c49b016003a1a642235b14788648736809a58.zip
llvm-7f8c49b016003a1a642235b14788648736809a58.tar.gz
llvm-7f8c49b016003a1a642235b14788648736809a58.tar.bz2
[llvm-objdump] Change symbol name/PLT decoding errors to warnings
If the referenced symbol of a J[U]MP_SLOT is invalid (e.g. symbol index 0), llvm-objdump -d will bail out: ``` error: 'a': st_name (0x326600) is past the end of the string table of size 0x7 ``` where 0x326600 is the st_name field of the first entry past the end of .symtab Change it to a warning to continue dumping. `X86/plt.test` uses a prebuilt executable, so I pick `ELF/AArch64/plt.test` which has a YAML input and can be easily modified. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85623
Diffstat (limited to 'llvm/lib/Object/ELFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/ELFObjectFile.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index c919d25..72eaeb7 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -440,7 +440,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
TheTriple.setArchName(Triple);
}
-std::vector<std::pair<DataRefImpl, uint64_t>>
+std::vector<std::pair<Optional<DataRefImpl>, uint64_t>>
ELFObjectFileBase::getPltAddresses() const {
std::string Err;
const auto Triple = makeTriple();
@@ -498,14 +498,18 @@ ELFObjectFileBase::getPltAddresses() const {
GotToPlt.insert(std::make_pair(Entry.second, Entry.first));
// Find the relocations in the dynamic relocation table that point to
// locations in the GOT for which we know the corresponding PLT entry.
- std::vector<std::pair<DataRefImpl, uint64_t>> Result;
+ std::vector<std::pair<Optional<DataRefImpl>, uint64_t>> Result;
for (const auto &Relocation : RelaPlt->relocations()) {
if (Relocation.getType() != JumpSlotReloc)
continue;
auto PltEntryIter = GotToPlt.find(Relocation.getOffset());
- if (PltEntryIter != GotToPlt.end())
- Result.push_back(std::make_pair(
- Relocation.getSymbol()->getRawDataRefImpl(), PltEntryIter->second));
+ if (PltEntryIter != GotToPlt.end()) {
+ symbol_iterator Sym = Relocation.getSymbol();
+ if (Sym == symbol_end())
+ Result.emplace_back(None, PltEntryIter->second);
+ else
+ Result.emplace_back(Sym->getRawDataRefImpl(), PltEntryIter->second);
+ }
}
return Result;
}