diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-05 01:33:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-05 01:33:53 +0000 |
commit | 6c1202c459ffa6d693ad92fa84e43902bc780bca (patch) | |
tree | 7b105f95ab50dfb164f274ae463085af780e3262 /tools | |
parent | cc5a6cb0a22736e133a17cf4de23e3d76de8058e (diff) | |
download | external_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.zip external_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.tar.gz external_llvm-6c1202c459ffa6d693ad92fa84e43902bc780bca.tar.bz2 |
Handle relocations that don't point to symbols.
In ELF (as in MachO), not all relocations point to symbols. Represent this
properly by using a symbol_iterator instead of a SymbolRef. Update llvm-readobj
ELF's dumper to handle relocatios without symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-objdump/COFFDump.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-objdump/MachODump.cpp | 5 | ||||
-rw-r--r-- | tools/llvm-readobj/COFFDumper.cpp | 8 | ||||
-rw-r--r-- | tools/llvm-readobj/ELFDumper.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-readobj/MachODumper.cpp | 7 |
5 files changed, 12 insertions, 16 deletions
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index 2ada683..7b55007 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/tools/llvm-objdump/COFFDump.cpp @@ -178,7 +178,7 @@ static error_code resolveSymbol(const std::vector<RelocationRef> &Rels, uint64_t Ofs; if (error_code ec = I->getOffset(Ofs)) return ec; if (Ofs == Offset) { - if (error_code ec = I->getSymbol(Sym)) return ec; + Sym = *I->getSymbol(); break; } } diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 03a383e..1ee3e42 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -250,10 +250,9 @@ static void DisassembleInputMachO2(StringRef Filename, Sections[SectIdx].getAddress(SectionAddress); RelocOffset -= SectionAddress; - SymbolRef RelocSym; - RI->getSymbol(RelocSym); + symbol_iterator RelocSym = RI->getSymbol(); - Relocs.push_back(std::make_pair(RelocOffset, RelocSym)); + Relocs.push_back(std::make_pair(RelocOffset, *RelocSym)); } array_pod_sort(Relocs.begin(), Relocs.end()); diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 94aafa7..3cbb9b3 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -201,8 +201,7 @@ static error_code resolveSymbol(const std::vector<RelocationRef> &Rels, return EC; if (Ofs == Offset) { - if (error_code EC = RelI->getSymbol(Sym)) - return EC; + Sym = *RelI->getSymbol(); return readobj_error::success; } } @@ -670,14 +669,13 @@ void COFFDumper::printRelocation(section_iterator SecI, uint64_t Offset; uint64_t RelocType; SmallString<32> RelocName; - SymbolRef Symbol; StringRef SymbolName; StringRef Contents; if (error(RelI->getOffset(Offset))) return; if (error(RelI->getType(RelocType))) return; if (error(RelI->getTypeName(RelocName))) return; - if (error(RelI->getSymbol(Symbol))) return; - if (error(Symbol.getName(SymbolName))) return; + symbol_iterator Symbol = RelI->getSymbol(); + if (error(Symbol->getName(SymbolName))) return; if (error(SecI->getContents(Contents))) return; if (opts::ExpandRelocs) { diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 2427b7d..67bbafa 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -571,7 +571,6 @@ void ELFDumper<ELFT>::printRelocation(section_iterator Sec, SmallString<32> RelocName; int64_t Addend; StringRef SymbolName; - SymbolRef Symbol; if (Obj->getElfHeader()->e_type == ELF::ET_REL){ if (error(RelI->getOffset(Offset))) return; } else { @@ -580,8 +579,9 @@ void ELFDumper<ELFT>::printRelocation(section_iterator Sec, if (error(RelI->getType(RelocType))) return; if (error(RelI->getTypeName(RelocName))) return; if (error(getELFRelocationAddend(*RelI, Addend))) return; - if (error(RelI->getSymbol(Symbol))) return; - if (error(Symbol.getName(SymbolName))) return; + symbol_iterator Symbol = RelI->getSymbol(); + if (Symbol != Obj->end_symbols() && error(Symbol->getName(SymbolName))) + return; if (opts::ExpandRelocs) { DictScope Group(W, "Relocation"); diff --git a/tools/llvm-readobj/MachODumper.cpp b/tools/llvm-readobj/MachODumper.cpp index 31dc5ce..8df6fd6 100644 --- a/tools/llvm-readobj/MachODumper.cpp +++ b/tools/llvm-readobj/MachODumper.cpp @@ -341,12 +341,11 @@ void MachODumper::printRelocation(const MachOObjectFile *Obj, uint64_t Offset; SmallString<32> RelocName; StringRef SymbolName; - SymbolRef Symbol; if (error(RelI->getOffset(Offset))) return; if (error(RelI->getTypeName(RelocName))) return; - if (error(RelI->getSymbol(Symbol))) return; - if (symbol_iterator(Symbol) != Obj->end_symbols() && - error(Symbol.getName(SymbolName))) + symbol_iterator Symbol = RelI->getSymbol(); + if (Symbol != Obj->end_symbols() && + error(Symbol->getName(SymbolName))) return; DataRefImpl DR = RelI->getRawDataRefImpl(); |