Lines Matching refs:Sec
52 void SectionBase::removeSectionReferences(const SectionBase *Sec) {} in removeSectionReferences() argument
58 template <class ELFT> void ELFWriter<ELFT>::writeShdr(const SectionBase &Sec) { in writeShdr() argument
60 B += Sec.HeaderOffset; in writeShdr()
62 Shdr.sh_name = Sec.NameIndex; in writeShdr()
63 Shdr.sh_type = Sec.Type; in writeShdr()
64 Shdr.sh_flags = Sec.Flags; in writeShdr()
65 Shdr.sh_addr = Sec.Addr; in writeShdr()
66 Shdr.sh_offset = Sec.Offset; in writeShdr()
67 Shdr.sh_size = Sec.Size; in writeShdr()
68 Shdr.sh_link = Sec.Link; in writeShdr()
69 Shdr.sh_info = Sec.Info; in writeShdr()
70 Shdr.sh_addralign = Sec.Align; in writeShdr()
71 Shdr.sh_entsize = Sec.EntrySize; in writeShdr()
74 template <class ELFT> void ELFSectionSizer<ELFT>::visit(Section &Sec) {} in visit() argument
77 void ELFSectionSizer<ELFT>::visit(OwnedDataSection &Sec) {} in visit() argument
80 void ELFSectionSizer<ELFT>::visit(StringTableSection &Sec) {} in visit() argument
83 void ELFSectionSizer<ELFT>::visit(DynamicRelocationSection &Sec) {} in visit() argument
86 void ELFSectionSizer<ELFT>::visit(SymbolTableSection &Sec) { in visit() argument
87 Sec.EntrySize = sizeof(Elf_Sym); in visit()
88 Sec.Size = Sec.Symbols.size() * Sec.EntrySize; in visit()
90 Sec.Align = ELFT::Is64Bits ? sizeof(Elf_Xword) : sizeof(Elf_Word); in visit()
94 void ELFSectionSizer<ELFT>::visit(RelocationSection &Sec) { in visit() argument
95 Sec.EntrySize = Sec.Type == SHT_REL ? sizeof(Elf_Rel) : sizeof(Elf_Rela); in visit()
96 Sec.Size = Sec.Relocations.size() * Sec.EntrySize; in visit()
98 Sec.Align = ELFT::Is64Bits ? sizeof(Elf_Xword) : sizeof(Elf_Word); in visit()
102 void ELFSectionSizer<ELFT>::visit(GnuDebugLinkSection &Sec) {} in visit() argument
104 template <class ELFT> void ELFSectionSizer<ELFT>::visit(GroupSection &Sec) {} in visit() argument
107 void ELFSectionSizer<ELFT>::visit(SectionIndexSection &Sec) {} in visit() argument
110 void ELFSectionSizer<ELFT>::visit(CompressedSection &Sec) {} in visit() argument
113 void ELFSectionSizer<ELFT>::visit(DecompressedSection &Sec) {} in visit() argument
115 void BinarySectionWriter::visit(const SectionIndexSection &Sec) { in visit() argument
116 error("Cannot write symbol section index table '" + Sec.Name + "' "); in visit()
119 void BinarySectionWriter::visit(const SymbolTableSection &Sec) { in visit() argument
120 error("Cannot write symbol table '" + Sec.Name + "' out to binary"); in visit()
123 void BinarySectionWriter::visit(const RelocationSection &Sec) { in visit() argument
124 error("Cannot write relocation section '" + Sec.Name + "' out to binary"); in visit()
127 void BinarySectionWriter::visit(const GnuDebugLinkSection &Sec) { in visit() argument
128 error("Cannot write '" + Sec.Name + "' out to binary"); in visit()
131 void BinarySectionWriter::visit(const GroupSection &Sec) { in visit() argument
132 error("Cannot write '" + Sec.Name + "' out to binary"); in visit()
135 void SectionWriter::visit(const Section &Sec) { in visit() argument
136 if (Sec.Type == SHT_NOBITS) in visit()
138 uint8_t *Buf = Out.getBufferStart() + Sec.Offset; in visit()
139 llvm::copy(Sec.Contents, Buf); in visit()
146 void SectionWriter::visit(const OwnedDataSection &Sec) { in visit() argument
147 uint8_t *Buf = Out.getBufferStart() + Sec.Offset; in visit()
148 llvm::copy(Sec.Data, Buf); in visit()
176 void ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) { in visit() argument
177 uint8_t *Buf = Out.getBufferStart() + Sec.Offset; in visit()
180 std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf); in visit()
184 const size_t DataOffset = isDataGnuCompressed(Sec.OriginalData) in visit()
185 ? (ZlibGnuMagic.size() + sizeof(Sec.Size)) in visit()
189 reinterpret_cast<const char *>(Sec.OriginalData.data()) + DataOffset, in visit()
190 Sec.OriginalData.size() - DataOffset); in visit()
194 static_cast<size_t>(Sec.Size))) in visit()
195 reportError(Sec.Name, std::move(E)); in visit()
200 void BinarySectionWriter::visit(const DecompressedSection &Sec) { in visit() argument
201 error("Cannot write compressed section '" + Sec.Name + "' "); in visit()
220 void BinarySectionWriter::visit(const CompressedSection &Sec) { in visit() argument
221 error("Cannot write compressed section '" + Sec.Name + "' "); in visit()
225 void ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) { in visit() argument
227 Buf += Sec.Offset; in visit()
229 if (Sec.CompressionType == DebugCompressionType::None) { in visit()
230 std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf); in visit()
234 if (Sec.CompressionType == DebugCompressionType::GNU) { in visit()
239 support::endian::read64be(&Sec.DecompressedSize); in visit()
245 Chdr.ch_size = Sec.DecompressedSize; in visit()
246 Chdr.ch_addralign = Sec.DecompressedAlign; in visit()
251 std::copy(Sec.CompressedData.begin(), Sec.CompressedData.end(), Buf); in visit()
254 CompressedSection::CompressedSection(const SectionBase &Sec, in CompressedSection() argument
256 : SectionBase(Sec), CompressionType(CompressionType), in CompressedSection()
257 DecompressedSize(Sec.OriginalData.size()), DecompressedAlign(Sec.Align) { in CompressedSection()
272 Name = ".z" + Sec.Name.substr(1); in CompressedSection()
313 void SectionWriter::visit(const StringTableSection &Sec) { in visit() argument
314 Sec.StrTabBuilder.write(Out.getBufferStart() + Sec.Offset); in visit()
326 void ELFSectionWriter<ELFT>::visit(const SectionIndexSection &Sec) { in visit() argument
327 uint8_t *Buf = Out.getBufferStart() + Sec.Offset; in visit()
329 llvm::copy(Sec.Indexes, IndexesBuffer); in visit()
429 void SymbolTableSection::removeSectionReferences(const SectionBase *Sec) { in removeSectionReferences() argument
430 if (SectionIndexTable == Sec) in removeSectionReferences()
432 if (SymbolNames == Sec) { in removeSectionReferences()
437 removeSymbols([Sec](const Symbol &Sym) { return Sym.DefinedIn == Sec; }); in removeSectionReferences()
513 void ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) { in visit() argument
515 Buf += Sec.Offset; in visit()
518 for (auto &Symbol : Sec.Symbols) { in visit()
540 const SectionBase *Sec) { in removeSectionReferences() argument
541 if (Symbols == Sec) { in removeSectionReferences()
596 void ELFSectionWriter<ELFT>::visit(const RelocationSection &Sec) { in visit() argument
597 uint8_t *Buf = Out.getBufferStart() + Sec.Offset; in visit()
598 if (Sec.Type == SHT_REL) in visit()
599 writeRel(Sec.Relocations, reinterpret_cast<Elf_Rel *>(Buf)); in visit()
601 writeRel(Sec.Relocations, reinterpret_cast<Elf_Rela *>(Buf)); in visit()
625 void SectionWriter::visit(const DynamicRelocationSection &Sec) { in visit() argument
626 llvm::copy(Sec.Contents, in visit()
627 Out.getBufferStart() + Sec.Offset); in visit()
638 void Section::removeSectionReferences(const SectionBase *Sec) { in removeSectionReferences() argument
639 if (LinkSection == Sec) { in removeSectionReferences()
711 void ELFSectionWriter<ELFT>::visit(const GnuDebugLinkSection &Sec) { in visit() argument
712 auto Buf = Out.getBufferStart() + Sec.Offset; in visit()
715 reinterpret_cast<Elf_Word *>(Buf + Sec.Size - sizeof(Elf_Word)); in visit()
716 *CRC = Sec.CRC32; in visit()
717 llvm::copy(Sec.FileName, File); in visit()
729 void ELFSectionWriter<ELFT>::visit(const GroupSection &Sec) { in visit() argument
731 reinterpret_cast<ELF::Elf32_Word *>(Out.getBufferStart() + Sec.Offset); in visit()
732 *Buf++ = Sec.FlagWord; in visit()
733 for (const auto *S : Sec.GroupMembers) in visit()
1034 if (T *Sec = dyn_cast<T>(getSection(Index, IndexErrMsg))) in getSectionOfType() local
1035 return Sec; in getSectionOfType()
1109 auto &Sec = makeSection(Shdr); in readSectionHeaders() local
1110 Sec.Name = unwrapOrError(ElfFile.getSectionName(&Shdr)); in readSectionHeaders()
1111 Sec.Type = Shdr.sh_type; in readSectionHeaders()
1112 Sec.Flags = Shdr.sh_flags; in readSectionHeaders()
1113 Sec.Addr = Shdr.sh_addr; in readSectionHeaders()
1114 Sec.Offset = Shdr.sh_offset; in readSectionHeaders()
1115 Sec.OriginalOffset = Shdr.sh_offset; in readSectionHeaders()
1116 Sec.Size = Shdr.sh_size; in readSectionHeaders()
1117 Sec.Link = Shdr.sh_link; in readSectionHeaders()
1118 Sec.Info = Shdr.sh_info; in readSectionHeaders()
1119 Sec.Align = Shdr.sh_addralign; in readSectionHeaders()
1120 Sec.EntrySize = Shdr.sh_entsize; in readSectionHeaders()
1121 Sec.Index = Index++; in readSectionHeaders()
1122 Sec.OriginalData = in readSectionHeaders()
1312 for (auto &Sec : Obj.sections()) in writeShdrs() local
1313 writeShdr(Sec); in writeShdrs()
1317 for (auto &Sec : Obj.sections()) in writeSectionData() local
1318 Sec.accept(*SecWriter); in writeSectionData()
1324 std::begin(Sections), std::end(Sections), [=](const SecPtr &Sec) { in removeSections() argument
1325 if (ToRemove(*Sec)) in removeSections()
1327 if (auto RelSec = dyn_cast<RelocationSectionBase>(Sec.get())) { in removeSections()
1356 for (const SecPtr &Sec : Sections) in removeSymbols() local
1357 Sec->removeSymbols(ToRemove); in removeSymbols()
1520 [](const SectionBase &Sec) { return Sec.HasSymbol; }); in finalize() argument
1539 Obj.removeSections([this](const SectionBase &Sec) { in finalize() argument
1540 return &Sec == Obj.SectionIndexTable; in finalize()
1559 for (auto &Sec : Obj.sections()) { in finalize() local
1560 Sec.Index = Index++; in finalize()
1561 Sec.accept(*SecSizer); in finalize()
1642 auto Sec = Seg->firstSection(); in finalize() local
1643 auto Diff = Sec->OriginalOffset - Seg->OriginalOffset; in finalize()