Lines Matching refs:BC

361   BC = std::move(BCOrErr.get());  in RewriteInstance()
362 BC->initializeTarget(std::unique_ptr<MCPlusBuilder>(createMCPlusBuilder( in RewriteInstance()
363 BC->TheTriple->getArch(), BC->MIA.get(), BC->MII.get(), BC->MRI.get()))); in RewriteInstance()
365 BAT = std::make_unique<BoltAddressTranslation>(*BC); in RewriteInstance()
368 DebugInfoRewriter = std::make_unique<DWARFRewriter>(*BC); in RewriteInstance()
371 BC->setRuntimeLibrary(std::make_unique<InstrumentationRuntimeLibrary>()); in RewriteInstance()
373 BC->setRuntimeLibrary(std::make_unique<HugifyRuntimeLibrary>()); in RewriteInstance()
420 BC->EFMM.reset(new ExecutableFileMemoryManager(*BC, /*AllowStubs*/ false)); in discoverStorage()
425 BC->StartFunctionAddress = Obj.getHeader().e_entry; in discoverStorage()
437 BC->FirstAllocAddress = std::min(BC->FirstAllocAddress, in discoverStorage()
444 BC->SegmentMapInfo[Phdr.p_vaddr] = SegmentInfo{Phdr.p_vaddr, in discoverStorage()
451 BC->HasInterpHeader = true; in discoverStorage()
462 BC->OldTextSectionAddress = Section.getAddress(); in discoverStorage()
463 BC->OldTextSectionSize = Section.getSize(); in discoverStorage()
469 BC->OldTextSectionOffset = in discoverStorage()
487 << Twine::utohexstr(BC->FirstAllocAddress) << '\n'; in discoverStorage()
491 NextAvailableAddress = alignTo(NextAvailableAddress, BC->PageAlign); in discoverStorage()
492 NextAvailableOffset = alignTo(NextAvailableOffset, BC->PageAlign); in discoverStorage()
505 if (NextAvailableOffset <= NextAvailableAddress - BC->FirstAllocAddress) in discoverStorage()
506 NextAvailableOffset = NextAvailableAddress - BC->FirstAllocAddress; in discoverStorage()
508 NextAvailableAddress = NextAvailableOffset + BC->FirstAllocAddress; in discoverStorage()
511 NextAvailableAddress - BC->FirstAllocAddress && in discoverStorage()
535 BC->LayoutStartAddress = NextAvailableAddress; in discoverStorage()
539 if (!getFileOffsetForAddress(BC->OldTextSectionAddress)) in discoverStorage()
552 DataExtractor DE = DataExtractor(Buf, BC->AsmInfo->isLittleEndian(), in parseSDTNotes()
553 BC->AsmInfo->getCodePointerSize()); in parseSDTNotes()
585 BC->SDTMarkers[Marker.PC] = Marker; in parseSDTNotes()
608 if (!BC->ProbeDecoder.buildGUID2FuncDescMap( in parsePseudoProbe()
615 if (!BC->ProbeDecoder.buildAddress2ProbeMap( in parsePseudoProbe()
618 BC->ProbeDecoder.getAddress2ProbesMap().clear(); in parsePseudoProbe()
627 BC->ProbeDecoder.printGUID2FuncDescMap(outs()); in parsePseudoProbe()
628 BC->ProbeDecoder.printProbesForAllAddresses(outs()); in parsePseudoProbe()
633 outs() << "BOLT-INFO: Number of SDT markers is " << BC->SDTMarkers.size() in printSDTMarkers()
635 for (auto It : BC->SDTMarkers) { in printSDTMarkers()
719 assert(BC && "failed to create a binary context"); in run()
783 BC->getBinaryFunctions().clear(); in discoverFileObjects()
784 BC->clearBinaryData(); in discoverFileObjects()
837 BinarySection Section(*BC, *cantFail(Sym.getSection())); in discoverFileObjects()
851 bool AMarker = BC->isMarker(A); in discoverFileObjects()
852 bool BMarker = BC->isMarker(B); in discoverFileObjects()
896 MarkerSymType MarkerType = BC->getMarkerType(*Sym); in discoverFileObjects()
912 if (BC->isAArch64()) { in discoverFileObjects()
916 [this](const SymbolRef &Symbol) { return !BC->isMarker(Symbol); }); in discoverFileObjects()
956 ErrorOr<BinarySection &> BSection = BC->getSectionForAddress(Address); in discoverFileObjects()
964 std::string Name = SymName.startswith(BC->AsmInfo->getPrivateGlobalPrefix()) in discoverFileObjects()
979 assert(!BC->getBinaryDataByName(Name) && "global name not unique"); in discoverFileObjects()
1009 BC->registerNameAtAddress(UniqueName, Address, FinalSize, SymbolAlignment, in discoverFileObjects()
1012 BC->registerNameAtAddress(AlternativeName, Address, FinalSize, in discoverFileObjects()
1123 if (BC->getBinaryDataAtAddress(Address)) { in discoverFileObjects()
1124 BC->setBinaryDataSize(Address, SymbolSize); in discoverFileObjects()
1136 auto BFI = BC->getBinaryFunctions().find(Address); in discoverFileObjects()
1137 if (BFI != BC->getBinaryFunctions().end()) { in discoverFileObjects()
1150 BC->setBinaryDataSize(Address, BF->getSize()); in discoverFileObjects()
1154 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(Address); in discoverFileObjects()
1167 BF = BC->createBinaryFunction(UniqueName, *Section, Address, SymbolSize); in discoverFileObjects()
1190 const BinaryFunction *BF = BC->getBinaryFunctionAtAddress(Address); in discoverFileObjects()
1194 BF = BC->getBinaryFunctionContainingAddress(Address); in discoverFileObjects()
1207 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(Address); in discoverFileObjects()
1211 BC->createBinaryFunction(FunctionName, *Section, Address, in discoverFileObjects()
1215 BC->setHasSymbolsWithFileName(SeenFileName); in discoverFileObjects()
1225 BC->getBinaryFunctionContainingAddress(ISym->Address, true, true); in discoverFileObjects()
1238 BC->AddressToConstantIslandMap[ISym->Address] = BF; in discoverFileObjects()
1260 const unsigned PtrSize = BC->AsmInfo->getCodePointerSize(); in createPLTBinaryFunction()
1261 MCSymbol *TargetSymbol = BC->registerNameAtAddress( in createPLTBinaryFunction()
1266 BinaryFunction *BF = BC->getBinaryFunctionAtAddress(EntryAddress); in createPLTBinaryFunction()
1267 if (BF && BC->isAArch64()) { in createPLTBinaryFunction()
1273 const Relocation *Rel = BC->getDynamicRelocationAt(TargetAddress); in createPLTBinaryFunction()
1277 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(EntryAddress); in createPLTBinaryFunction()
1279 BF = BC->createBinaryFunction(Rel->Symbol->getName().str() + "@PLT", *Section, in createPLTBinaryFunction()
1295 if (!BC->DisAsm->getInstruction(Instruction, InstrSize, in disassemblePLTSectionAArch64()
1317 if (!BC->MIB->isIndirectBranch(Instruction)) { in disassemblePLTSectionAArch64()
1324 const uint64_t TargetAddress = BC->MIB->analyzePLTEntry( in disassemblePLTSectionAArch64()
1337 if (!BC->MIB->isNoop(Instruction)) in disassemblePLTSectionAArch64()
1356 if (!BC->DisAsm->getInstruction(Instruction, InstrSize, in disassemblePLTSectionX86()
1373 if (EntryOffset == 0 && BC->MIB->isTerminateBranch(Instruction) && in disassemblePLTSectionX86()
1377 if (BC->MIB->isIndirectBranch(Instruction)) in disassemblePLTSectionX86()
1387 if (!BC->MIB->evaluateMemOperandTarget(Instruction, TargetAddress, in disassemblePLTSectionX86()
1402 if (BC->isAArch64()) in disassemblePLT()
1407 for (BinarySection &Section : BC->allocatableSections()) { in disassemblePLT()
1415 if (BC->getBinaryFunctions().find(Section.getAddress()) == in disassemblePLT()
1416 BC->getBinaryFunctions().end()) { in disassemblePLT()
1417 BinaryFunction *BF = BC->createBinaryFunction( in disassemblePLT()
1426 for (auto BFI = BC->getBinaryFunctions().begin(), in adjustFunctionBoundaries()
1427 BFE = BC->getBinaryFunctions().end(); in adjustFunctionBoundaries()
1439 if (BC->HasRelocations && !PrintedWarning) { in adjustFunctionBoundaries()
1511 BC->AsmInfo->isLittleEndian(), in relocateEHFrameSection()
1512 BC->AsmInfo->getCodePointerSize()); in relocateEHFrameSection()
1577 BC->registerSection(Section); in readSpecialSections()
1595 HasTextRelocations = (bool)BC->getUniqueSectionByName(".rela.text"); in readSpecialSections()
1596 LSDASection = BC->getUniqueSectionByName(".gcc_except_table"); in readSpecialSections()
1597 EHFrameSection = BC->getUniqueSectionByName(".eh_frame"); in readSpecialSections()
1598 GOTPLTSection = BC->getUniqueSectionByName(".got.plt"); in readSpecialSections()
1599 RelaPLTSection = BC->getUniqueSectionByName(".rela.plt"); in readSpecialSections()
1600 RelaDynSection = BC->getUniqueSectionByName(".rela.dyn"); in readSpecialSections()
1601 BuildIDSection = BC->getUniqueSectionByName(".note.gnu.build-id"); in readSpecialSections()
1602 SDTSection = BC->getUniqueSectionByName(".note.stapsdt"); in readSpecialSections()
1603 PseudoProbeDescSection = BC->getUniqueSectionByName(".pseudo_probe_desc"); in readSpecialSections()
1604 PseudoProbeSection = BC->getUniqueSectionByName(".pseudo_probe"); in readSpecialSections()
1607 BC->getUniqueSectionByName(BoltAddressTranslation::SECTION_NAME)) { in readSpecialSections()
1620 BC->printSections(outs()); in readSpecialSections()
1629 BC->HasRelocations = in readSpecialSections()
1634 BC->HasRelocations = false; in readSpecialSections()
1636 if (BC->HasRelocations) in readSpecialSections()
1641 Expected<const DWARFDebugFrame *> EHFrameOrError = BC->DwCtx->getEHFrame(); in readSpecialSections()
1649 BC->setFileBuildID(*FileBuildID); in readSpecialSections()
1658 if (BC->isAArch64() && !BC->HasRelocations) in adjustCommandLineOptions()
1662 if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary()) in adjustCommandLineOptions()
1663 RtLibrary->adjustCommandLineOptions(*BC); in adjustCommandLineOptions()
1665 if (opts::AlignMacroOpFusion != MFT_NONE && !BC->isX86()) { in adjustCommandLineOptions()
1670 if (BC->isX86() && BC->MAB->allowAutoPadding()) { in adjustCommandLineOptions()
1671 if (!BC->HasRelocations) { in adjustCommandLineOptions()
1681 if (opts::AlignMacroOpFusion != MFT_NONE && !BC->HasRelocations) { in adjustCommandLineOptions()
1687 if (opts::SplitEH && !BC->HasRelocations) { in adjustCommandLineOptions()
1692 if (opts::StrictMode && !BC->HasRelocations) { in adjustCommandLineOptions()
1698 if (BC->HasRelocations && opts::AggregateOnly && in adjustCommandLineOptions()
1705 if (BC->isX86() && BC->HasRelocations && in adjustCommandLineOptions()
1712 if (!BC->HasRelocations && in adjustCommandLineOptions()
1722 } else if (opts::HotText && !BC->HasRelocations) { in adjustCommandLineOptions()
1733 if (opts::UseOldText && !BC->OldTextSectionAddress) { in adjustCommandLineOptions()
1738 if (opts::UseOldText && !BC->HasRelocations) { in adjustCommandLineOptions()
1744 opts::AlignText = BC->PageAlign; in adjustCommandLineOptions()
1749 if (BC->isX86() && opts::Lite.getNumOccurrences() == 0 && !opts::StrictMode && in adjustCommandLineOptions()
1855 const bool IsAArch64 = BC->isAArch64(); in analyzeRelocation()
1860 BC->getUnsignedValueAtAddress(Rel.getOffset(), RelSize); in analyzeRelocation()
1875 BC->getOrCreateGlobalSymbol(SymbolAddress, "RELSYMat"); in analyzeRelocation()
1887 const BinaryData *BD = BC->getPLTBinaryDataByName(SymbolName); in analyzeRelocation()
1898 if (!BC->HasFixedLoadAddress && RelSize == 8) in analyzeRelocation()
1902 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(SymbolAddress); in analyzeRelocation()
1972 BC->getSectionForAddress(*PLTRelocationsAddress); in processDynamicRelocations()
1986 BC->getSectionForAddress(*DynamicRelocationsAddress); in processDynamicRelocations()
1999 if (!BC->HasRelocations) in processRelocations()
2004 !BinarySection(*BC, Section).isAllocatable()) in processRelocations()
2016 BC->LKMarkers[PC].emplace_back(LKInstructionMarkerInfo{ in insertLKMarker()
2048 BC->getUniqueSectionByName("__ex_table"); in processLKExTable()
2058 ErrorOr<uint64_t> Offset = BC->getSignedValueAtAddress(EntryAddress, 4); in processLKExTable()
2064 BC->getBinaryFunctionContainingAddress(RefAddress); in processLKExTable()
2082 BC->addRelocation(EntryAddress, ReferencedSymbol, Relocation::getPC32(), in processLKExTable()
2089 BC->addRelocation(EntryAddress, ReferencedSymbol, Relocation::getPC32(), in processLKExTable()
2103 BC->getUniqueSectionByName(".pci_fixup"); in processLKPCIFixup()
2112 ErrorOr<uint64_t> Offset = BC->getSignedValueAtAddress(PC, 4); in processLKPCIFixup()
2117 BC->getBinaryFunctionAtAddress(HookupAddress); in processLKPCIFixup()
2119 BC->addRelocation(PC, HookupFunction->getSymbol(), Relocation::getPC32(), 0, in processLKPCIFixup()
2135 BC->getUniqueSectionByName(SectionName); in processLKKSymtab()
2145 ErrorOr<uint64_t> Offset = BC->getSignedValueAtAddress(EntryAddress, 4); in processLKKSymtab()
2149 BinaryFunction *BF = BC->getBinaryFunctionAtAddress(RefAddress); in processLKKSymtab()
2153 BC->addRelocation(EntryAddress, BF->getSymbol(), Relocation::getPC32(), 0, in processLKKSymtab()
2167 BC->getUniqueSectionByName("__bug_table"); in processLKBugTable()
2177 ErrorOr<uint64_t> Offset = BC->getSignedValueAtAddress(EntryAddress, 4); in processLKBugTable()
2182 assert(BC->getBinaryFunctionContainingAddress(RefAddress) && in processLKBugTable()
2193 BC->getUniqueSectionByName(".smp_locks"); in processLKSMPLocks()
2204 ErrorOr<uint64_t> Offset = BC->getSignedValueAtAddress(EntryAddress, 4); in processLKSMPLocks()
2210 BC->getBinaryFunctionContainingAddress(RefAddress); in processLKSMPLocks()
2220 assert(BinarySection(*BC, Section).isAllocatable() && "allocatable expected"); in readDynamicRelocations()
2241 BinaryData *BD = BC->getBinaryDataByName(SymbolName); in readDynamicRelocations()
2243 : BC->getOrCreateUndefinedGlobalSymbol(SymbolName); in readDynamicRelocations()
2263 BC->addDynamicRelocation(Rel.getOffset(), Symbol, RType, Addend); in readDynamicRelocations()
2273 if (BinarySection(*BC, Section).isAllocatable()) { in readRelocations()
2285 if (!BinarySection(*BC, RelocatedSection).isAllocatable()) { in readRelocations()
2300 const bool IsAArch64 = BC->isAArch64(); in readRelocations()
2311 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(SymbolAddress); in readRelocations()
2322 if (BinaryFunction *Func = BC->getBinaryFunctionContainingAddress( in readRelocations()
2326 dbgs() << BC->getSectionForAddress(Rel.getOffset())->getName() << "\n"; in readRelocations()
2337 if (BC->isX86() && (RType & ELF::R_X86_64_converted_reloc_bit)) { in readRelocations()
2345 if (BC->isX86()) in readRelocations()
2353 if (!IsAArch64 && BC->getDynamicRelocationAt(Rel.getOffset())) { in readRelocations()
2392 BC->getBinaryFunctionContainingAddress(Rel.getOffset(), in readRelocations()
2408 if (BinaryData *BD = BC->getBinaryDataByName(SymbolName)) in readRelocations()
2412 BC->getSectionForAddress(SymbolAddress); in readRelocations()
2432 BC->addPCRelativeDataRelocation(Rel.getOffset()); in readRelocations()
2449 bool ForceRelocation = BC->forceSymbolRelocations(SymbolName); in readRelocations()
2450 if (BC->isAArch64() && Relocation::isGOT(RType)) in readRelocations()
2461 BinaryFunction *ReferencedBF = BC->getBinaryFunctionContainingAddress( in readRelocations()
2466 BC->getBinaryFunctionContainingAddress(SymbolAddress)) { in readRelocations()
2496 BC->getBinaryFunctionAtAddress(Address + 1)) { in readRelocations()
2521 ReferencedSymbol = BC->registerNameAtAddress(Name, 0, 0, 0); in readRelocations()
2545 !BinarySection(*BC, RelocatedSection).isReadOnly()) in readRelocations()
2577 if (BinaryData *BD = BC->getBinaryDataContainingAddress(SymbolAddress)) { in readRelocations()
2594 BC->markAmbiguousRelocations(*BD, Address); in readRelocations()
2605 BC->getSectionNameForAddress(SymbolAddress)->startswith(".plt")) && in readRelocations()
2610 BC->getOrCreateGlobalSymbol(SymbolAddress, "SYMBOLat"); in readRelocations()
2623 .startswith(BC->AsmInfo->getPrivateGlobalPrefix())) in readRelocations()
2628 ReferencedSymbol = BC->registerNameAtAddress( in readRelocations()
2633 BinaryData *BD = BC->getBinaryDataByName(ReferencedSymbol->getName()); in readRelocations()
2634 BC->markAmbiguousRelocations(*BD, Address); in readRelocations()
2661 BC->addRelocation(Rel.getOffset(), ReferencedSymbol, RType, Addend, in readRelocations()
2703 for (auto &BFI : BC->getBinaryFunctions()) { in selectFunctionsToProcess()
2758 for (auto &BFI : BC->getBinaryFunctions()) { in selectFunctionsToProcess()
2786 BC->preprocessDebugInfo(); in readDebugInfo()
2805 if (Error E = ProfileReader->preprocessProfile(*BC.get())) in preprocessProfileData()
2808 if (!BC->hasSymbolsWithFileName() && ProfileReader->hasLocalsWithFileName() && in preprocessProfileData()
2826 if (Error E = ProfileReader->readProfilePreCFG(*BC.get())) in processProfileDataPreCFG()
2837 if (Error E = ProfileReader->readProfile(*BC.get())) in processProfileData()
2855 for (auto &BFI : BC->getBinaryFunctions()) { in disassembleFunctions()
2886 BC->exitWithBugReport("function cannot be properly disassembled. " in disassembleFunctions()
2901 BC->processInterproceduralReferences(); in disassembleFunctions()
2902 BC->populateJumpTables(); in disassembleFunctions()
2904 for (auto &BFI : BC->getBinaryFunctions()) { in disassembleFunctions()
2914 BC->clearJumpTableTempData(); in disassembleFunctions()
2915 BC->adjustCodePadding(); in disassembleFunctions()
2917 for (auto &BFI : BC->getBinaryFunctions()) { in disassembleFunctions()
2924 assert((!BC->HasRelocations || Function.getSize() == 0 || in disassembleFunctions()
2932 if (BC->HasRelocations) { in disassembleFunctions()
2933 BC->exitWithBugReport("unable to fill CFI.", Function); in disassembleFunctions()
2944 !BC->getFragmentsToSkip().count(&Function)) in disassembleFunctions()
2954 BC->MIB->getOrCreateAnnotationIndex("JTIndexReg"); in buildFunctionsCFG()
2955 BC->MIB->getOrCreateAnnotationIndex("NOP"); in buildFunctionsCFG()
2956 BC->MIB->getOrCreateAnnotationIndex("Size"); in buildFunctionsCFG()
2964 auto L = BC->scopeLock(); in buildFunctionsCFG()
2974 *BC, ParallelUtilities::SchedulingPolicy::SP_INST_LINEAR, WorkFun, in buildFunctionsCFG()
2978 BC->postProcessSymbolTable(); in buildFunctionsCFG()
2984 BC->skipMarkedFragments(); in postProcessFunctions()
2985 BC->clearFragmentsToSkip(); in postProcessFunctions()
2987 BC->TotalScore = 0; in postProcessFunctions()
2988 BC->SumExecutionCount = 0; in postProcessFunctions()
2989 for (auto &BFI : BC->getBinaryFunctions()) { in postProcessFunctions()
3008 BC->TotalScore += Function.getFunctionScore(); in postProcessFunctions()
3009 BC->SumExecutionCount += Function.getKnownExecutionCount(); in postProcessFunctions()
3014 BC->printGlobalSymbols(outs()); in postProcessFunctions()
3021 BinaryFunctionPassManager::runAllPasses(*BC); in runOptimizationPasses()
3027 BinaryContext &BC; member in __anonc7c09cfe1711::BOLTSymbolResolver
3030 BOLTSymbolResolver(BinaryContext &BC) : BC(BC) {} in BOLTSymbolResolver() argument
3045 if (BC.EFMM->ObjectsLoaded) { in lookup()
3050 if (const BinaryData *I = BC.getPLTBinaryDataByName(SymName)) { in lookup()
3068 if (BinaryData *I = BC.getBinaryDataByName(SymName)) { in lookup()
3107 std::unique_ptr<MCStreamer> Streamer = BC->createStreamer(*OS); in emitAndLink()
3120 emitBinaryContext(*Streamer, *BC, getOrgSecPrefix()); in emitAndLink()
3139 BOLTSymbolResolver Resolver = BOLTSymbolResolver(*BC); in emitAndLink()
3144 RTDyld.reset(new decltype(RTDyld)::element_type(*BC->EFMM, Resolver)); in emitAndLink()
3167 if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary()) in emitAndLink()
3168 RtLibrary->link(*BC, ToolPath, *RTDyld, [this](RuntimeDyld &R) { in emitAndLink()
3174 for (BinaryFunction *Function : BC->getAllBinaryFunctions()) { in emitAndLink()
3183 BC->deregisterSection(*Section); in emitAndLink()
3188 BC->deregisterSection(*ColdSection); in emitAndLink()
3195 CacheMetrics::printAll(BC->getSortedFunctions()); in emitAndLink()
3224 if (BC->ProbeDecoder.getAddress2ProbesMap().empty()) in updatePseudoProbes()
3227 AddressProbesMap &Address2ProbesMap = BC->ProbeDecoder.getAddress2ProbesMap(); in updatePseudoProbes()
3229 BC->ProbeDecoder.getGUID2FuncDescMap(); in updatePseudoProbes()
3232 BinaryFunction *F = BC->getBinaryFunctionContainingAddress(AP.first); in updatePseudoProbes()
3295 for (auto &F : BC->getBinaryFunctions()) in updatePseudoProbes()
3340 const bool IsLittleEndian = BC->AsmInfo->isLittleEndian(); in encodePseudoProbes()
3378 uint32_t AddrSize = BC->AsmInfo->getCodePointerSize(); in encodePseudoProbes()
3394 BC->ProbeDecoder.getDummyInlineRoot(); in encodePseudoProbes()
3458 BC->registerOrUpdateSection(".pseudo_probe", PseudoProbeSection->getELFType(), in encodePseudoProbes()
3488 for (auto &SDTInfoKV : BC->SDTMarkers) { in updateSDTMarkers()
3492 BC->getBinaryFunctionContainingAddress(OriginalAddress); in updateSDTMarkers()
3502 if (BC->LKMarkers.size() == 0) in updateLKMarkers()
3510 &LKMarkerInfoKV : BC->LKMarkers) { in updateLKMarkers()
3513 BC->getBinaryFunctionContainingAddress(OriginalAddress, false, true); in updateLKMarkers()
3531 ErrorOr<BinarySection &> BSec = BC->getUniqueSectionByName(SectionName); in updateLKMarkers()
3559 for (BinarySection &Section : BC->textSections()) in getCodeSections()
3565 if (A->getName() == BC->getHotTextMoverSectionName()) in getCodeSections()
3567 if (B->getName() == BC->getHotTextMoverSectionName()) in getCodeSections()
3572 return B->getName() == BC->getMainCodeSectionName(); in getCodeSections()
3574 return A->getName() == BC->getMainCodeSectionName(); in getCodeSections()
3584 if (BC->HasRelocations) { in mapCodeSections()
3586 BC->getUniqueSectionByName(BC->getMainCodeSectionName()); in mapCodeSections()
3591 for (BinaryFunction *InjectedFunction : BC->getInjectedBinaryFunctions()) { in mapCodeSections()
3632 HotTextEnd = alignTo(HotTextEnd, BC->PageAlign); in mapCodeSections()
3645 allocateAt(BC->OldTextSectionAddress) - BC->OldTextSectionAddress; in mapCodeSections()
3647 if (CodeSize <= BC->OldTextSectionSize) { in mapCodeSections()
3655 << BC->OldTextSectionSize << " bytes available.\n"; in mapCodeSections()
3687 for (auto &BFI : BC->getBinaryFunctions()) { in mapCodeSections()
3766 BC->registerOrUpdateSection(getBOLTTextSectionName(), in mapCodeSections()
3785 if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary()) in mapDataSections()
3789 ErrorOr<BinarySection &> Section = BC->getUniqueSectionByName(SectionName); in mapDataSections()
3811 for (BinarySection &Section : BC->sections()) { in mapDataSections()
3817 BC->getUniqueSectionByName((getOrgSecPrefix() + SectionName).str()); in mapDataSections()
3846 for (BinarySection &Section : BC->allocatableSections()) { in mapExtraSections()
3867 for (BinaryFunction *Function : BC->getAllBinaryFunctions()) in updateOutputValues()
3919 NewPhdr.p_align = BC->PageAlign; in patchELFPHDRTable()
3935 BC->getUniqueSectionByName(".eh_frame_hdr"); in patchELFPHDRTable()
4008 ErrorOr<BinarySection &> BSec = BC->getUniqueSectionByName(SectionName); in rewriteNoteSections()
4033 BSec = BC->registerOrUpdateNoteSection( in rewriteNoteSections()
4070 BC->registerOrUpdateNoteSection(SectionName, in rewriteNoteSections()
4084 for (BinarySection &Section : BC->nonAllocatableSections()) { in rewriteNoteSections()
4120 for (const BinarySection &Section : BC->sections()) in finalizeSectionStringTable()
4128 BC->registerOrUpdateNoteSection(".shstrtab", in finalizeSectionStringTable()
4149 BC->registerOrUpdateNoteSection(".note.bolt_info", copyByteArray(BoltInfo), in addBoltInfoSection()
4156 BC->registerOrUpdateNoteSection(BoltAddressTranslation::SECTION_NAME, nullptr, in addBATSection()
4171 BC->registerOrUpdateNoteSection(BoltAddressTranslation::SECTION_NAME, in encodeBATSection()
4240 for (const BinarySection &Section : BC->allocatableSections()) { in getOutputSections()
4316 ErrorOr<BinarySection &> BSec = BC->getUniqueSectionByName(SectionName); in getOutputSections()
4332 for (BinarySection &Section : BC->nonAllocatableSections()) { in getOutputSections()
4360 BC->getUniqueSectionByName(SectionName)) in getOutputSections()
4430 if (BC->HasRelocations) { in patchELFSectionHeaderTable()
4431 if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary()) in patchELFSectionHeaderTable()
4595 BC->getBinaryFunctionAtAddress(Symbol.st_value); in updateELFSymbolTable()
4634 ? BC->getBinaryFunctionContainingAddress(Symbol.st_value, in updateELFSymbolTable()
4655 : BC->getBinaryDataAtAddress(Symbol.st_value); in updateELFSymbolTable()
4665 << *BC->getSectionNameForAddress(Symbol.st_value) << " (" in updateELFSymbolTable()
4681 if (BC->getBinaryFunctionContainingAddress(Symbol.st_value, in updateELFSymbolTable()
4732 for (BinaryFunction *Function : BC->getInjectedBinaryFunctions()) { in updateELFSymbolTable()
4826 assert((DynSymSection || BC->IsStaticExecutable) && in patchELFSymTabs()
4885 BC->registerOrUpdateNoteSection(SecName, in patchELFSymTabs()
4892 BC->registerOrUpdateNoteSection(StrSecName, in patchELFSymTabs()
4912 ErrorOr<BinarySection &> Section = BC->getSectionForAddress(Address); in patchELFAllocatableRelaSections()
4936 for (BinarySection &Section : BC->allocatableSections()) { in patchELFAllocatableRelaSections()
5022 if (!BC->IsStaticExecutable) in patchELFGOT()
5046 if (BC->IsStaticExecutable) in patchELFDynamic()
5087 if (BC->HasRelocations) { in patchELFDynamic()
5094 RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary(); in patchELFDynamic()
5099 if (RtLibrary && Dyn.getTag() == ELF::DT_INIT && !BC->HasInterpHeader) { in patchELFDynamic()
5109 if (BC->RequiresZNow) { in patchELFDynamic()
5115 if (BC->RequiresZNow) { in patchELFDynamic()
5126 if (BC->RequiresZNow && !ZNowSet) { in patchELFDynamic()
5153 BC->IsStaticExecutable = true; in readELFDynamic()
5170 if (!BC->HasInterpHeader) { in readELFDynamic()
5172 BC->StartFunctionAddress = Dyn.getPtr(); in readELFDynamic()
5176 BC->FiniFunctionAddress = Dyn.getPtr(); in readELFDynamic()
5209 const BinaryFunction *Function = BC->getBinaryFunctionAtAddress(OldAddress); in getNewFunctionAddress()
5220 const BinaryData *BD = BC->getBinaryDataAtAddress(OldAddress); in getNewFunctionOrDataAddress()
5241 BC->TheTarget->createMCAsmBackend(*BC->STI, *BC->MRI, MCTargetOptions())); in rewriteFile()
5242 auto Streamer = BC->createStreamer(OS); in rewriteFile()
5255 for (BinaryFunction *Function : BC->getAllBinaryFunctions()) { in rewriteFile()
5269 if (!BC->HasRelocations && opts::JumpTables == JTS_BASIC) { in rewriteFile()
5273 BC->deregisterSection(Section); in rewriteFile()
5296 &*BC->STI); in rewriteFile()
5328 if (!BC->HasRelocations) { in rewriteFile()
5330 << BC->getBinaryFunctions().size() in rewriteFile()
5332 if (BC->TotalScore != 0) { in rewriteFile()
5333 double Coverage = OverwrittenScore / (double)BC->TotalScore * 100.0; in rewriteFile()
5340 if (BC->HasRelocations && opts::TrapOldCode) { in rewriteFile()
5343 for (auto &BFI : BC->getBinaryFunctions()) { in rewriteFile()
5349 OS.write((unsigned char)BC->MIB->getTrapFillValue()); in rewriteFile()
5355 for (BinarySection &Section : BC->allocatableSections()) { in rewriteFile()
5368 for (BinarySection &Section : BC->allocatableSections()) in rewriteFile()
5399 if (BC->HasRelocations) { in rewriteFile()
5412 BC->printSections(outs()); in rewriteFile()
5421 DWARFDebugFrame NewEHFrame(BC->TheTriple->getArch(), true, in writeEHFrameHeader()
5424 EHFrameSection->getOutputContents(), BC->AsmInfo->isLittleEndian(), in writeEHFrameHeader()
5425 BC->AsmInfo->getCodePointerSize())); in writeEHFrameHeader()
5431 BC->getUniqueSectionByName(Twine(getOrgSecPrefix(), ".eh_frame").str()); in writeEHFrameHeader()
5436 DWARFDebugFrame OldEHFrame(BC->TheTriple->getArch(), true, OldEHFrameAddress); in writeEHFrameHeader()
5438 DWARFDataExtractor(OldEHFrameContents, BC->AsmInfo->isLittleEndian(), in writeEHFrameHeader()
5439 BC->AsmInfo->getCodePointerSize())); in writeEHFrameHeader()
5460 BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection( in writeEHFrameHeader()
5474 BC->registerOrUpdateSection(".eh_frame", in writeEHFrameHeader()
5480 BC->deregisterSection(*OldEHFrameSection); in writeEHFrameHeader()
5493 BinaryData *BD = BC->getBinaryDataByName(Name); in getNewValueForSymbol()
5506 const auto SegmentInfoI = BC->SegmentMapInfo.upper_bound(Address); in getFileOffsetForAddress()
5507 if (SegmentInfoI == BC->SegmentMapInfo.begin()) in getFileOffsetForAddress()
5526 ErrorOr<BinarySection &> Section = BC->getUniqueSectionByName(SectionName); in willOverwriteSection()