9#ifndef LLVM_LIB_OBJCOPY_COFF_COFFOBJECT_H
10#define LLVM_LIB_OBJCOPY_COFF_COFFOBJECT_H
43 if (!OwnedContents.empty())
49 OwnedContents.clear();
55 OwnedContents = std::move(
Data);
56 Header.SizeOfRawData = OwnedContents.size();
61 OwnedContents.clear();
66 std::vector<uint8_t> OwnedContents;
72 std::copy(In.begin(), In.end(),
Opaque);
114 return make_range(Symbols.begin(), Symbols.end());
130 return make_range(Sections.begin(), Sections.end());
140 std::vector<Symbol> Symbols;
143 size_t NextSymbolUniqueId = 0;
144 size_t NextSymbolOriginalIndex = 0;
146 std::vector<Section> Sections;
149 ssize_t NextSectionUniqueId = 1;
152 void updateSymbols();
155 void updateSections();
162template <
class Symbol1Ty,
class Symbol2Ty>
164 static_assert(
sizeof(Dest.Name.ShortName) ==
sizeof(Src.Name.ShortName),
165 "Mismatched name sizes");
166 memcpy(Dest.Name.ShortName, Src.Name.ShortName,
sizeof(Dest.Name.ShortName));
167 Dest.Value = Src.Value;
168 Dest.SectionNumber = Src.SectionNumber;
169 Dest.Type = Src.Type;
170 Dest.StorageClass = Src.StorageClass;
171 Dest.NumberOfAuxSymbols = Src.NumberOfAuxSymbols;
176template <
class PeHeader1Ty,
class PeHeader2Ty>
178 Dest.Magic = Src.Magic;
179 Dest.MajorLinkerVersion = Src.MajorLinkerVersion;
180 Dest.MinorLinkerVersion = Src.MinorLinkerVersion;
181 Dest.SizeOfCode = Src.SizeOfCode;
182 Dest.SizeOfInitializedData = Src.SizeOfInitializedData;
183 Dest.SizeOfUninitializedData = Src.SizeOfUninitializedData;
184 Dest.AddressOfEntryPoint = Src.AddressOfEntryPoint;
185 Dest.BaseOfCode = Src.BaseOfCode;
186 Dest.ImageBase = Src.ImageBase;
187 Dest.SectionAlignment = Src.SectionAlignment;
188 Dest.FileAlignment = Src.FileAlignment;
189 Dest.MajorOperatingSystemVersion = Src.MajorOperatingSystemVersion;
190 Dest.MinorOperatingSystemVersion = Src.MinorOperatingSystemVersion;
191 Dest.MajorImageVersion = Src.MajorImageVersion;
192 Dest.MinorImageVersion = Src.MinorImageVersion;
193 Dest.MajorSubsystemVersion = Src.MajorSubsystemVersion;
194 Dest.MinorSubsystemVersion = Src.MinorSubsystemVersion;
195 Dest.Win32VersionValue = Src.Win32VersionValue;
196 Dest.SizeOfImage = Src.SizeOfImage;
197 Dest.SizeOfHeaders = Src.SizeOfHeaders;
198 Dest.CheckSum = Src.CheckSum;
199 Dest.Subsystem = Src.Subsystem;
200 Dest.DLLCharacteristics = Src.DLLCharacteristics;
201 Dest.SizeOfStackReserve = Src.SizeOfStackReserve;
202 Dest.SizeOfStackCommit = Src.SizeOfStackCommit;
203 Dest.SizeOfHeapReserve = Src.SizeOfHeapReserve;
204 Dest.SizeOfHeapCommit = Src.SizeOfHeapCommit;
205 Dest.LoaderFlags = Src.LoaderFlags;
206 Dest.NumberOfRvaAndSize = Src.NumberOfRvaAndSize;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ReachingDefAnalysis InstSet & ToRemove
This file defines the DenseMap class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
void copySymbol(Symbol1Ty &Dest, const Symbol2Ty &Src)
void copyPeHeader(PeHeader1Ty &Dest, const PeHeader2Ty &Src)
coff_symbol< support::ulittle16_t > coff_symbol16
coff_symbol< support::ulittle32_t > coff_symbol32
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
AuxSymbol(ArrayRef< uint8_t > In)
uint8_t Opaque[sizeof(object::coff_symbol16)]
ArrayRef< uint8_t > getRef() const
ArrayRef< Symbol > getSymbols() const
ArrayRef< uint8_t > DosStub
iterator_range< std::vector< Symbol >::iterator > getMutableSymbols()
object::coff_file_header CoffFileHeader
void truncateSections(function_ref< bool(const Section &)> ToTruncate)
const Symbol * findSymbol(size_t UniqueId) const
std::vector< object::data_directory > DataDirectories
const Section * findSection(ssize_t UniqueId) const
void addSections(ArrayRef< Section > NewSections)
object::pe32plus_header PeHeader
void removeSections(function_ref< bool(const Section &)> ToRemove)
iterator_range< std::vector< Section >::iterator > getMutableSections()
object::dos_header DosHeader
ArrayRef< Section > getSections() const
void addSymbols(ArrayRef< Symbol > NewSymbols)
Error removeSymbols(function_ref< Expected< bool >(const Symbol &)> ToRemove)
object::coff_relocation Reloc
Relocation(const object::coff_relocation &R)
void setOwnedContents(std::vector< uint8_t > &&Data)
object::coff_section Header
std::vector< Relocation > Relocs
void setContentsRef(ArrayRef< uint8_t > Data)
ArrayRef< uint8_t > getContents() const
object::coff_symbol32 Sym
std::optional< size_t > WeakTargetSymbolId
ssize_t AssociativeComdatTargetSectionId
std::vector< AuxSymbol > AuxData