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 @@ -3818,18 +3818,18 @@ // Handling for sections with relocations. for (BinarySection &Section : BC->sections()) { - if (!Section.hasSectionRef()) + if (!Section.hasSectionRef() || !Section.isAllocatable()) continue; StringRef SectionName = Section.getName(); ErrorOr OrgSection = BC->getUniqueSectionByName((getOrgSecPrefix() + SectionName).str()); - if (!OrgSection || - !OrgSection->isAllocatable() || - !OrgSection->isFinalized() || - !OrgSection->hasValidSectionID()) + if (!OrgSection) continue; + assert(OrgSection->isAllocatable() && OrgSection->isFinalized() && + OrgSection->hasValidSectionID() && "section check failed"); + if (OrgSection->getOutputAddress()) { LLVM_DEBUG(dbgs() << "BOLT-DEBUG: section " << SectionName << " is already mapped at 0x"