Lines Matching +full:tightly +full:- +full:coupled
1 //===- yaml2elf - Convert YAML to a ELF object file -----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
85 uint64_t PaddingSize = AlignedOffset - CurrentOffset; in padToAlignment()
139 memcpy(&Buf[Pos - InitialOffset], Data, Size); in updateDataAt()
158 Idx = I->getValue(); in lookup()
362 if (Sections.empty() || Sections.front()->Type != ELF::SHT_NULL) in ELFState()
384 if (C->Name.empty()) { in ELFState()
387 C->Name = StringRef(NewName).copy(StringAlloc); in ELFState()
388 assert(ELFYAML::dropUniqueSuffix(C->Name).empty()); in ELFState()
391 if (!DocSections.insert(C->Name).second) in ELFState()
392 reportError("repeated section/fill name: '" + C->Name + in ELFState()
411 for (StringRef DebugSecName : Doc.DWARF->getNonEmptySectionNames()) { in ELFState()
423 if (!SecHdrTable || !SecHdrTable->NoHeaders.value_or(false)) in ELFState()
434 Sec->Name = SecName; in ELFState()
437 Sec->Type = ELF::SHT_STRTAB; in ELFState()
439 Sec->Type = ELF::SHT_DYNSYM; in ELFState()
441 Sec->Type = ELF::SHT_SYMTAB; in ELFState()
443 Sec->Type = ELF::SHT_STRTAB; in ELFState()
451 Doc.Chunks.insert(Doc.Chunks.end() - 1, std::move(Sec)); in ELFState()
546 NameToFill[S->Name] = S; in initProgramHeaders()
547 NameToIndex[Doc.Chunks[I]->Name] = I + 1; in initProgramHeaders()
584 YamlPhdr.Chunks.push_back(Doc.Chunks[I - 1].get()); in initProgramHeaders()
613 SectionHeaders.Sections ? SectionHeaders.Sections->size() : 0; in toSectionIndex()
644 if (From->ShAddrAlign) in overrideFields()
645 To.sh_addralign = *From->ShAddrAlign; in overrideFields()
646 if (From->ShFlags) in overrideFields()
647 To.sh_flags = *From->ShFlags; in overrideFields()
648 if (From->ShName) in overrideFields()
649 To.sh_name = *From->ShName; in overrideFields()
650 if (From->ShOffset) in overrideFields()
651 To.sh_offset = *From->ShOffset; in overrideFields()
652 if (From->ShSize) in overrideFields()
653 To.sh_size = *From->ShSize; in overrideFields()
654 if (From->ShType) in overrideFields()
655 To.sh_type = *From->ShType; in overrideFields()
711 if (SuffixPos == StringRef::npos || S[SuffixPos - 1] != ' ') in dropUniqueSuffix()
713 return S.substr(0, SuffixPos - 1); in dropUniqueSuffix()
722 return ShStrtabStrings->getOffset(Name); in getSectionNameOffset()
731 ContentSize = Content->binary_size(); in writeContent()
737 CBA.writeZeros(*Size - ContentSize); in writeContent()
767 // Ensure SHN_UNDEF entry is present. An all-zero section header is a in initSectionHeaders()
773 S->Offset = alignToOffset(CBA, /*Align=*/1, S->Offset); in initSectionHeaders()
775 LocationCounter += S->Size; in initSectionHeaders()
781 if (S->NoHeaders.value_or(false)) in initSectionHeaders()
784 if (!S->Offset) in initSectionHeaders()
785 S->Offset = alignToOffset(CBA, sizeof(typename ELFT::uint), in initSectionHeaders()
788 S->Offset = alignToOffset(CBA, /*Align=*/1, S->Offset); in initSectionHeaders()
790 uint64_t Size = S->getNumHeaders(SHeaders.size()) * sizeof(Elf_Shdr); in initSectionHeaders()
800 if (IsFirstUndefSection && Sec->IsImplicit) in initSectionHeaders()
803 Elf_Shdr &SHeader = SHeaders[SN2I.get(Sec->Name)]; in initSectionHeaders()
804 if (Sec->Link) { in initSectionHeaders()
805 SHeader.sh_link = toSectionIndex(*Sec->Link, Sec->Name); in initSectionHeaders()
807 StringRef LinkSec = getDefaultLinkSec(Sec->Type); in initSectionHeaders()
814 if (Sec->EntSize) in initSectionHeaders()
815 SHeader.sh_entsize = *Sec->EntSize; in initSectionHeaders()
818 Doc.Header.Machine.value_or(ELF::EM_NONE), Sec->Type, Sec->Name); in initSectionHeaders()
824 if (initImplicitHeader(CBA, SHeader, Sec->Name, in initSectionHeaders()
825 Sec->IsImplicit ? nullptr : Sec)) in initSectionHeaders()
832 getSectionNameOffset(ELFYAML::dropUniqueSuffix(Sec->Name)); in initSectionHeaders()
833 SHeader.sh_type = Sec->Type; in initSectionHeaders()
834 if (Sec->Flags) in initSectionHeaders()
835 SHeader.sh_flags = *Sec->Flags; in initSectionHeaders()
836 SHeader.sh_addralign = Sec->AddressAlign; in initSectionHeaders()
840 if (!IsFirstUndefSection || Sec->Offset) in initSectionHeaders()
841 SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign, Sec->Offset); in initSectionHeaders()
848 if (RawSec->Size) in initSectionHeaders()
849 SHeader.sh_size = *RawSec->Size; in initSectionHeaders()
850 if (RawSec->Info) in initSectionHeaders()
851 SHeader.sh_info = *RawSec->Info; in initSectionHeaders()
859 if (!isa<ELFYAML::NoBitsSection>(Sec) && (Sec->Content || Sec->Size)) in initSectionHeaders()
860 SHeader.sh_size = writeContent(CBA, Sec->Content, Sec->Size); in initSectionHeaders()
918 if (YAMLSec && YAMLSec->Address) { in assignSectionAddress()
919 SHeader.sh_addr = *YAMLSec->Address; in assignSectionAddress()
920 LocationCounter = *YAMLSec->Address; in assignSectionAddress()
925 // in a relocatable object file or non-allocatable sections do not need in assignSectionAddress()
991 if (RawSec && (RawSec->Content || RawSec->Size)) { in initSymtabSectionHeader()
996 if (RawSec->Content) in initSymtabSectionHeader()
998 " for symbol table section '" + RawSec->Name + "'"); in initSymtabSectionHeader()
999 if (RawSec->Size) in initSymtabSectionHeader()
1001 " for symbol table section '" + RawSec->Name + "'"); in initSymtabSectionHeader()
1009 SHeader.sh_type = YAMLSec->Type; in initSymtabSectionHeader()
1013 if (YAMLSec && YAMLSec->Flags) in initSymtabSectionHeader()
1014 SHeader.sh_flags = *YAMLSec->Flags; in initSymtabSectionHeader()
1020 SHeader.sh_info = (RawSec && RawSec->Info) ? (unsigned)(*RawSec->Info) in initSymtabSectionHeader()
1022 SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 8; in initSymtabSectionHeader()
1027 RawSec ? RawSec->Offset : std::nullopt); in initSymtabSectionHeader()
1029 if (RawSec && (RawSec->Content || RawSec->Size)) { in initSymtabSectionHeader()
1031 SHeader.sh_size = writeContent(CBA, RawSec->Content, RawSec->Size); in initSymtabSectionHeader()
1047 SHeader.sh_type = YAMLSec ? YAMLSec->Type : ELF::SHT_STRTAB; in initStrtabSectionHeader()
1048 SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 1; in initStrtabSectionHeader()
1054 YAMLSec ? YAMLSec->Offset : std::nullopt); in initStrtabSectionHeader()
1056 if (RawSec && (RawSec->Content || RawSec->Size)) { in initStrtabSectionHeader()
1057 SHeader.sh_size = writeContent(CBA, RawSec->Content, RawSec->Size); in initStrtabSectionHeader()
1064 if (RawSec && RawSec->Info) in initStrtabSectionHeader()
1065 SHeader.sh_info = *RawSec->Info; in initStrtabSectionHeader()
1067 if (YAMLSec && YAMLSec->Flags) in initStrtabSectionHeader()
1068 SHeader.sh_flags = *YAMLSec->Flags; in initStrtabSectionHeader()
1097 return CBA.tell() - BeginOffset; in emitDWARF()
1105 SHeader.sh_type = YAMLSec ? YAMLSec->Type : ELF::SHT_PROGBITS; in initDWARFSectionHeader()
1106 SHeader.sh_addralign = YAMLSec ? (uint64_t)YAMLSec->AddressAlign : 1; in initDWARFSectionHeader()
1108 YAMLSec ? YAMLSec->Offset : std::nullopt); in initDWARFSectionHeader()
1113 if (RawSec && (RawSec->Content || RawSec->Size)) in initDWARFSectionHeader()
1125 SHeader.sh_size = writeContent(CBA, RawSec->Content, RawSec->Size); in initDWARFSectionHeader()
1130 if (RawSec && RawSec->Info) in initDWARFSectionHeader()
1131 SHeader.sh_info = *RawSec->Info; in initDWARFSectionHeader()
1133 if (YAMLSec && YAMLSec->Flags) in initDWARFSectionHeader()
1134 SHeader.sh_flags = *YAMLSec->Flags; in initDWARFSectionHeader()
1159 Ret.push_back({*F->Offset, F->Size, llvm::ELF::SHT_PROGBITS, in getPhdrFragments()
1165 const Elf_Shdr &H = SHeaders[SN2I.get(S->Name)]; in getPhdrFragments()
1199 uint64_t FileSize = Fragments.back().Offset - PHeader.p_offset; in setProgramHeaderLayout()
1214 : MemOffset - PHeader.p_offset; in setProgramHeaderLayout()
1233 PH.Chunks, [&](ELFYAML::Chunk *C) { return C->Name == S.Name; }); in shouldAllocateFileSpace()
1236 cast<ELFYAML::Section>(C)->Type != ELF::SHT_NOBITS); in shouldAllocateFileSpace()
1252 // When a nobits section is followed by a non-nobits section or fill in writeSectionContent()
1298 CBA.writeULEB128(Section.Relocations->size() * 8 + ELF::CREL_HDR_ADDEND + in writeSectionContent()
1309 (static_cast<typename ELFT::uint>(Rel.Offset) - Offset) >> Shift; in writeSectionContent()
1323 std::make_signed_t<typename ELFT::uint>(CurSymIdx - SymIdx)); in writeSectionContent()
1327 CBA.writeSLEB128(static_cast<int32_t>(Rel.Type - Type)); in writeSectionContent()
1332 std::make_signed_t<typename ELFT::uint>(Rel.Addend - Addend)); in writeSectionContent()
1351 SHeader.sh_size = CBA.getOffset() - CurrentOffset; in writeSectionContent()
1363 reportError(Section.Name + ": the value is too large for 32-bits: 0x" + in writeSectionContent()
1368 SHeader.sh_size = sizeof(uintX_t) * Section.Entries->size(); in writeSectionContent()
1385 SHeader.sh_size = Shndx.Entries->size() * SHeader.sh_entsize; in writeSectionContent()
1410 SHeader.sh_size = SHeader.sh_entsize * Section.Members->size(); in writeSectionContent()
1422 SHeader.sh_size = Section.Entries->size() * SHeader.sh_entsize; in writeSectionContent()
1452 if (Section.Entries->size() != Section.PGOAnalyses->size()) in writeSectionContent()
1475 MultiBBRangeFeatureEnabled = FeatureOrErr->MultiBBRange; in writeSectionContent()
1479 (E.BBRanges && E.BBRanges->size() != 1); in writeSectionContent()
1487 E.NumBBRanges.value_or(E.BBRanges ? E.BBRanges->size() : 0); in writeSectionContent()
1500 BBR.NumBlocks.value_or(BBR.BBEntries ? BBR.BBEntries->size() : 0); in writeSectionContent()
1516 const ELFYAML::PGOAnalysisMapEntry &PGOEntry = PGOAnalyses->at(Idx); in writeSectionContent()
1537 SHeader.sh_size += CBA.writeULEB128(PGOBBE.Successors->size()); in writeSectionContent()
1597 CBA.writeZeros(AlignedOffset - CurrentOffset); in alignToOffset()
1622 Section.NBucket.value_or(llvm::yaml::Hex64(Section.Bucket->size())), in writeSectionContent()
1625 Section.NChain.value_or(llvm::yaml::Hex64(Section.Chain->size())), in writeSectionContent()
1633 SHeader.sh_size = (2 + Section.Bucket->size() + Section.Chain->size()) * 4; in writeSectionContent()
1644 SHeader.sh_info = Section.Entries->size(); in writeSectionContent()
1650 for (size_t I = 0; I < Section.Entries->size(); ++I) { in writeSectionContent()
1660 if (I == Section.Entries->size() - 1) in writeSectionContent()
1670 if (J == E.VerNames.size() - 1) in writeSectionContent()
1678 SHeader.sh_size = Section.Entries->size() * sizeof(Elf_Verdef) + in writeSectionContent()
1689 SHeader.sh_info = Section.VerneedV->size(); in writeSectionContent()
1695 for (size_t I = 0; I < Section.VerneedV->size(); ++I) { in writeSectionContent()
1701 if (I == Section.VerneedV->size() - 1) in writeSectionContent()
1718 if (J == VE.AuxV.size() - 1) in writeSectionContent()
1726 SHeader.sh_size = Section.VerneedV->size() * sizeof(Elf_Verneed) + in writeSectionContent()
1741 SHeader.sh_size = Section.Entries->size() * 8; in writeSectionContent()
1783 SHeader.sh_size = 2 * sizeof(uintX_t) * Section.Entries->size(); in writeSectionContent()
1836 SHeader.sh_size = CBA.tell() - Offset; in writeSectionContent()
1853 if (Section.Header->NBuckets) in writeSectionContent()
1854 CBA.write<uint32_t>(*Section.Header->NBuckets, ELFT::Endianness); in writeSectionContent()
1856 CBA.write<uint32_t>(Section.HashBuckets->size(), ELFT::Endianness); in writeSectionContent()
1860 CBA.write<uint32_t>(Section.Header->SymNdx, ELFT::Endianness); in writeSectionContent()
1864 if (Section.Header->MaskWords) in writeSectionContent()
1865 CBA.write<uint32_t>(*Section.Header->MaskWords, ELFT::Endianness); in writeSectionContent()
1867 CBA.write<uint32_t>(Section.BloomFilter->size(), ELFT::Endianness); in writeSectionContent()
1870 CBA.write<uint32_t>(Section.Header->Shift2, ELFT::Endianness); in writeSectionContent()
1885 Section.BloomFilter->size() * sizeof(typename ELFT::uint) + in writeSectionContent()
1886 Section.HashBuckets->size() * 4 + in writeSectionContent()
1887 Section.HashValues->size() * 4; in writeSectionContent()
1893 size_t PatternSize = Fill.Pattern ? Fill.Pattern->binary_size() : 0; in writeFill()
1903 CBA.writeAsBinary(*Fill.Pattern, Fill.Size - Written); in writeFill()
1937 if (!Seen.count(S->Name)) in buildSectionHeaderReorderMap()
1938 reportError("section '" + S->Name + in buildSectionHeaderReorderMap()
1940 Seen.erase(S->Name); in buildSectionHeaderReorderMap()
1968 if (!ExcludedSectionHeaders.insert(S->Name).second) in buildSectionIndex()
1971 size_t SecNdx = -1; in buildSectionIndex()
1975 size_t Index = ReorderMap.empty() ? SecNdx : ReorderMap.lookup(S->Name); in buildSectionIndex()
1976 if (!SN2I.addName(S->Name, Index)) in buildSectionIndex()
1979 if (!ExcludedSectionHeaders.count(S->Name)) in buildSectionIndex()
1980 ShStrtabStrings->add(ELFYAML::dropUniqueSuffix(S->Name)); in buildSectionIndex()
2015 if (VerNeed->VerneedV) { in finalizeStrings()
2016 for (const ELFYAML::VerneedEntry &VE : *VerNeed->VerneedV) { in finalizeStrings()
2023 if (VerDef->Entries) in finalizeStrings()
2024 for (const ELFYAML::VerdefEntry &E : *VerDef->Entries) in finalizeStrings()
2035 ShStrtabStrings->finalize(); in finalizeStrings()
2061 // XXX: This offset is tightly coupled with the order that we write in writeELF()
2087 "--max-size option to change the limit"); in writeELF()