Lines Matching refs:Obj
39 Obj.ProgramHdrSegment.Offset + Seg.Index * sizeof(Elf_Phdr); in writePhdr()
1241 Obj->Flags = 0x0; in initFileHeader()
1242 Obj->Type = ET_REL; in initFileHeader()
1243 Obj->OSABI = ELFOSABI_NONE; in initFileHeader()
1244 Obj->ABIVersion = 0; in initFileHeader()
1245 Obj->Entry = 0x0; in initFileHeader()
1246 Obj->Machine = EM_NONE; in initFileHeader()
1247 Obj->Version = 1; in initFileHeader()
1250 void BasicELFBuilder::initHeaderSegment() { Obj->ElfHdrSegment.Index = 0; } in initHeaderSegment()
1253 auto &StrTab = Obj->addSection<StringTableSection>(); in addStrTab()
1256 Obj->SectionNames = &StrTab; in addStrTab()
1261 auto &SymTab = Obj->addSection<SymbolTableSection>(); in addSymTab()
1269 Obj->SymbolTable = &SymTab; in addSymTab()
1274 for (SectionBase &Sec : Obj->sections()) in initSections()
1275 if (Error Err = Sec.initialize(Obj->sections())) in initSections()
1285 auto &DataSection = Obj->addSection<Section>(Data); in addData()
1315 return std::move(Obj); in build()
1338 Section = &Obj->addSection<OwnedDataSection>( in addDataSections()
1353 Obj->Entry = checkedGetHex<uint32_t>(R.HexData); in addDataSections()
1354 assert(Obj->Entry <= 0xFFFFFU); in addDataSections()
1375 return std::move(Obj); in build()
1379 ELFBuilder<ELFT>::ELFBuilder(const ELFObjectFile<ELFT> &ElfObj, Object &Obj, in ELFBuilder() argument
1381 : ElfFile(ElfObj.getELFFile()), Obj(Obj), in ELFBuilder()
1383 Obj.IsMips64EL = ElfFile.isMips64EL(); in ELFBuilder()
1387 for (Segment &Parent : Obj.segments()) { in setParentSegment()
1406 for (const SectionBase &Sec : Obj.sections()) { in findEhdrOffset()
1436 Segment &Seg = Obj.addSegment(Data); in readProgramHeaders()
1447 for (SectionBase &Sec : Obj.sections()) in readProgramHeaders()
1455 auto &ElfHdr = Obj.ElfHdrSegment; in readProgramHeaders()
1460 auto &PrHdr = Obj.ProgramHdrSegment; in readProgramHeaders()
1476 for (Segment &Child : Obj.segments()) in readProgramHeaders()
1490 SectionTableRef SecTable = Obj.sections(); in initGroupSection()
1584 Expected<SectionBase *> Sec = Obj.sections().getSection( in initSymbolTable()
1592 if (!isValidReservedSectionIndex(Sym.st_shndx, Obj.Machine)) { in initSymbolTable()
1601 Expected<SectionBase *> Sec = Obj.sections().getSection( in initSymbolTable()
1682 return Obj.addSection<DynamicRelocationSection>(*Data); in makeSection()
1686 return Obj.addSection<RelocationSection>(Obj); in makeSection()
1693 return Obj.addSection<Section>(*Data); in makeSection()
1697 return Obj.addSection<StringTableSection>(); in makeSection()
1703 return Obj.addSection<Section>(*Data); in makeSection()
1708 return Obj.addSection<GroupSection>(*Data); in makeSection()
1713 return Obj.addSection<DynamicSymbolTableSection>(*Data); in makeSection()
1718 return Obj.addSection<DynamicSection>(*Data); in makeSection()
1723 if (Obj.SymbolTable != nullptr) in makeSection()
1726 auto &SymTab = Obj.addSection<SymbolTableSection>(); in makeSection()
1727 Obj.SymbolTable = &SymTab; in makeSection()
1731 auto &ShndxSection = Obj.addSection<SectionIndexSection>(); in makeSection()
1732 Obj.SectionIndexTable = &ShndxSection; in makeSection()
1736 return Obj.addSection<Section>(ArrayRef<uint8_t>()); in makeSection()
1747 return Obj.addSection<Section>(*Data); in makeSection()
1749 return Obj.addSection<CompressedSection>(CompressedSection( in makeSection()
1806 Obj.HadShdrs = false; in readSections()
1809 Obj.sections().template getSectionOfType<StringTableSection>( in readSections()
1818 Obj.SectionNames = *Sec; in readSections()
1824 if (Obj.SectionIndexTable) in readSections()
1825 if (Error Err = Obj.SectionIndexTable->initialize(Obj.sections())) in readSections()
1831 if (Obj.SymbolTable) { in readSections()
1832 if (Error Err = Obj.SymbolTable->initialize(Obj.sections())) in readSections()
1834 if (Error Err = initSymbolTable(Obj.SymbolTable)) in readSections()
1837 if (Error Err = Obj.addNewSymbolTable()) in readSections()
1844 for (SectionBase &Sec : Obj.sections()) { in readSections()
1845 if (&Sec == Obj.SymbolTable) in readSections()
1847 if (Error Err = Sec.initialize(Obj.sections())) in readSections()
1898 Obj.Is64Bits = Ehdr.e_ident[EI_CLASS] == ELFCLASS64; in build()
1899 Obj.OSABI = Ehdr.e_ident[EI_OSABI]; in build()
1900 Obj.ABIVersion = Ehdr.e_ident[EI_ABIVERSION]; in build()
1901 Obj.Type = Ehdr.e_type; in build()
1902 Obj.Machine = Ehdr.e_machine; in build()
1903 Obj.Version = Ehdr.e_version; in build()
1904 Obj.Entry = Ehdr.e_entry; in build()
1905 Obj.Flags = Ehdr.e_flags; in build()
1957 auto Obj = std::make_unique<Object>(); in create() local
1959 ELFBuilder<ELF32LE> Builder(*O, *Obj, ExtractPartition); in create()
1962 return std::move(Obj); in create()
1964 ELFBuilder<ELF64LE> Builder(*O, *Obj, ExtractPartition); in create()
1967 return std::move(Obj); in create()
1969 ELFBuilder<ELF32BE> Builder(*O, *Obj, ExtractPartition); in create()
1972 return std::move(Obj); in create()
1974 ELFBuilder<ELF64BE> Builder(*O, *Obj, ExtractPartition); in create()
1977 return std::move(Obj); in create()
1994 Ehdr.e_ident[EI_OSABI] = Obj.OSABI; in writeEhdr()
1995 Ehdr.e_ident[EI_ABIVERSION] = Obj.ABIVersion; in writeEhdr()
1997 Ehdr.e_type = Obj.Type; in writeEhdr()
1998 Ehdr.e_machine = Obj.Machine; in writeEhdr()
1999 Ehdr.e_version = Obj.Version; in writeEhdr()
2000 Ehdr.e_entry = Obj.Entry; in writeEhdr()
2003 Ehdr.e_phnum = llvm::size(Obj.segments()); in writeEhdr()
2004 Ehdr.e_phoff = (Ehdr.e_phnum != 0) ? Obj.ProgramHdrSegment.Offset : 0; in writeEhdr()
2006 Ehdr.e_flags = Obj.Flags; in writeEhdr()
2008 if (WriteSectionHeaders && Obj.sections().size() != 0) { in writeEhdr()
2010 Ehdr.e_shoff = Obj.SHOff; in writeEhdr()
2017 auto Shnum = Obj.sections().size() + 1; in writeEhdr()
2028 if (Obj.SectionNames->Index >= SHN_LORESERVE) in writeEhdr()
2031 Ehdr.e_shstrndx = Obj.SectionNames->Index; in writeEhdr()
2041 for (auto &Seg : Obj.segments()) in writePhdrs()
2049 *reinterpret_cast<Elf_Shdr *>(Buf->getBufferStart() + Obj.SHOff); in writeShdrs()
2056 uint64_t Shnum = Obj.sections().size() + 1; in writeShdrs()
2062 if (Obj.SectionNames != nullptr && Obj.SectionNames->Index >= SHN_LORESERVE) in writeShdrs()
2063 Shdr.sh_link = Obj.SectionNames->Index; in writeShdrs()
2070 for (SectionBase &Sec : Obj.sections()) in writeShdrs()
2075 for (SectionBase &Sec : Obj.sections()) in writeSectionData()
2087 for (Segment &Seg : Obj.segments()) { in writeSegmentData()
2093 for (const auto &it : Obj.getUpdatedSections()) { in writeSegmentData()
2105 for (auto &Sec : Obj.removedSections()) { in writeSegmentData()
2116 ELFWriter<ELFT>::ELFWriter(Object &Obj, raw_ostream &Buf, bool WSH, in ELFWriter() argument
2118 : Writer(Obj, Buf), WriteSectionHeaders(WSH && Obj.HadShdrs), in ELFWriter()
2343 static uint64_t layoutSectionsForOnlyKeepDebug(Object &Obj, uint64_t Off) { in layoutSectionsForOnlyKeepDebug() argument
2347 Sections.reserve(Obj.sections().size()); in layoutSectionsForOnlyKeepDebug()
2349 for (auto &Sec : Obj.sections()) { in layoutSectionsForOnlyKeepDebug()
2433 Segment &ElfHdr = Obj.ElfHdrSegment; in initEhdrSegment()
2447 for (Segment &Segment : Obj.segments()) in assignOffsets()
2449 OrderedSegments.push_back(&Obj.ElfHdrSegment); in assignOffsets()
2450 OrderedSegments.push_back(&Obj.ProgramHdrSegment); in assignOffsets()
2459 sizeof(Elf_Ehdr) + llvm::size(Obj.segments()) * sizeof(Elf_Phdr); in assignOffsets()
2460 Offset = layoutSectionsForOnlyKeepDebug(Obj, HdrEnd); in assignOffsets()
2468 Offset = layoutSections(Obj.sections(), Offset); in assignOffsets()
2474 Obj.SHOff = Offset; in assignOffsets()
2481 return Obj.SHOff; in totalSize()
2482 size_t ShdrCount = Obj.sections().size() + 1; // Includes null shdr. in totalSize()
2483 return Obj.SHOff + ShdrCount * sizeof(Elf_Shdr); in totalSize()
2503 static Error removeUnneededSections(Object &Obj) { in removeUnneededSections() argument
2508 if (Obj.isRelocatable() || Obj.SymbolTable == nullptr || in removeUnneededSections()
2509 !Obj.SymbolTable->empty()) in removeUnneededSections()
2514 auto *StrTab = Obj.SymbolTable->getStrTab() == Obj.SectionNames in removeUnneededSections()
2516 : Obj.SymbolTable->getStrTab(); in removeUnneededSections()
2517 return Obj.removeSections(false, [&](const SectionBase &Sec) { in removeUnneededSections()
2518 return &Sec == Obj.SymbolTable || &Sec == StrTab; in removeUnneededSections()
2526 if (Obj.SectionNames == nullptr && WriteSectionHeaders) in finalize()
2531 if (Error E = removeUnneededSections(Obj)) in finalize()
2536 if (Obj.SymbolTable && !Obj.SymbolTable->indicesChanged()) in finalize()
2537 for (SectionBase &Sec : Obj.sections()) in finalize()
2538 Sec.restoreSymTabLink(*Obj.SymbolTable); in finalize()
2544 if (Obj.sections().size() >= SHN_LORESERVE) { in finalize()
2545 SectionTableRef Sections = Obj.sections(); in finalize()
2558 if (Obj.SymbolTable != nullptr && Obj.SectionIndexTable == nullptr) { in finalize()
2561 auto &Shndx = Obj.addSection<SectionIndexSection>(); in finalize()
2562 Obj.SymbolTable->setShndxTable(&Shndx); in finalize()
2563 Shndx.setSymTab(Obj.SymbolTable); in finalize()
2568 if (Obj.SectionIndexTable != nullptr) { in finalize()
2570 if (Error E = Obj.removeSections(false /*AllowBrokenLinks*/, in finalize()
2572 return &Sec == Obj.SectionIndexTable; in finalize()
2580 if (Obj.SectionNames != nullptr) in finalize()
2581 for (const SectionBase &Sec : Obj.sections()) in finalize()
2582 Obj.SectionNames->addString(Sec.Name); in finalize()
2591 for (SectionBase &Sec : Obj.sections()) { in finalize()
2600 if (Obj.SymbolTable != nullptr) in finalize()
2601 Obj.SymbolTable->prepareForLayout(); in finalize()
2605 for (SectionBase &Sec : Obj.sections()) in finalize()
2613 if (Obj.SymbolTable != nullptr) in finalize()
2614 Obj.SymbolTable->fillShndxTable(); in finalize()
2618 uint64_t Offset = Obj.SHOff + sizeof(Elf_Shdr); in finalize()
2619 for (SectionBase &Sec : Obj.sections()) { in finalize()
2623 Sec.NameIndex = Obj.SectionNames->findIndex(Sec.Name); in finalize()
2640 for (const SectionBase &Sec : Obj.allocSections()) { in write()
2682 for (SectionBase &Sec : Obj.allocSections()) { in finalize()
2695 for (SectionBase &Sec : Obj.allocSections()) in finalize()
2720 if (Obj.Entry == 0) in writeEntryPointRecord()
2723 if (Obj.Entry <= 0xFFFFFU) { in writeEntryPointRecord()
2724 Data[0] = ((Obj.Entry & 0xF0000U) >> 12) & 0xFF; in writeEntryPointRecord()
2725 support::endian::write(&Data[2], static_cast<uint16_t>(Obj.Entry), in writeEntryPointRecord()
2729 support::endian::write(Data, static_cast<uint32_t>(Obj.Entry), in writeEntryPointRecord()
2777 if (addressOverflows32bit(Obj.Entry)) in finalize()
2780 Obj.Entry); in finalize()
2782 for (const SectionBase &Sec : Obj.sections()) in finalize()
2804 (Obj.Entry ? IHexRecord::getLineLength(4) : 0) + in finalize()