Lines Matching refs:ELFYAML

202   ELFYAML::Object &Doc;
212 std::vector<Elf_Sym> toELFSymbols(ArrayRef<ELFYAML::Symbol> Symbols,
221 StringRef SecName, ELFYAML::Section *YAMLSec);
226 ELFYAML::Section *YAMLSec);
230 ELFYAML::Section *YAMLSec);
233 ELFYAML::Section *YAMLSec);
238 getPhdrFragments(const ELFYAML::ProgramHeader &Phdr,
244 const ELFYAML::NoBitsSection &Section,
247 const ELFYAML::RawContentSection &Section,
250 const ELFYAML::RelocationSection &Section,
253 const ELFYAML::RelrSection &Section,
256 const ELFYAML::GroupSection &Group,
259 const ELFYAML::SymtabShndxSection &Shndx,
262 const ELFYAML::SymverSection &Section,
265 const ELFYAML::VerneedSection &Section,
268 const ELFYAML::VerdefSection &Section,
271 const ELFYAML::ARMIndexTableSection &Section,
274 const ELFYAML::MipsABIFlags &Section,
277 const ELFYAML::DynamicSection &Section,
280 const ELFYAML::StackSizesSection &Section,
283 const ELFYAML::BBAddrMapSection &Section,
286 const ELFYAML::HashSection &Section,
289 const ELFYAML::AddrsigSection &Section,
292 const ELFYAML::NoteSection &Section,
295 const ELFYAML::GnuHashSection &Section,
298 const ELFYAML::LinkerOptionsSection &Section,
301 const ELFYAML::DependentLibrariesSection &Section,
304 const ELFYAML::CallGraphProfileSection &Section,
307 void writeFill(ELFYAML::Fill &Fill, ContiguousBlobAccumulator &CBA);
309 ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH);
311 void assignSectionAddress(Elf_Shdr &SHeader, ELFYAML::Section *YAMLSec);
322 static bool writeELF(raw_ostream &OS, ELFYAML::Object &Doc,
338 ELFState<ELFT>::ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH) in ELFState()
352 std::vector<ELFYAML::Section *> Sections = Doc.getSections(); in ELFState()
357 std::make_unique<ELFYAML::Section>( in ELFState()
358 ELFYAML::Chunk::ChunkKind::RawContent, /*IsImplicit=*/true)); in ELFState()
361 ELFYAML::SectionHeaderTable *SecHdrTable = nullptr; in ELFState()
363 const std::unique_ptr<ELFYAML::Chunk> &C = Doc.Chunks[I]; in ELFState()
366 if (auto S = dyn_cast<ELFYAML::SectionHeaderTable>(C.get())) { in ELFState()
377 std::string NewName = ELFYAML::appendUniqueSuffix( in ELFState()
380 assert(ELFYAML::dropUniqueSuffix(C->Name).empty()); in ELFState()
424 std::unique_ptr<ELFYAML::Section> Sec = std::make_unique<ELFYAML::Section>( in ELFState()
425 ELFYAML::Chunk::ChunkKind::RawContent, true /*IsImplicit*/); in ELFState()
452 std::make_unique<ELFYAML::SectionHeaderTable>(/*IsImplicit=*/true)); in ELFState()
506 const ELFYAML::SectionHeaderTable &SectionHeaders = in writeELFHeader()
534 DenseMap<StringRef, ELFYAML::Fill *> NameToFill; in initProgramHeaders()
537 if (auto S = dyn_cast<ELFYAML::Fill>(Doc.Chunks[I].get())) in initProgramHeaders()
542 std::vector<ELFYAML::Section *> Sections = Doc.getSections(); in initProgramHeaders()
544 ELFYAML::ProgramHeader &YamlPhdr = Doc.ProgramHeaders[I]; in initProgramHeaders()
596 const ELFYAML::SectionHeaderTable &SectionHeaders = in toSectionIndex()
634 static void overrideFields(ELFYAML::Section *From, typename ELFT::Shdr &To) { in overrideFields()
654 ELFYAML::Section *YAMLSec) { in initImplicitHeader()
672 if (YAMLSec && !isa<ELFYAML::RawContentSection>(YAMLSec)) in initImplicitHeader()
688 std::string llvm::ELFYAML::appendUniqueSuffix(StringRef Name, in appendUniqueSuffix()
695 StringRef llvm::ELFYAML::dropUniqueSuffix(StringRef S) { in dropUniqueSuffix()
764 for (const std::unique_ptr<ELFYAML::Chunk> &D : Doc.Chunks) { in initSectionHeaders()
765 if (ELFYAML::Fill *S = dyn_cast<ELFYAML::Fill>(D.get())) { in initSectionHeaders()
772 if (ELFYAML::SectionHeaderTable *S = in initSectionHeaders()
773 dyn_cast<ELFYAML::SectionHeaderTable>(D.get())) { in initSectionHeaders()
791 ELFYAML::Section *Sec = cast<ELFYAML::Section>(D.get()); in initSectionHeaders()
810 SHeader.sh_entsize = ELFYAML::getDefaultShEntSize<ELFT>( in initSectionHeaders()
825 getSectionNameOffset(ELFYAML::dropUniqueSuffix(Sec->Name)); in initSectionHeaders()
839 if (auto RawSec = dyn_cast<ELFYAML::RawContentSection>(Sec)) { in initSectionHeaders()
852 if (!isa<ELFYAML::NoBitsSection>(Sec) && (Sec->Content || Sec->Size)) in initSectionHeaders()
855 if (auto S = dyn_cast<ELFYAML::RawContentSection>(Sec)) { in initSectionHeaders()
857 } else if (auto S = dyn_cast<ELFYAML::SymtabShndxSection>(Sec)) { in initSectionHeaders()
859 } else if (auto S = dyn_cast<ELFYAML::RelocationSection>(Sec)) { in initSectionHeaders()
861 } else if (auto S = dyn_cast<ELFYAML::RelrSection>(Sec)) { in initSectionHeaders()
863 } else if (auto S = dyn_cast<ELFYAML::GroupSection>(Sec)) { in initSectionHeaders()
865 } else if (auto S = dyn_cast<ELFYAML::ARMIndexTableSection>(Sec)) { in initSectionHeaders()
867 } else if (auto S = dyn_cast<ELFYAML::MipsABIFlags>(Sec)) { in initSectionHeaders()
869 } else if (auto S = dyn_cast<ELFYAML::NoBitsSection>(Sec)) { in initSectionHeaders()
871 } else if (auto S = dyn_cast<ELFYAML::DynamicSection>(Sec)) { in initSectionHeaders()
873 } else if (auto S = dyn_cast<ELFYAML::SymverSection>(Sec)) { in initSectionHeaders()
875 } else if (auto S = dyn_cast<ELFYAML::VerneedSection>(Sec)) { in initSectionHeaders()
877 } else if (auto S = dyn_cast<ELFYAML::VerdefSection>(Sec)) { in initSectionHeaders()
879 } else if (auto S = dyn_cast<ELFYAML::StackSizesSection>(Sec)) { in initSectionHeaders()
881 } else if (auto S = dyn_cast<ELFYAML::HashSection>(Sec)) { in initSectionHeaders()
883 } else if (auto S = dyn_cast<ELFYAML::AddrsigSection>(Sec)) { in initSectionHeaders()
885 } else if (auto S = dyn_cast<ELFYAML::LinkerOptionsSection>(Sec)) { in initSectionHeaders()
887 } else if (auto S = dyn_cast<ELFYAML::NoteSection>(Sec)) { in initSectionHeaders()
889 } else if (auto S = dyn_cast<ELFYAML::GnuHashSection>(Sec)) { in initSectionHeaders()
891 } else if (auto S = dyn_cast<ELFYAML::DependentLibrariesSection>(Sec)) { in initSectionHeaders()
893 } else if (auto S = dyn_cast<ELFYAML::CallGraphProfileSection>(Sec)) { in initSectionHeaders()
895 } else if (auto S = dyn_cast<ELFYAML::BBAddrMapSection>(Sec)) { in initSectionHeaders()
910 ELFYAML::Section *YAMLSec) { in assignSectionAddress()
929 static size_t findFirstNonGlobal(ArrayRef<ELFYAML::Symbol> Symbols) { in findFirstNonGlobal()
938 ELFState<ELFT>::toELFSymbols(ArrayRef<ELFYAML::Symbol> Symbols, in toELFSymbols()
944 for (const ELFYAML::Symbol &Sym : Symbols) { in toELFSymbols()
953 Symbol.st_name = Strtab.getOffset(ELFYAML::dropUniqueSuffix(Sym.Name)); in toELFSymbols()
973 ELFYAML::Section *YAMLSec) { in initSymtabSectionHeader()
976 ArrayRef<ELFYAML::Symbol> Symbols; in initSymtabSectionHeader()
982 ELFYAML::RawContentSection *RawSec = in initSymtabSectionHeader()
983 dyn_cast_or_null<ELFYAML::RawContentSection>(YAMLSec); in initSymtabSectionHeader()
1038 ELFYAML::Section *YAMLSec) { in initStrtabSectionHeader()
1039 SHeader.sh_name = getSectionNameOffset(ELFYAML::dropUniqueSuffix(Name)); in initStrtabSectionHeader()
1043 ELFYAML::RawContentSection *RawSec = in initStrtabSectionHeader()
1044 dyn_cast_or_null<ELFYAML::RawContentSection>(YAMLSec); in initStrtabSectionHeader()
1096 ELFYAML::Section *YAMLSec) { in initDWARFSectionHeader()
1097 SHeader.sh_name = getSectionNameOffset(ELFYAML::dropUniqueSuffix(Name)); in initDWARFSectionHeader()
1103 ELFYAML::RawContentSection *RawSec = in initDWARFSectionHeader()
1104 dyn_cast_or_null<ELFYAML::RawContentSection>(YAMLSec); in initDWARFSectionHeader()
1147 ELFState<ELFT>::getPhdrFragments(const ELFYAML::ProgramHeader &Phdr, in getPhdrFragments()
1150 for (const ELFYAML::Chunk *C : Phdr.Chunks) { in getPhdrFragments()
1151 if (const ELFYAML::Fill *F = dyn_cast<ELFYAML::Fill>(C)) { in getPhdrFragments()
1157 const ELFYAML::Section *S = cast<ELFYAML::Section>(C); in getPhdrFragments()
1222 bool llvm::ELFYAML::shouldAllocateFileSpace( in shouldAllocateFileSpace()
1223 ArrayRef<ELFYAML::ProgramHeader> Phdrs, const ELFYAML::NoBitsSection &S) { in shouldAllocateFileSpace()
1224 for (const ELFYAML::ProgramHeader &PH : Phdrs) { in shouldAllocateFileSpace()
1226 PH.Chunks, [&](ELFYAML::Chunk *C) { return C->Name == S.Name; }); in shouldAllocateFileSpace()
1227 if (std::any_of(It, PH.Chunks.end(), [](ELFYAML::Chunk *C) { in shouldAllocateFileSpace()
1228 return (isa<ELFYAML::Fill>(C) || in shouldAllocateFileSpace()
1229 cast<ELFYAML::Section>(C)->Type != ELF::SHT_NOBITS); in shouldAllocateFileSpace()
1238 const ELFYAML::NoBitsSection &S, in writeSectionContent()
1254 Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section, in writeSectionContent()
1260 static bool isMips64EL(const ELFYAML::Object &Obj) { in isMips64EL()
1262 Obj.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64) && in isMips64EL()
1263 Obj.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB); in isMips64EL()
1268 Elf_Shdr &SHeader, const ELFYAML::RelocationSection &Section, in writeSectionContent()
1281 for (const ELFYAML::Relocation &Rel : *Section.Relocations) { in writeSectionContent()
1307 const ELFYAML::RelrSection &Section, in writeSectionContent()
1324 Elf_Shdr &SHeader, const ELFYAML::SymtabShndxSection &Shndx, in writeSectionContent()
1341 const ELFYAML::GroupSection &Section, in writeSectionContent()
1353 for (const ELFYAML::SectionOrType &Member : *Section.Members) { in writeSectionContent()
1366 const ELFYAML::SymverSection &Section, in writeSectionContent()
1378 Elf_Shdr &SHeader, const ELFYAML::StackSizesSection &Section, in writeSectionContent()
1386 for (const ELFYAML::StackSizeEntry &E : *Section.Entries) { in writeSectionContent()
1394 Elf_Shdr &SHeader, const ELFYAML::BBAddrMapSection &Section, in writeSectionContent()
1399 for (const ELFYAML::BBAddrMapEntry &E : *Section.Entries) { in writeSectionContent()
1410 for (const ELFYAML::BBAddrMapEntry::BBEntry &BBE : *E.BBEntries) in writeSectionContent()
1419 Elf_Shdr &SHeader, const ELFYAML::LinkerOptionsSection &Section, in writeSectionContent()
1424 for (const ELFYAML::LinkerOption &LO : *Section.Options) { in writeSectionContent()
1435 Elf_Shdr &SHeader, const ELFYAML::DependentLibrariesSection &Section, in writeSectionContent()
1473 Elf_Shdr &SHeader, const ELFYAML::CallGraphProfileSection &Section, in writeSectionContent()
1478 for (const ELFYAML::CallGraphEntryWeight &E : *Section.Entries) { in writeSectionContent()
1486 const ELFYAML::HashSection &Section, in writeSectionContent()
1511 const ELFYAML::VerdefSection &Section, in writeSectionContent()
1524 const ELFYAML::VerdefEntry &E = (*Section.Entries)[I]; in writeSectionContent()
1557 const ELFYAML::VerneedSection &Section, in writeSectionContent()
1569 const ELFYAML::VerneedEntry &VE = (*Section.VerneedV)[I]; in writeSectionContent()
1584 const ELFYAML::VernauxEntry &VAuxE = VE.AuxV[J]; in writeSectionContent()
1605 Elf_Shdr &SHeader, const ELFYAML::ARMIndexTableSection &Section, in writeSectionContent()
1610 for (const ELFYAML::ARMIndexTableEntry &E : *Section.Entries) { in writeSectionContent()
1619 const ELFYAML::MipsABIFlags &Section, in writeSectionContent()
1644 const ELFYAML::DynamicSection &Section, in writeSectionContent()
1652 for (const ELFYAML::DynamicEntry &DE : *Section.Entries) { in writeSectionContent()
1661 const ELFYAML::AddrsigSection &Section, in writeSectionContent()
1676 const ELFYAML::NoteSection &Section, in writeSectionContent()
1682 for (const ELFYAML::NoteEntry &NE : *Section.Notes) { in writeSectionContent()
1717 const ELFYAML::GnuHashSection &Section, in writeSectionContent()
1767 void ELFState<ELFT>::writeFill(ELFYAML::Fill &Fill, in writeFill()
1784 const ELFYAML::SectionHeaderTable &SectionHeaders = in buildSectionHeaderReorderMap()
1794 auto AddSection = [&](const ELFYAML::SectionHeader &Hdr) { in buildSectionHeaderReorderMap()
1802 for (const ELFYAML::SectionHeader &Hdr : *SectionHeaders.Sections) in buildSectionHeaderReorderMap()
1806 for (const ELFYAML::SectionHeader &Hdr : *SectionHeaders.Excluded) in buildSectionHeaderReorderMap()
1809 for (const ELFYAML::Section *S : Doc.getSections()) { in buildSectionHeaderReorderMap()
1834 std::vector<ELFYAML::Section *> Sections = Doc.getSections(); in buildSectionIndex()
1835 const ELFYAML::SectionHeaderTable &SectionHeaders = in buildSectionIndex()
1838 for (const ELFYAML::SectionHeader &Hdr : *SectionHeaders.Excluded) in buildSectionIndex()
1843 for (const ELFYAML::Section *S : Sections) in buildSectionIndex()
1848 for (const ELFYAML::Section *S : Sections) { in buildSectionIndex()
1856 ShStrtabStrings->add(ELFYAML::dropUniqueSuffix(S->Name)); in buildSectionIndex()
1861 auto Build = [this](ArrayRef<ELFYAML::Symbol> V, NameToIdxMap &Map) { in buildSymbolIndexes()
1863 const ELFYAML::Symbol &Sym = V[I]; in buildSymbolIndexes()
1878 for (const ELFYAML::Symbol &Sym : *Doc.Symbols) in finalizeStrings()
1879 DotStrtab.add(ELFYAML::dropUniqueSuffix(Sym.Name)); in finalizeStrings()
1884 for (const ELFYAML::Symbol &Sym : *Doc.DynamicSymbols) in finalizeStrings()
1885 DotDynstr.add(ELFYAML::dropUniqueSuffix(Sym.Name)); in finalizeStrings()
1889 for (const ELFYAML::Chunk *Sec : Doc.getSections()) { in finalizeStrings()
1890 if (auto VerNeed = dyn_cast<ELFYAML::VerneedSection>(Sec)) { in finalizeStrings()
1892 for (const ELFYAML::VerneedEntry &VE : *VerNeed->VerneedV) { in finalizeStrings()
1894 for (const ELFYAML::VernauxEntry &Aux : VE.AuxV) in finalizeStrings()
1898 } else if (auto VerDef = dyn_cast<ELFYAML::VerdefSection>(Sec)) { in finalizeStrings()
1900 for (const ELFYAML::VerdefEntry &E : *VerDef->Entries) in finalizeStrings()
1915 bool ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc, in writeELF()
1971 const ELFYAML::SectionHeaderTable &SHT = Doc.getSectionHeaderTable(); in writeELF()
1983 bool yaml2elf(llvm::ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, in yaml2elf()
1985 bool IsLE = Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB); in yaml2elf()
1986 bool Is64Bit = Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64); in yaml2elf()