diff --git a/bolt/include/bolt/Rewrite/RewriteInstance.h b/bolt/include/bolt/Rewrite/RewriteInstance.h --- a/bolt/include/bolt/Rewrite/RewriteInstance.h +++ b/bolt/include/bolt/Rewrite/RewriteInstance.h @@ -96,7 +96,7 @@ /// Read info from special sections. E.g. eh_frame and .gcc_except_table /// for exception and stack unwinding information. - void readSpecialSections(); + Error readSpecialSections(); /// Adjust supplied command-line options based on input data. void adjustCommandLineOptions(); diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -765,7 +765,8 @@ if (Error E = discoverStorage()) return E; - readSpecialSections(); + if (Error E = readSpecialSections()) + return E; adjustCommandLineOptions(); discoverFileObjects(); @@ -1540,7 +1541,7 @@ uint64_t RewriteInstance::getLSDAAddress() { return LSDASection->getAddress(); } -void RewriteInstance::readSpecialSections() { +Error RewriteInstance::readSpecialSections() { NamedRegionTimer T("readSpecialSections", "read special sections", TimerGroupName, TimerGroupDesc, opts::TimeRewrite); @@ -1555,6 +1556,8 @@ // Only register sections with names. if (!SectionName.empty()) { + if (Error E = Section.getContents().takeError()) + return E; BC->registerSection(Section); LLVM_DEBUG( dbgs() << "BOLT-DEBUG: registering section " << SectionName << " @ 0x" @@ -1633,6 +1636,7 @@ // Read .dynamic/PT_DYNAMIC. readELFDynamic(); + return Error::success(); } void RewriteInstance::adjustCommandLineOptions() {