diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp --- a/bolt/lib/Core/BinaryContext.cpp +++ b/bolt/lib/Core/BinaryContext.cpp @@ -1119,14 +1119,19 @@ bool BinaryContext::registerFragment(BinaryFunction &TargetFunction, BinaryFunction &Function) const { - if (!isPotentialFragmentByName(TargetFunction, Function)) + // Only use symbol name matching for non-stripped binaries + if (!IsStripped && !isPotentialFragmentByName(TargetFunction, Function)) return false; assert(TargetFunction.isFragment() && "TargetFunction must be a fragment"); if (TargetFunction.isParentFragment(&Function)) return true; TargetFunction.addParentFragment(Function); Function.addFragment(TargetFunction); - if (!HasRelocations) { + + // Stripped binaries mostly don't have .rela.text section + // Without .rela.text, BOLT cannot reliably move code + // Temporarily relax this check for stripped binaries + if (!IsStripped && !HasRelocations) { TargetFunction.setSimple(false); Function.setSimple(false); } diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -1602,10 +1602,10 @@ if (!getSecondaryEntryPointSymbol(Label)) continue; - // In non-relocation mode there's potentially an external undetectable - // reference to the entry point and hence we cannot move this entry - // point. Optimizing without moving could be difficult. - if (!BC.HasRelocations) + // Stripped binaries mostly don't have .rela.text section + // Without .rela.text, BOLT cannot reliably move code + // Temporarily relax this check for stripped binaries + if (!BC.IsStripped && !BC.HasRelocations) setSimple(false); const uint32_t Offset = KV.first;