Lines Matching refs:Obj
39 Obj.ProgramHdrSegment.Offset + Seg.Index * sizeof(Elf_Phdr); in writePhdr()
1253 Obj->Flags = 0x0; in initFileHeader()
1254 Obj->Type = ET_REL; in initFileHeader()
1255 Obj->OSABI = ELFOSABI_NONE; in initFileHeader()
1256 Obj->ABIVersion = 0; in initFileHeader()
1257 Obj->Entry = 0x0; in initFileHeader()
1258 Obj->Machine = EM_NONE; in initFileHeader()
1259 Obj->Version = 1; in initFileHeader()
1262 void BasicELFBuilder::initHeaderSegment() { Obj->ElfHdrSegment.Index = 0; } in initHeaderSegment()
1265 auto &StrTab = Obj->addSection<StringTableSection>(); in addStrTab()
1268 Obj->SectionNames = &StrTab; in addStrTab()
1273 auto &SymTab = Obj->addSection<SymbolTableSection>(); in addSymTab()
1281 Obj->SymbolTable = &SymTab; in addSymTab()
1286 for (SectionBase &Sec : Obj->sections()) in initSections()
1287 if (Error Err = Sec.initialize(Obj->sections())) in initSections()
1297 auto &DataSection = Obj->addSection<Section>(Data); in addData()
1327 return std::move(Obj); in build()
1349 Section = &Obj->addSection<OwnedDataSection>( in addDataSections()
1362 Obj->Entry = checkedGetHex<uint32_t>(R.HexData); in addDataSections()
1363 assert(Obj->Entry <= 0xFFFFFU); in addDataSections()
1384 return std::move(Obj); in build()
1388 for (Segment &Parent : Obj.segments()) { in setParentSegment()
1407 for (const SectionBase &Sec : Obj.sections()) { in findEhdrOffset()
1437 Segment &Seg = Obj.addSegment(Data); in readProgramHeaders()
1448 for (SectionBase &Sec : Obj.sections()) in readProgramHeaders()
1456 auto &ElfHdr = Obj.ElfHdrSegment; in readProgramHeaders()
1461 auto &PrHdr = Obj.ProgramHdrSegment; in readProgramHeaders()
1477 for (Segment &Child : Obj.segments()) in readProgramHeaders()
1491 SectionTableRef SecTable = Obj.sections(); in initGroupSection()
1585 Expected<SectionBase *> Sec = Obj.sections().getSection( in initSymbolTable()
1593 if (!isValidReservedSectionIndex(Sym.st_shndx, Obj.Machine)) { in initSymbolTable()
1602 Expected<SectionBase *> Sec = Obj.sections().getSection( in initSymbolTable()
1683 return Obj.addSection<DynamicRelocationSection>(*Data); in makeSection()
1687 return Obj.addSection<RelocationSection>(); in makeSection()
1694 return Obj.addSection<Section>(*Data); in makeSection()
1698 return Obj.addSection<StringTableSection>(); in makeSection()
1704 return Obj.addSection<Section>(*Data); in makeSection()
1709 return Obj.addSection<GroupSection>(*Data); in makeSection()
1714 return Obj.addSection<DynamicSymbolTableSection>(*Data); in makeSection()
1719 return Obj.addSection<DynamicSection>(*Data); in makeSection()
1723 auto &SymTab = Obj.addSection<SymbolTableSection>(); in makeSection()
1724 Obj.SymbolTable = &SymTab; in makeSection()
1728 auto &ShndxSection = Obj.addSection<SectionIndexSection>(); in makeSection()
1729 Obj.SectionIndexTable = &ShndxSection; in makeSection()
1733 return Obj.addSection<Section>(ArrayRef<uint8_t>()); in makeSection()
1752 return Obj.addSection<CompressedSection>(std::move(*NewSection)); in makeSection()
1755 return Obj.addSection<Section>(*Data); in makeSection()
1811 Obj.HadShdrs = false; in readSections()
1814 Obj.sections().template getSectionOfType<StringTableSection>( in readSections()
1823 Obj.SectionNames = *Sec; in readSections()
1829 if (Obj.SectionIndexTable) in readSections()
1830 if (Error Err = Obj.SectionIndexTable->initialize(Obj.sections())) in readSections()
1836 if (Obj.SymbolTable) { in readSections()
1837 if (Error Err = Obj.SymbolTable->initialize(Obj.sections())) in readSections()
1839 if (Error Err = initSymbolTable(Obj.SymbolTable)) in readSections()
1842 if (Error Err = Obj.addNewSymbolTable()) in readSections()
1849 for (SectionBase &Sec : Obj.sections()) { in readSections()
1850 if (&Sec == Obj.SymbolTable) in readSections()
1852 if (Error Err = Sec.initialize(Obj.sections())) in readSections()
1868 if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Rels)) in readSections()
1876 if (Error Err = initRelocations(RelSec, Obj.SymbolTable, *Relas)) in readSections()
1903 Obj.OSABI = Ehdr.e_ident[EI_OSABI]; in build()
1904 Obj.ABIVersion = Ehdr.e_ident[EI_ABIVERSION]; in build()
1905 Obj.Type = Ehdr.e_type; in build()
1906 Obj.Machine = Ehdr.e_machine; in build()
1907 Obj.Version = Ehdr.e_version; in build()
1908 Obj.Entry = Ehdr.e_entry; in build()
1909 Obj.Flags = Ehdr.e_flags; in build()
1961 auto Obj = std::make_unique<Object>(); in create() local
1963 ELFBuilder<ELF32LE> Builder(*O, *Obj, ExtractPartition); in create()
1966 return std::move(Obj); in create()
1968 ELFBuilder<ELF64LE> Builder(*O, *Obj, ExtractPartition); in create()
1971 return std::move(Obj); in create()
1973 ELFBuilder<ELF32BE> Builder(*O, *Obj, ExtractPartition); in create()
1976 return std::move(Obj); in create()
1978 ELFBuilder<ELF64BE> Builder(*O, *Obj, ExtractPartition); in create()
1981 return std::move(Obj); in create()
1997 Ehdr.e_ident[EI_OSABI] = Obj.OSABI; in writeEhdr()
1998 Ehdr.e_ident[EI_ABIVERSION] = Obj.ABIVersion; in writeEhdr()
2000 Ehdr.e_type = Obj.Type; in writeEhdr()
2001 Ehdr.e_machine = Obj.Machine; in writeEhdr()
2002 Ehdr.e_version = Obj.Version; in writeEhdr()
2003 Ehdr.e_entry = Obj.Entry; in writeEhdr()
2006 Ehdr.e_phnum = llvm::size(Obj.segments()); in writeEhdr()
2007 Ehdr.e_phoff = (Ehdr.e_phnum != 0) ? Obj.ProgramHdrSegment.Offset : 0; in writeEhdr()
2009 Ehdr.e_flags = Obj.Flags; in writeEhdr()
2011 if (WriteSectionHeaders && Obj.sections().size() != 0) { in writeEhdr()
2013 Ehdr.e_shoff = Obj.SHOff; in writeEhdr()
2020 auto Shnum = Obj.sections().size() + 1; in writeEhdr()
2031 if (Obj.SectionNames->Index >= SHN_LORESERVE) in writeEhdr()
2034 Ehdr.e_shstrndx = Obj.SectionNames->Index; in writeEhdr()
2044 for (auto &Seg : Obj.segments()) in writePhdrs()
2052 *reinterpret_cast<Elf_Shdr *>(Buf->getBufferStart() + Obj.SHOff); in writeShdrs()
2059 uint64_t Shnum = Obj.sections().size() + 1; in writeShdrs()
2065 if (Obj.SectionNames != nullptr && Obj.SectionNames->Index >= SHN_LORESERVE) in writeShdrs()
2066 Shdr.sh_link = Obj.SectionNames->Index; in writeShdrs()
2073 for (SectionBase &Sec : Obj.sections()) in writeShdrs()
2078 for (SectionBase &Sec : Obj.sections()) in writeSectionData()
2090 for (Segment &Seg : Obj.segments()) { in writeSegmentData()
2097 for (auto &Sec : Obj.removedSections()) { in writeSegmentData()
2108 ELFWriter<ELFT>::ELFWriter(Object &Obj, raw_ostream &Buf, bool WSH, in ELFWriter() argument
2110 : Writer(Obj, Buf), WriteSectionHeaders(WSH && Obj.HadShdrs), in ELFWriter()
2284 static uint64_t layoutSectionsForOnlyKeepDebug(Object &Obj, uint64_t Off) { in layoutSectionsForOnlyKeepDebug() argument
2286 for (auto &Sec : Obj.sections()) { in layoutSectionsForOnlyKeepDebug()
2363 Segment &ElfHdr = Obj.ElfHdrSegment; in initEhdrSegment()
2377 for (Segment &Segment : Obj.segments()) in assignOffsets()
2379 OrderedSegments.push_back(&Obj.ElfHdrSegment); in assignOffsets()
2380 OrderedSegments.push_back(&Obj.ProgramHdrSegment); in assignOffsets()
2389 sizeof(Elf_Ehdr) + llvm::size(Obj.segments()) * sizeof(Elf_Phdr); in assignOffsets()
2390 Offset = layoutSectionsForOnlyKeepDebug(Obj, HdrEnd); in assignOffsets()
2398 Offset = layoutSections(Obj.sections(), Offset); in assignOffsets()
2404 Obj.SHOff = Offset; in assignOffsets()
2411 return Obj.SHOff; in totalSize()
2412 size_t ShdrCount = Obj.sections().size() + 1; // Includes null shdr. in totalSize()
2413 return Obj.SHOff + ShdrCount * sizeof(Elf_Shdr); in totalSize()
2433 static Error removeUnneededSections(Object &Obj) { in removeUnneededSections() argument
2438 if (Obj.isRelocatable() || Obj.SymbolTable == nullptr || in removeUnneededSections()
2439 !Obj.SymbolTable->empty()) in removeUnneededSections()
2444 auto *StrTab = Obj.SymbolTable->getStrTab() == Obj.SectionNames in removeUnneededSections()
2446 : Obj.SymbolTable->getStrTab(); in removeUnneededSections()
2447 return Obj.removeSections(false, [&](const SectionBase &Sec) { in removeUnneededSections()
2448 return &Sec == Obj.SymbolTable || &Sec == StrTab; in removeUnneededSections()
2456 if (Obj.SectionNames == nullptr && WriteSectionHeaders) in finalize()
2461 if (Error E = removeUnneededSections(Obj)) in finalize()
2463 Obj.sortSections(); in finalize()
2469 if (Obj.sections().size() >= SHN_LORESERVE) { in finalize()
2470 SectionTableRef Sections = Obj.sections(); in finalize()
2483 if (Obj.SymbolTable != nullptr && Obj.SectionIndexTable == nullptr) { in finalize()
2486 auto &Shndx = Obj.addSection<SectionIndexSection>(); in finalize()
2487 Obj.SymbolTable->setShndxTable(&Shndx); in finalize()
2488 Shndx.setSymTab(Obj.SymbolTable); in finalize()
2493 if (Obj.SectionIndexTable != nullptr) { in finalize()
2495 if (Error E = Obj.removeSections(false /*AllowBrokenLinks*/, in finalize()
2497 return &Sec == Obj.SectionIndexTable; in finalize()
2505 if (Obj.SectionNames != nullptr) in finalize()
2506 for (const SectionBase &Sec : Obj.sections()) in finalize()
2507 Obj.SectionNames->addString(Sec.Name); in finalize()
2516 for (SectionBase &Sec : Obj.sections()) { in finalize()
2525 if (Obj.SymbolTable != nullptr) in finalize()
2526 Obj.SymbolTable->prepareForLayout(); in finalize()
2530 for (SectionBase &Sec : Obj.sections()) in finalize()
2538 if (Obj.SymbolTable != nullptr) in finalize()
2539 Obj.SymbolTable->fillShndxTable(); in finalize()
2543 uint64_t Offset = Obj.SHOff + sizeof(Elf_Shdr); in finalize()
2544 for (SectionBase &Sec : Obj.sections()) { in finalize()
2548 Sec.NameIndex = Obj.SectionNames->findIndex(Sec.Name); in finalize()
2564 for (const SectionBase &Sec : Obj.allocSections()) in write()
2580 for (SectionBase &Sec : Obj.allocSections()) { in finalize()
2593 for (SectionBase &Sec : Obj.allocSections()) in finalize()
2618 if (Obj.Entry == 0) in writeEntryPointRecord()
2621 if (Obj.Entry <= 0xFFFFFU) { in writeEntryPointRecord()
2622 Data[0] = ((Obj.Entry & 0xF0000U) >> 12) & 0xFF; in writeEntryPointRecord()
2623 support::endian::write(&Data[2], static_cast<uint16_t>(Obj.Entry), in writeEntryPointRecord()
2627 support::endian::write(Data, static_cast<uint32_t>(Obj.Entry), in writeEntryPointRecord()
2675 if (addressOverflows32bit(Obj.Entry)) in finalize()
2678 Obj.Entry); in finalize()
2680 for (const SectionBase &Sec : Obj.sections()) in finalize()
2702 (Obj.Entry ? IHexRecord::getLineLength(4) : 0) + in finalize()