From 6c1202c459ffa6d693ad92fa84e43902bc780bca Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 5 Jun 2013 01:33:53 +0000 Subject: [PATCH] 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 --- include/llvm/Object/COFF.h | 3 +-- include/llvm/Object/ELF.h | 15 ++++++++------- include/llvm/Object/MachO.h | 2 +- include/llvm/Object/ObjectFile.h | 11 +++++------ lib/DebugInfo/DWARFContext.cpp | 5 ++--- .../RuntimeDyld/RuntimeDyldELF.cpp | 14 ++++++-------- .../RuntimeDyld/RuntimeDyldMachO.cpp | 5 ++--- lib/Object/COFFObjectFile.cpp | 6 ++---- lib/Object/MachOObjectFile.cpp | 13 +++++-------- lib/Object/Object.cpp | 5 +---- .../X86/MCTargetDesc/X86ELFRelocationInfo.cpp | 8 ++++---- .../X86/MCTargetDesc/X86MachORelocationInfo.cpp | 13 ++++++------- test/Object/Inputs/elf-reloc-no-sym.x86_64 | Bin 0 -> 1768 bytes test/Object/elf-reloc-no-sym.test | 7 +++++++ tools/llvm-objdump/COFFDump.cpp | 2 +- tools/llvm-objdump/MachODump.cpp | 5 ++--- tools/llvm-readobj/COFFDumper.cpp | 8 +++----- tools/llvm-readobj/ELFDumper.cpp | 6 +++--- tools/llvm-readobj/MachODumper.cpp | 7 +++---- 19 files changed, 62 insertions(+), 73 deletions(-) create mode 100755 test/Object/Inputs/elf-reloc-no-sym.x86_64 create mode 100644 test/Object/elf-reloc-no-sym.test diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 1127263c995..c0efbbaab12 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -243,8 +243,7 @@ protected: uint64_t &Res) const; virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const; - virtual error_code getRelocationSymbol(DataRefImpl Rel, - SymbolRef &Res) const; + virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const; virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 592dbae39e4..a6c545ec9d1 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -716,8 +716,7 @@ protected: uint64_t &Res) const; virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const; - virtual error_code getRelocationSymbol(DataRefImpl Rel, - SymbolRef &Res) const; + virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const; virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, @@ -1503,9 +1502,9 @@ error_code ELFObjectFile::getRelocationNext(DataRefImpl Rel, return object_error::success; } -template -error_code ELFObjectFile::getRelocationSymbol(DataRefImpl Rel, - SymbolRef &Result) const { +template +symbol_iterator +ELFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { uint32_t symbolIdx; const Elf_Shdr *sec = getRelSection(Rel); switch (sec->sh_type) { @@ -1520,6 +1519,9 @@ error_code ELFObjectFile::getRelocationSymbol(DataRefImpl Rel, break; } } + if (!symbolIdx) + return end_symbols(); + DataRefImpl SymbolData; IndexMap_t::const_iterator it = SymbolTableSectionsIndexMap.find(sec->sh_link); @@ -1527,8 +1529,7 @@ error_code ELFObjectFile::getRelocationSymbol(DataRefImpl Rel, report_fatal_error("Relocation symbol table not found!"); SymbolData.d.a = symbolIdx; SymbolData.d.b = it->second; - Result = SymbolRef(SymbolData, this); - return object_error::success; + return symbol_iterator(SymbolRef(SymbolData, this)); } template diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index bedf5c101e2..f3ba8ef7572 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -72,7 +72,7 @@ public: RelocationRef &Res) const; virtual error_code getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const; virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const; - virtual error_code getRelocationSymbol(DataRefImpl Rel, SymbolRef &Res) const; + virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const; virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const; virtual error_code getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl &Result) const; diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index ba1bb6945b0..f434d63736f 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -85,6 +85,7 @@ inline bool operator<(const DataRefImpl &a, const DataRefImpl &b) { } class SymbolRef; +typedef content_iterator symbol_iterator; /// RelocationRef - This is a value type class that represents a single /// relocation in the list of relocations in the object file. @@ -103,7 +104,7 @@ public: error_code getAddress(uint64_t &Result) const; error_code getOffset(uint64_t &Result) const; - error_code getSymbol(SymbolRef &Result) const; + symbol_iterator getSymbol() const; error_code getType(uint64_t &Result) const; /// @brief Indicates whether this relocation should hidden when listing @@ -236,7 +237,6 @@ public: DataRefImpl getRawDataRefImpl() const; }; -typedef content_iterator symbol_iterator; /// LibraryRef - This is a value type class that represents a single library in /// the list of libraries needed by a shared or dynamic object. @@ -334,8 +334,7 @@ protected: uint64_t &Res) const =0; virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const =0; - virtual error_code getRelocationSymbol(DataRefImpl Rel, - SymbolRef &Res) const = 0; + virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0; virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const = 0; virtual error_code getRelocationTypeName(DataRefImpl Rel, @@ -566,8 +565,8 @@ inline error_code RelocationRef::getOffset(uint64_t &Result) const { return OwningObject->getRelocationOffset(RelocationPimpl, Result); } -inline error_code RelocationRef::getSymbol(SymbolRef &Result) const { - return OwningObject->getRelocationSymbol(RelocationPimpl, Result); +inline symbol_iterator RelocationRef::getSymbol() const { + return OwningObject->getRelocationSymbol(RelocationPimpl); } inline error_code RelocationRef::getType(uint64_t &Result) const { diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 7e4132f059b..aaae952da5b 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -595,9 +595,8 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) : uint64_t SymAddr = 0; // ELF relocations may need the symbol address if (Obj->isELF()) { - object::SymbolRef Sym; - reloc_i->getSymbol(Sym); - Sym.getAddress(SymAddr); + object::symbol_iterator Sym = reloc_i->getSymbol(); + Sym->getAddress(SymAddr); } object::RelocVisitor V(Obj->getFileFormatName()); diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index ee424db6aff..e552cea1bc0 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -551,9 +551,8 @@ void RuntimeDyldELF::findOPDEntrySection(ObjectImage &Obj, continue; } - SymbolRef TargetSymbol; uint64_t TargetSymbolOffset; - check(i->getSymbol(TargetSymbol)); + symbol_iterator TargetSymbol = i->getSymbol(); check(i->getOffset(TargetSymbolOffset)); int64_t Addend; check(getELFRelocationAddend(*i, Addend)); @@ -576,7 +575,7 @@ void RuntimeDyldELF::findOPDEntrySection(ObjectImage &Obj, continue; section_iterator tsi(Obj.end_sections()); - check(TargetSymbol.getSection(tsi)); + check(TargetSymbol->getSection(tsi)); Rel.SectionID = findOrEmitSection(Obj, (*tsi), true, LocalSections); Rel.Addend = (intptr_t)Addend; return; @@ -777,12 +776,11 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID, Check(RelI.getType(RelType)); int64_t Addend; Check(getELFRelocationAddend(RelI, Addend)); - SymbolRef Symbol; - Check(RelI.getSymbol(Symbol)); + symbol_iterator Symbol = RelI.getSymbol(); // Obtain the symbol name which is referenced in the relocation StringRef TargetName; - Symbol.getName(TargetName); + Symbol->getName(TargetName); DEBUG(dbgs() << "\t\tRelType: " << RelType << " Addend: " << Addend << " TargetName: " << TargetName @@ -791,7 +789,7 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID, // First search for the symbol in the local symbol table SymbolTableMap::const_iterator lsi = Symbols.find(TargetName.data()); SymbolRef::Type SymType; - Symbol.getType(SymType); + Symbol->getType(SymType); if (lsi != Symbols.end()) { Value.SectionID = lsi->second.first; Value.Addend = lsi->second.second + Addend; @@ -809,7 +807,7 @@ void RuntimeDyldELF::processRelocationRef(unsigned SectionID, // and can be changed by another developers. Maybe best way is add // a new symbol type ST_Section to SymbolRef and use it. section_iterator si(Obj.end_sections()); - Symbol.getSection(si); + Symbol->getSection(si); if (si == Obj.end_sections()) llvm_unreachable("Symbol section not found, bad object file format!"); DEBUG(dbgs() << "\t\tThis is section symbol\n"); diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 01a3fd9f82d..0384b322624 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -302,10 +302,9 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID, if (isExtern) { // Obtain the symbol name which is referenced in the relocation - SymbolRef Symbol; - RelI.getSymbol(Symbol); + symbol_iterator Symbol = RelI.getSymbol(); StringRef TargetName; - Symbol.getName(TargetName); + Symbol->getName(TargetName); // First search for the symbol in the local symbol table SymbolTableMap::const_iterator lsi = Symbols.find(TargetName.data()); if (lsi != Symbols.end()) { diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index f5b49ab0618..bc5958d3c47 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -712,13 +712,11 @@ error_code COFFObjectFile::getRelocationOffset(DataRefImpl Rel, Res = toRel(Rel)->VirtualAddress; return object_error::success; } -error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel, - SymbolRef &Res) const { +symbol_iterator COFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { const coff_relocation* R = toRel(Rel); DataRefImpl Symb; Symb.p = reinterpret_cast(SymbolTable + R->SymbolTableIndex); - Res = SymbolRef(Symb, this); - return object_error::success; + return symbol_iterator(SymbolRef(Symb, this)); } error_code COFFObjectFile::getRelocationType(DataRefImpl Rel, uint64_t &Res) const { diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 654af081f9e..bd5ea57c1f5 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -869,15 +869,13 @@ error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel, return object_error::success; } -error_code -MachOObjectFile::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Res) const { +symbol_iterator +MachOObjectFile::getRelocationSymbol(DataRefImpl Rel) const { macho::RelocationEntry RE = getRelocation(Rel); uint32_t SymbolIdx = getPlainRelocationSymbolNum(RE); bool isExtern = getPlainRelocationExternal(RE); - if (!isExtern) { - Res = *end_symbols(); - return object_error::success; - } + if (!isExtern) + return end_symbols(); macho::SymtabLoadCommand S = getSymtabLoadCommand(); unsigned SymbolTableEntrySize = is64Bit() ? @@ -886,8 +884,7 @@ MachOObjectFile::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Res) const { uint64_t Offset = S.SymbolTableOffset + SymbolIdx * SymbolTableEntrySize; DataRefImpl Sym; Sym.p = reinterpret_cast(getPtr(this, Offset)); - Res = SymbolRef(Sym, this); - return object_error::success; + return symbol_iterator(SymbolRef(Sym, this)); } error_code MachOObjectFile::getRelocationType(DataRefImpl Rel, diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index 3e2c78ec47c..6941708dd34 100644 --- a/lib/Object/Object.cpp +++ b/lib/Object/Object.cpp @@ -219,10 +219,7 @@ uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI) { } LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI) { - SymbolRef ret; - if (error_code ec = (*unwrap(RI))->getSymbol(ret)) - report_fatal_error(ec.message()); - + symbol_iterator ret = (*unwrap(RI))->getSymbol(); return wrap(new symbol_iterator(ret)); } diff --git a/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp b/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp index 917c37d2ca5..8f4ab4673d5 100644 --- a/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp +++ b/lib/Target/X86/MCTargetDesc/X86ELFRelocationInfo.cpp @@ -27,11 +27,11 @@ public: const MCExpr *createExprForRelocation(RelocationRef Rel) { uint64_t RelType; Rel.getType(RelType); - SymbolRef SymRef; Rel.getSymbol(SymRef); + symbol_iterator SymI = Rel.getSymbol(); - StringRef SymName; SymRef.getName(SymName); - uint64_t SymAddr; SymRef.getAddress(SymAddr); - uint64_t SymSize; SymRef.getSize(SymSize); + StringRef SymName; SymI->getName(SymName); + uint64_t SymAddr; SymI->getAddress(SymAddr); + uint64_t SymSize; SymI->getSize(SymSize); int64_t Addend; getELFRelocationAddend(Rel, Addend); MCSymbol *Sym = Ctx.GetOrCreateSymbol(SymName); diff --git a/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp b/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp index a76cad555df..75b5acf5089 100644 --- a/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp +++ b/lib/Target/X86/MCTargetDesc/X86MachORelocationInfo.cpp @@ -28,10 +28,10 @@ public: const MachOObjectFile *Obj = cast(Rel.getObjectFile()); uint64_t RelType; Rel.getType(RelType); - SymbolRef SymRef; Rel.getSymbol(SymRef); + symbol_iterator SymI = Rel.getSymbol(); - StringRef SymName; SymRef.getName(SymName); - uint64_t SymAddr; SymRef.getAddress(SymAddr); + StringRef SymName; SymI->getName(SymName); + uint64_t SymAddr; SymI->getAddress(SymAddr); RelocationEntry RE = Obj->getRelocation(Rel.getRawDataRefImpl()); bool isPCRel = Obj->getAnyRelocationPCRel(RE); @@ -86,12 +86,11 @@ public: const MCExpr *LHS = MCSymbolRefExpr::Create(Sym, Ctx); - SymbolRef RSymRef; - RelNext.getSymbol(RSymRef); + symbol_iterator RSymI = RelNext.getSymbol(); uint64_t RSymAddr; - RSymRef.getAddress(RSymAddr); + RSymI->getAddress(RSymAddr); StringRef RSymName; - RSymRef.getName(RSymName); + RSymI->getName(RSymName); MCSymbol *RSym = Ctx.GetOrCreateSymbol(RSymName); if (RSym->isVariable() == false) diff --git a/test/Object/Inputs/elf-reloc-no-sym.x86_64 b/test/Object/Inputs/elf-reloc-no-sym.x86_64 new file mode 100755 index 0000000000000000000000000000000000000000..a41b4e0d78d9906ab271cd0286f05a961a1f7f3a GIT binary patch literal 1768 zcmbtUO=}Zj5S~r?5oy}4qEe#JRT|Jj7lSBbwI-FMQ9^^-;z>5!X44eXP04Px^`cM_ zJP7?6{s<4j7Wx+iFS!&Vc&K+_o!OmfmZcGj1Mkc`&-*;@=j^`AmkKdO0kIg&0cBYw z>qCJD_!9S1#_mBJvM>rspF7wa!d{lMAhvmGiJ%6<1P@^oynUYe95oyx(|nJPbabvEh~IhMG;1_IpLgdQ&g`WR(C?vnY0B%w`q}Y3ulRY8wz^+DY)@0{{y=cQrjJj4 zAPy`SKOGf!f2oK0Ka_UAl4kcneYH<1z{Mbd^7c6>+p2OUIh@$T8LuKvt&RK?adKno z$Jpahx)ZV~Y!9$ia9qO(V`^b+;_3Lvo5Xu~l$xEsJ$0Snes-D9H-Ln5*eEV6F2h>0 zQPnbfCeu&II30QbetS{c2m(rM2;{vcm~ai_1+0o2ysqeOVkd>T+_&H}%)b@k)4ph) zEaU#&Aa)mvCJ7VhFL-eQNPx|1nUfZ%)_0`QyFcwPX`CQ2;7YZ-(OU6=ezLYn> zFzVKhkpc9u*>GXQT(`lns-|n=*oxyAj%&7DgzPGS?poU}=xfcu>7>wGR>KT>NC(|+ zx|Y6XZy~Euoq27wob{#+x>Yx7Epx*H-Kjfn%QaW9Cvj)P&;3<{gZ`(#gnFuhd7h`s z-)Wa~c}GfP*b)((-hpaD>J#MM2t?C--*f!A%4h3q!+NO)jrI3?Qokp9foHKpRN5O^ zh1ajJzT%@jC;JzK{uxA#Ga&WbX1(wvM)gS?_?KQ2A;+lRi0Gw`JAKxtw+h=NCN!t) z|E&5c)SmX=l=bOf6t?L4FL6-rKFkyFm_hnK&>rRdQdechnRXJ6dD6ubB &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 03a383eb120..1ee3e42dab7 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 94aafa7eb11..3cbb9b3c34b 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -201,8 +201,7 @@ static error_code resolveSymbol(const std::vector &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 2427b7d3b14..67bbafaf6f2 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -571,7 +571,6 @@ void ELFDumper::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::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 31dc5ce24a2..8df6fd6457f 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(); -- 2.34.1