From 1c01e2defe3e2eaf49c4f45a67c46a03570fda25 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 18 May 2016 05:31:24 +0000 Subject: [PATCH] [RuntimeDyld] Thread Error through some APIs, remove calls to report_fatal_error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269881 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../RuntimeDyld/Targets/RuntimeDyldCOFFI386.h | 18 ++++------------- .../Targets/RuntimeDyldCOFFX86_64.h | 18 ++++------------- .../Targets/RuntimeDyldMachOAArch64.h | 20 +++++-------------- .../Targets/RuntimeDyldMachOX86_64.h | 20 +++++-------------- 4 files changed, 18 insertions(+), 58 deletions(-) diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h index 4ce83798950..468ce111486 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h @@ -46,23 +46,13 @@ public: report_fatal_error("Unknown symbol in relocation"); Expected TargetNameOrErr = Symbol->getName(); - if (!TargetNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(TargetNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!TargetNameOrErr) + return TargetNameOrErr.takeError(); StringRef TargetName = *TargetNameOrErr; auto SectionOrErr = Symbol->getSection(); - if (!SectionOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(SectionOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!SectionOrErr) + return SectionOrErr.takeError(); auto Section = *SectionOrErr; uint64_t RelType = RelI->getType(); diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h index f3a32eefa3e..df8681da24d 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -118,13 +118,8 @@ public: if (Symbol == Obj.symbol_end()) report_fatal_error("Unknown symbol in relocation"); auto SectionOrError = Symbol->getSection(); - if (!SectionOrError) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(SectionOrError.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!SectionOrError) + return SectionOrError.takeError(); section_iterator SecI = *SectionOrError; // If there is no section, this must be an external reference. const bool IsExtern = SecI == Obj.section_end(); @@ -161,13 +156,8 @@ public: } Expected TargetNameOrErr = Symbol->getName(); - if (!TargetNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(TargetNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!TargetNameOrErr) + return TargetNameOrErr.takeError(); StringRef TargetName = *TargetNameOrErr; DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h index 7d1a62f08e1..63598f19707 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h @@ -417,7 +417,7 @@ private: addRelocationForSection(TargetRE, RE.SectionID); } - relocation_iterator + Expected processSubtractRelocation(unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, ObjSectionToIDMap &ObjSectionToID) { @@ -432,13 +432,8 @@ private: unsigned NumBytes = 1 << Size; Expected SubtrahendNameOrErr = RelI->getSymbol()->getName(); - if (!SubtrahendNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(SubtrahendNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!SubtrahendNameOrErr) + return SubtrahendNameOrErr.takeError(); auto SubtrahendI = GlobalSymbolTable.find(*SubtrahendNameOrErr); unsigned SectionBID = SubtrahendI->second.getSectionID(); uint64_t SectionBOffset = SubtrahendI->second.getOffset(); @@ -447,13 +442,8 @@ private: ++RelI; Expected MinuendNameOrErr = RelI->getSymbol()->getName(); - if (!MinuendNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(MinuendNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!MinuendNameOrErr) + return MinuendNameOrErr.takeError(); auto MinuendI = GlobalSymbolTable.find(*MinuendNameOrErr); unsigned SectionAID = MinuendI->second.getSectionID(); uint64_t SectionAOffset = MinuendI->second.getOffset(); diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h index 2aad3c832e2..0f1407dd8de 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h @@ -155,7 +155,7 @@ private: resolveRelocation(TargetRE, (uint64_t)Addr); } - relocation_iterator + Expected processSubtractRelocation(unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, ObjSectionToIDMap &ObjSectionToID) { @@ -170,13 +170,8 @@ private: unsigned NumBytes = 1 << Size; Expected SubtrahendNameOrErr = RelI->getSymbol()->getName(); - if (!SubtrahendNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(SubtrahendNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!SubtrahendNameOrErr) + return SubtrahendNameOrErr.takeError(); auto SubtrahendI = GlobalSymbolTable.find(*SubtrahendNameOrErr); unsigned SectionBID = SubtrahendI->second.getSectionID(); uint64_t SectionBOffset = SubtrahendI->second.getOffset(); @@ -185,13 +180,8 @@ private: ++RelI; Expected MinuendNameOrErr = RelI->getSymbol()->getName(); - if (!MinuendNameOrErr) { - std::string Buf; - raw_string_ostream OS(Buf); - logAllUnhandledErrors(MinuendNameOrErr.takeError(), OS, ""); - OS.flush(); - report_fatal_error(Buf); - } + if (!MinuendNameOrErr) + return MinuendNameOrErr.takeError(); auto MinuendI = GlobalSymbolTable.find(*MinuendNameOrErr); unsigned SectionAID = MinuendI->second.getSectionID(); uint64_t SectionAOffset = MinuendI->second.getOffset();