diff options
Diffstat (limited to 'llvm/lib/ExecutionEngine')
5 files changed, 43 insertions, 11 deletions
diff --git a/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp b/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp index 1fff153bf24..962e8d06397 100644 --- a/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp +++ b/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp @@ -113,9 +113,12 @@ void IntelJITEventListener::NotifyObjectEmitted( std::vector<LineNumberInfo> LineInfo; std::string SourceFileName; - ErrorOr<SymbolRef::Type> SymTypeOrErr = Sym.getType(); - if (!SymTypeOrErr) + Expected<SymbolRef::Type> SymTypeOrErr = Sym.getType(); + if (!SymTypeOrErr) { + // TODO: Actually report errors helpfully. + consumeError(SymTypeOrErr.takeError()); continue; + } SymbolRef::Type SymType = *SymTypeOrErr; if (SymType != SymbolRef::ST_Function) continue; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 5ac2db96245..a14a6bbd1e5 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -211,7 +211,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { if (auto SymTypeOrErr = I->getType()) SymType = *SymTypeOrErr; else - return errorCodeToError(SymTypeOrErr.getError()); + return SymTypeOrErr.takeError(); // Get symbol name. StringRef Name; @@ -252,7 +252,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { if (auto SIOrErr = I->getSection()) SI = *SIOrErr; else - return errorCodeToError(SIOrErr.getError()); + return SIOrErr.takeError(); if (SI == Obj.section_end()) continue; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index d36794dc704..a080b1374e4 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -877,7 +877,7 @@ Error RuntimeDyldELF::findOPDEntrySection(const ELFObjectFileBase &Obj, if (auto TSIOrErr = TargetSymbol->getSection()) TSI = *TSIOrErr; else - return errorCodeToError(TSIOrErr.getError()); + return TSIOrErr.takeError(); assert(TSI != Obj.section_end() && "TSI should refer to a valid section"); bool IsCode = TSI->isText(); @@ -1210,9 +1210,14 @@ RuntimeDyldELF::processRelocationRef( RTDyldSymbolTable::const_iterator gsi = GlobalSymbolTable.end(); if (Symbol != Obj.symbol_end()) { gsi = GlobalSymbolTable.find(TargetName.data()); - ErrorOr<SymbolRef::Type> SymTypeOrErr = Symbol->getType(); - if (std::error_code EC = SymTypeOrErr.getError()) - report_fatal_error(EC.message()); + Expected<SymbolRef::Type> SymTypeOrErr = Symbol->getType(); + if (!SymTypeOrErr) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(SymTypeOrErr.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } SymType = *SymTypeOrErr; } if (gsi != GlobalSymbolTable.end()) { @@ -1226,7 +1231,15 @@ RuntimeDyldELF::processRelocationRef( // TODO: Now ELF SymbolRef::ST_Debug = STT_SECTION, it's not obviously // 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 = *Symbol->getSection(); + auto SectionOrErr = Symbol->getSection(); + if (!SectionOrErr) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(SectionOrErr.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } + section_iterator si = *SectionOrErr; if (si == Obj.section_end()) llvm_unreachable("Symbol section not found, bad object file format!"); DEBUG(dbgs() << "\t\tThis is section symbol\n"); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h index 3456b337197..4ce83798950 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h @@ -55,7 +55,15 @@ public: } StringRef TargetName = *TargetNameOrErr; - auto Section = *Symbol->getSection(); + auto SectionOrErr = Symbol->getSection(); + if (!SectionOrErr) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(SectionOrErr.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } + auto Section = *SectionOrErr; uint64_t RelType = RelI->getType(); uint64_t Offset = RelI->getOffset(); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h index 7dd112e5f83..f3a32eefa3e 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -117,7 +117,15 @@ public: symbol_iterator Symbol = RelI->getSymbol(); if (Symbol == Obj.symbol_end()) report_fatal_error("Unknown symbol in relocation"); - section_iterator SecI = *Symbol->getSection(); + auto SectionOrError = Symbol->getSection(); + if (!SectionOrError) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(SectionOrError.takeError(), OS, ""); + OS.flush(); + report_fatal_error(Buf); + } + section_iterator SecI = *SectionOrError; // If there is no section, this must be an external reference. const bool IsExtern = SecI == Obj.section_end(); |