36#include <system_error>
39using namespace object;
48 if (M.getBufferSize() <
Size) {
49 EC = object_error::unexpected_eof;
60 uintptr_t
Addr =
reinterpret_cast<uintptr_t
>(
Ptr);
63 Obj =
reinterpret_cast<const T *
>(
Addr);
70 assert(Str.size() <= 6 &&
"String too long, possible overflow.");
75 while (!Str.empty()) {
77 if (Str[0] >=
'A' && Str[0] <=
'Z')
78 CharVal = Str[0] -
'A';
79 else if (Str[0] >=
'a' && Str[0] <=
'z')
80 CharVal = Str[0] -
'a' + 26;
81 else if (Str[0] >=
'0' && Str[0] <=
'9')
82 CharVal = Str[0] -
'0' + 52;
83 else if (Str[0] ==
'+')
85 else if (Str[0] ==
'/')
94 if (
Value > std::numeric_limits<uint32_t>::max())
101template <
typename coff_symbol_type>
102const coff_symbol_type *COFFObjectFile::toSymb(
DataRefImpl Ref)
const {
103 const coff_symbol_type *
Addr =
104 reinterpret_cast<const coff_symbol_type *
>(
Ref.p);
110 reinterpret_cast<uintptr_t
>(
Addr) -
reinterpret_cast<uintptr_t
>(
base());
113 "Symbol did not point to the beginning of a symbol");
127 uintptr_t
Offset =
reinterpret_cast<uintptr_t
>(
Addr) -
128 reinterpret_cast<uintptr_t
>(SectionTable);
130 "Section did not point to the beginning of a section");
137 auto End =
reinterpret_cast<uintptr_t
>(StringTable);
141 Ref.p = std::min(
reinterpret_cast<uintptr_t
>(Symb),
End);
142 }
else if (SymbolTable32) {
145 Ref.p = std::min(
reinterpret_cast<uintptr_t
>(Symb),
End);
177 return Section.takeError();
178 Result += (*Section)->VirtualAddress;
255 Ret.p =
reinterpret_cast<uintptr_t
>(*Sec);
267 Ref.p =
reinterpret_cast<uintptr_t
>(Sec);
286 return toSec(Sec) - SectionTable;
333 if (!SectionNameOrErr) {
402 Ret.p =
reinterpret_cast<uintptr_t
>(begin);
412 Ret.p =
reinterpret_cast<uintptr_t
>(
I);
417Error COFFObjectFile::initSymbolTablePtr() {
424 if (COFFBigObjHeader)
436 const ulittle32_t *StringTableSizePtr;
439 StringTableSize = *StringTableSizePtr;
445 if (StringTableSize < 4)
449 if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
451 "string table missing null terminator");
458 else if (PE32PlusHeader)
468 assert(Rva <= UINT32_MAX);
474 const char *ErrorContext)
const {
477 uint32_t SectionStart = Section->VirtualAddress;
478 uint32_t SectionEnd = Section->VirtualAddress + Section->VirtualSize;
479 if (SectionStart <=
Addr &&
Addr < SectionEnd) {
489 if (Section->SizeOfRawData < Section->VirtualSize &&
490 Addr >= SectionStart + Section->SizeOfRawData) {
491 return make_error<SectionStrippedError>();
494 Res =
reinterpret_cast<uintptr_t
>(
base()) + Section->PointerToRawData +
501 "RVA 0x%" PRIx32
" for %s not found",
Addr,
504 "RVA 0x%" PRIx32
" not found",
Addr);
509 const char *ErrorContext)
const {
512 uint32_t SectionStart = Section->VirtualAddress;
515 uint32_t OffsetIntoSection = RVA - SectionStart;
516 if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize &&
517 Size <= Section->VirtualSize - OffsetIntoSection) {
518 uintptr_t Begin =
reinterpret_cast<uintptr_t
>(
base()) +
519 Section->PointerToRawData + OffsetIntoSection;
527 "RVA 0x%" PRIx32
" for %s not found", RVA,
530 "RVA 0x%" PRIx32
" not found", RVA);
537 uintptr_t IntPtr = 0;
540 const uint8_t *
Ptr =
reinterpret_cast<const uint8_t *
>(IntPtr);
541 Hint = *
reinterpret_cast<const ulittle16_t *
>(
Ptr);
552 InfoBytes,
"PDB info"))
554 if (InfoBytes.
size() <
sizeof(*PDBInfo) + 1)
557 InfoBytes = InfoBytes.
drop_front(
sizeof(*PDBInfo));
558 PDBFileName =
StringRef(
reinterpret_cast<const char *
>(InfoBytes.
data()),
561 PDBFileName = PDBFileName.
split(
'\0').first;
577Error COFFObjectFile::initImportTablePtr() {
592 uintptr_t IntPtr = 0;
597 ImportDirectory =
reinterpret_cast<
603Error COFFObjectFile::initDelayImportTablePtr() {
612 NumberOfDelayImportDirectory = DataEntry->
Size /
615 uintptr_t IntPtr = 0;
621 DelayImportDirectory =
reinterpret_cast<
627Error COFFObjectFile::initExportTablePtr() {
639 uintptr_t IntPtr = 0;
650Error COFFObjectFile::initBaseRelocPtr() {
658 uintptr_t IntPtr = 0;
668 IntPtr + DataEntry->
Size);
674Error COFFObjectFile::initDebugDirectoryPtr() {
687 "debug directory has uneven size");
689 uintptr_t IntPtr = 0;
696 DebugDirectoryBegin =
reinterpret_cast<const debug_directory *
>(IntPtr);
698 IntPtr + DataEntry->
Size);
704Error COFFObjectFile::initTLSDirectoryPtr() {
718 if (DataEntry->
Size != DirSize)
721 "TLS Directory size (%u) is not the expected size (%" PRIu64
").",
724 uintptr_t IntPtr = 0;
739Error COFFObjectFile::initLoadConfigPtr() {
748 uintptr_t IntPtr = 0;
750 "load config table"))
755 LoadConfig = (
const void *)IntPtr;
761 std::unique_ptr<COFFObjectFile> Obj(
new COFFObjectFile(std::move(Object)));
762 if (
Error E = Obj->initialize())
764 return std::move(Obj);
769 COFFBigObjHeader(nullptr), PE32Header(nullptr), PE32PlusHeader(nullptr),
770 DataDirectory(nullptr), SectionTable(nullptr), SymbolTable16(nullptr),
771 SymbolTable32(nullptr), StringTable(nullptr), StringTableSize(0),
772 ImportDirectory(nullptr), DelayImportDirectory(nullptr),
773 NumberOfDelayImportDirectory(0), ExportDirectory(nullptr),
774 BaseRelocHeader(nullptr), BaseRelocEnd(nullptr),
775 DebugDirectoryBegin(nullptr), DebugDirectoryEnd(nullptr),
776 TLSDirectory32(nullptr), TLSDirectory64(nullptr) {}
786Error COFFObjectFile::initialize() {
797 bool HasPEHeader =
false;
804 if (DH->Magic[0] ==
'M' && DH->Magic[1] ==
'Z') {
805 CurPtr = DH->AddressOfNewExeHeader;
809 "incorrect PE magic");
831 COFFHeader =
nullptr;
835 COFFBigObjHeader =
nullptr;
841 EC = std::error_code();
853 const uint8_t *DataDirAddr;
866 "incorrect PE magic");
875 assert(COFFHeader || COFFBigObjHeader);
884 if (
Error E = initSymbolTablePtr()) {
887 SymbolTable16 =
nullptr;
888 SymbolTable32 =
nullptr;
889 StringTable =
nullptr;
896 "symbol table missing");
937 Ret.p =
reinterpret_cast<uintptr_t
>(StringTable);
942 if (!ImportDirectory)
944 if (ImportDirectory->
isNull())
965 DelayImportDirectory, NumberOfDelayImportDirectory,
this));
974 if (!ExportDirectory)
983 Ret.p =
reinterpret_cast<uintptr_t
>(SectionTable);
991 Ret.p =
reinterpret_cast<uintptr_t
>(SectionTable + NumSections);
1012 return "COFF-x86-64";
1016 return "COFF-ARM64";
1018 return "COFF-ARM64EC";
1020 return "COFF-ARM64X";
1022 return "COFF-<unknown arch>";
1072 assert(PE32Header || PE32PlusHeader);
1075 if (
Index >= NumEnt)
1077 return &DataDirectory[
Index];
1087 return SectionTable + (
Index - 1);
1090 "section index out of bounds");
1094 if (StringTableSize <= 4)
1097 if (
Offset >= StringTableSize)
1109 if (Symbol->Name.Offset.Zeroes == 0)
1110 return getString(Symbol->Name.Offset.Offset);
1114 return StringRef(Symbol->Name.ShortName);
1122 const uint8_t *Aux =
nullptr;
1125 if (Symbol.getNumberOfAuxSymbols() > 0) {
1127 Aux =
reinterpret_cast<const uint8_t *
>(Symbol.getRawPtr()) + SymbolSize;
1130 uintptr_t
Offset = uintptr_t(Aux) - uintptr_t(
base());
1137 "Aux Symbol data did not point to the beginning of a symbol");
1140 return ArrayRef(Aux, Symbol.getNumberOfAuxSymbols() * SymbolSize);
1145 reinterpret_cast<uintptr_t
>(Symbol.getRawPtr()) -
getSymbolTable();
1147 "Symbol did not point to the beginning of a symbol");
1158 if (
Name.startswith(
"/")) {
1160 if (
Name.startswith(
"//")) {
1163 "invalid section name");
1167 "invalid section name");
1169 return getString(
Offset);
1200 uintptr_t ConStart =
1205 Res =
ArrayRef(
reinterpret_cast<const uint8_t *
>(ConStart), SectionSize);
1214 Rel.
p =
reinterpret_cast<uintptr_t
>(
1220 return R->VirtualAddress;
1229 Ref.p =
reinterpret_cast<uintptr_t
>(SymbolTable16 + R->SymbolTableIndex);
1230 else if (SymbolTable32)
1231 Ref.p =
reinterpret_cast<uintptr_t
>(SymbolTable32 + R->SymbolTableIndex);
1244 return toSec(Section.getRawDataRefImpl());
1249 return toSymb<coff_symbol16>(
Ref);
1251 return toSymb<coff_symbol32>(
Ref);
1270#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \
1271 case COFF::reloc_type: \
1370#undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME
1376 Result.append(Res.
begin(), Res.
end());
1380 return !DataDirectory;
1385 .
Case(
"eh_fram",
"eh_frame")
1396 if (ImportTable[
Index].isNull()) {
1398 ImportTable =
nullptr;
1410 if (Object->getBytesInAddress() == 4) {
1420 uintptr_t IntPtr = 0;
1422 cantFail(Object->getRvaPtr(RVA, IntPtr));
1428 uintptr_t IntPtr = 0;
1430 cantFail(Object->getRvaPtr(RVA, IntPtr));
1433 if (Object->getBytesInAddress() == 4) {
1434 auto *Entry =
reinterpret_cast<ulittle32_t *
>(IntPtr);
1438 auto *Entry =
reinterpret_cast<ulittle64_t *
>(IntPtr);
1478 uintptr_t IntPtr = 0;
1480 "import directory name"))
1482 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr));
1525 uintptr_t IntPtr = 0;
1527 "delay import directory name"))
1529 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr));
1535 Result = &Table[
Index];
1542 AddrIndex * (OwningObject->
is64() ? 8 : 4);
1543 uintptr_t IntPtr = 0;
1546 if (OwningObject->
is64())
1547 Result = *
reinterpret_cast<const ulittle64_t *
>(IntPtr);
1549 Result = *
reinterpret_cast<const ulittle32_t *
>(IntPtr);
1565 uintptr_t IntPtr = 0;
1569 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr));
1587 uintptr_t IntPtr = 0;
1589 IntPtr,
"export address"))
1601 uintptr_t IntPtr = 0;
1603 "export ordinal table"))
1605 const ulittle16_t *Start =
reinterpret_cast<const ulittle16_t *
>(IntPtr);
1609 for (
const ulittle16_t *
I = Start, *
E = Start + NumEntries;
1614 "export table entry"))
1616 const ulittle32_t *NamePtr =
reinterpret_cast<const ulittle32_t *
>(IntPtr);
1618 "export symbol name"))
1620 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr));
1632 "export table missing");
1638 Result = (Begin <= RVA && RVA <
End);
1646 uintptr_t IntPtr = 0;
1647 if (
auto EC = OwningObject->
getRvaPtr(RVA, IntPtr,
"export forward target"))
1649 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr));
1655 return Entry32 ==
Other.Entry32 && Entry64 ==
Other.Entry64
1675 uintptr_t IntPtr = 0;
1676 if (
Error EC = OwningObject->
getRvaPtr(RVA, IntPtr,
"import symbol name"))
1679 Result =
StringRef(
reinterpret_cast<const char *
>(IntPtr + 2));
1714 uintptr_t IntPtr = 0;
1715 if (
Error EC = OwningObject->
getRvaPtr(RVA, IntPtr,
"import symbol ordinal"))
1717 Result = *
reinterpret_cast<const ulittle16_t *
>(IntPtr);
1735 if (
Size == Header->BlockSize) {
1741 reinterpret_cast<const uint8_t *
>(Header) +
Size);
1756 Result = Header->PageRVA + Entry[
Index].getOffset();
1760#define RETURN_IF_ERROR(Expr) \
1764 return std::move(E); \
1775 return RawDirString;
1780 return getDirStringAtOffset(Entry.Identifier.getNameOffset());
1788 Reader.setOffset(
Offset);
1790 assert(Table !=
nullptr);
1799 Reader.setOffset(
Offset);
1801 assert(Entry !=
nullptr);
1810 Reader.setOffset(
Offset);
1812 assert(Entry !=
nullptr);
1818 assert(Entry.Offset.isSubDir());
1819 return getTableAtOffset(Entry.Offset.value());
1824 assert(!Entry.Offset.isSubDir());
1825 return getDataEntryAtOffset(Entry.Offset.value());
1829 return getTableAtOffset(0);
1837 const uint8_t *TablePtr =
reinterpret_cast<const uint8_t *
>(&Table);
1839 return getTableEntryAtOffset(TableOffset +
sizeof(Table) +
1847 return Name.takeError();
1849 if (*
Name ==
".rsrc" || *
Name ==
".rsrc$01")
1853 "no resource section found");
1863 const coff_section *COFFSect = Obj->getCOFFSection(Section);
1865 Relocs.reserve(OrigRelocs.
size());
1867 Relocs.push_back(&R);
1869 return A->VirtualAddress <
B->VirtualAddress;
1881 const uint8_t *EntryPtr =
reinterpret_cast<const uint8_t *
>(&Entry);
1885 auto RelocsForOffset =
1886 std::equal_range(Relocs.begin(), Relocs.end(), &RelocTarget,
1888 return A->VirtualAddress < B->VirtualAddress;
1891 if (RelocsForOffset.first != RelocsForOffset.second) {
1896 switch (Obj->getMachine()) {
1913 "unsupported architecture");
1915 if (R.Type != RVAReloc)
1917 "unexpected relocation type");
1921 return Sym.takeError();
1924 Obj->getSection(
Sym->getSectionNumber());
1926 return Section.takeError();
1931 if (
Error E = Obj->getSectionContents(*Section, Contents))
1932 return std::move(
E);
1933 if (
Offset + Entry.DataSize > Contents.
size())
1935 "data outside of section");
1941 if (Obj->isRelocatableObject())
1943 "no relocation found for DataRVA");
1946 uint64_t VA = Entry.DataRVA + Obj->getImageBase();
1947 for (
const SectionRef &S : Obj->sections()) {
1948 if (VA >= S.getAddress() &&
1949 VA + Entry.DataSize <= S.getAddress() + S.getSize()) {
1954 return Contents->slice(
Offset,
Offset + Entry.DataSize);
1958 "address not found in image");
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static imported_symbol_iterator importedSymbolEnd(uint32_t RVA, const COFFObjectFile *Object)
static uint32_t getNumberOfRelocations(const coff_section *Sec, MemoryBufferRef M, const uint8_t *base)
static Error getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
static imported_symbol_iterator makeImportedSymbolIterator(const COFFObjectFile *Object, uintptr_t Ptr, int Index)
#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type)
static const coff_relocation * getFirstReloc(const coff_section *Sec, MemoryBufferRef M, const uint8_t *Base)
static imported_symbol_iterator importedSymbolBegin(uint32_t RVA, const COFFObjectFile *Object)
static bool checkSize(MemoryBufferRef M, std::error_code &EC, uint64_t Size)
#define RETURN_IF_ERROR(Expr)
static bool decodeBase64StringEntry(StringRef Str, uint32_t &Result)
static Error ignoreStrippedErrors(Error E)
Merge contiguous icmps into a memcmp
print Instructions which execute on loop entry
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
ArrayRef< uint8_t > data() const
Provides read only access to a subclass of BinaryStream.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
void setOffset(uint64_t Off)
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
A range adaptor for a pair of iterators.
Error getType(uint8_t &Type) const
bool operator==(const BaseRelocRef &Other) const
Error getRVA(uint32_t &Result) const
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
const dos_header * getDOSHeader() const
uint64_t getSectionSize(DataRefImpl Sec) const override
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
uint64_t getSectionIndex(DataRefImpl Sec) const override
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
bool isSectionCompressed(DataRefImpl Sec) const override
void moveRelocationNext(DataRefImpl &Rel) const override
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
export_directory_iterator export_directory_begin() const
delay_import_directory_iterator delay_import_directory_end() const
base_reloc_iterator base_reloc_begin() const
section_iterator section_end() const override
Error getVaPtr(uint64_t VA, uintptr_t &Res) const
uint64_t getRelocationType(DataRefImpl Rel) const override
void moveSymbolNext(DataRefImpl &Symb) const override
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
iterator_range< delay_import_directory_iterator > delay_import_directories() const
import_directory_iterator import_directory_end() const
uint32_t getPointerToSymbolTable() const
const coff_relocation * getCOFFRelocation(const RelocationRef &Reloc) const
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
bool isDebugSection(DataRefImpl Sec) const override
iterator_range< const debug_directory * > debug_directories() const
StringRef getRelocationTypeName(uint16_t Type) const
bool isSectionBSS(DataRefImpl Sec) const override
base_reloc_iterator base_reloc_end() const
uint64_t getSectionAddress(DataRefImpl Sec) const override
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
uint32_t getNumberOfSymbols() const
section_iterator section_begin() const override
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
size_t getSymbolTableEntrySize() const
friend class ImportDirectoryEntryRef
export_directory_iterator export_directory_end() const
Error getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const
uintptr_t getSymbolTable() const
static Expected< std::unique_ptr< COFFObjectFile > > create(MemoryBufferRef Object)
bool isSectionVirtual(DataRefImpl Sec) const override
unsigned getSectionID(SectionRef Sec) const
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
iterator_range< import_directory_iterator > import_directories() const
delay_import_directory_iterator delay_import_directory_begin() const
basic_symbol_iterator symbol_end() const override
Error getRvaAndSizeAsBytes(uint32_t RVA, uint32_t Size, ArrayRef< uint8_t > &Contents, const char *ErrorContext=nullptr) const
Given an RVA base and size, returns a valid array of bytes or an error code if the RVA and size is no...
iterator_range< export_directory_iterator > export_directories() const
uint32_t getNumberOfSections() const
uint64_t getRelocationOffset(DataRefImpl Rel) const override
basic_symbol_iterator symbol_begin() const override
Triple::ArchType getArch() const override
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Expected< const coff_section * > getSection(int32_t index) const
bool isSectionText(DataRefImpl Sec) const override
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
const data_directory * getDataDirectory(uint32_t index) const
StringRef mapDebugSectionName(StringRef Name) const override
Maps a debug section name to a standard DWARF section name.
ArrayRef< uint8_t > getSymbolAuxData(COFFSymbolRef Symbol) const
uint64_t getImageBase() const
const coff_section * getCOFFSection(const SectionRef &Section) const
import_directory_iterator import_directory_begin() const
void moveSectionNext(DataRefImpl &Sec) const override
relocation_iterator section_rel_end(DataRefImpl Sec) const override
ArrayRef< coff_relocation > getRelocations(const coff_section *Sec) const
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
Error getRvaPtr(uint32_t Rva, uintptr_t &Res, const char *ErrorContext=nullptr) const
unsigned getSymbolSectionID(SymbolRef Sym) const
Error getDebugPDBInfo(const debug_directory *DebugDir, const codeview::DebugInfo *&Info, StringRef &PDBFileName) const
Get PDB information out of a codeview debug directory entry.
friend class ExportDirectoryEntryRef
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
uint64_t getSectionAlignment(DataRefImpl Sec) const override
uint32_t getSymbolIndex(COFFSymbolRef Symbol) const
uint16_t getMachine() const
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
Expected< uint64_t > getStartAddress() const override
iterator_range< base_reloc_iterator > base_relocs() const
bool isSectionData(DataRefImpl Sec) const override
StringRef getFileFormatName() const override
bool isAnyUndefined() const
bool isFileRecord() const
const coff_aux_weak_external * getWeakExternal() const
bool isSectionDefinition() const
uint8_t getComplexType() const
uint32_t getValue() const
bool isWeakExternal() const
int32_t getSectionNumber() const
bool operator==(const DelayImportDirectoryEntryRef &Other) const
imported_symbol_iterator imported_symbol_begin() const
Error getImportAddress(int AddrIndex, uint64_t &Result) const
iterator_range< imported_symbol_iterator > imported_symbols() const
imported_symbol_iterator imported_symbol_end() const
Error getDelayImportTable(const delay_import_directory_table_entry *&Result) const
Error getName(StringRef &Result) const
bool operator==(const ExportDirectoryEntryRef &Other) const
Error getDllName(StringRef &Result) const
Error getExportRVA(uint32_t &Result) const
Error getOrdinalBase(uint32_t &Result) const
Error getOrdinal(uint32_t &Result) const
Error isForwarder(bool &Result) const
Error getForwardTo(StringRef &Result) const
Error getSymbolName(StringRef &Result) const
bool operator==(const ImportDirectoryEntryRef &Other) const
imported_symbol_iterator imported_symbol_end() const
imported_symbol_iterator imported_symbol_begin() const
Error getImportLookupTableRVA(uint32_t &Result) const
Error getImportTableEntry(const coff_import_directory_table_entry *&Result) const
imported_symbol_iterator lookup_table_end() const
iterator_range< imported_symbol_iterator > lookup_table_symbols() const
iterator_range< imported_symbol_iterator > imported_symbols() const
imported_symbol_iterator lookup_table_begin() const
Error getImportAddressTableRVA(uint32_t &Result) const
Error getName(StringRef &Result) const
bool operator==(const ImportedSymbolRef &Other) const
Error getHintNameRVA(uint32_t &Result) const
Error getOrdinal(uint16_t &Result) const
Error getSymbolName(StringRef &Result) const
Error isOrdinal(bool &Result) const
This class is the base class for all object file types.
friend class RelocationRef
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
section_iterator_range sections() const
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
const uint8_t * base() const
This is a value type class that represents a single relocation in the list of relocations in the obje...
DataRefImpl getRawDataRefImpl() const
Expected< const coff_resource_dir_table & > getBaseTable()
Expected< const coff_resource_dir_table & > getEntrySubDir(const coff_resource_dir_entry &Entry)
Expected< const coff_resource_data_entry & > getEntryData(const coff_resource_dir_entry &Entry)
Error load(const COFFObjectFile *O)
Expected< ArrayRef< UTF16 > > getEntryNameString(const coff_resource_dir_entry &Entry)
Expected< StringRef > getContents(const coff_resource_data_entry &Entry)
Expected< const coff_resource_dir_entry & > getTableEntry(const coff_resource_dir_table &Table, uint32_t Index)
This is a value type class that represents a single section in the list of sections in the object fil...
DataRefImpl getRawDataRefImpl() const
Expected< StringRef > getContents() const
This is a value type class that represents a single symbol in the list of symbols in the object file.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_UNKNOWN
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_ARM64EC
@ IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_ARM64X
@ IMAGE_FILE_MACHINE_ARMNT
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
@ IMAGE_SCN_CNT_INITIALIZED_DATA
@ IMAGE_DEBUG_TYPE_CODEVIEW
@ IMAGE_REL_ARM64_ADDR32NB
@ IMAGE_REL_AMD64_ADDR32NB
@ DELAY_IMPORT_DESCRIPTOR
@ IMAGE_WEAK_EXTERN_SEARCH_ALIAS
bool isReservedSectionNumber(int32_t SectionNumber)
static const char BigObjMagic[]
static const char PEMagic[]
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
content_iterator< ImportDirectoryEntryRef > import_directory_iterator
content_iterator< ImportedSymbolRef > imported_symbol_iterator
content_iterator< ExportDirectoryEntryRef > export_directory_iterator
content_iterator< BaseRelocRef > base_reloc_iterator
coff_tls_directory< support::little64_t > coff_tls_directory64
content_iterator< SectionRef > section_iterator
content_iterator< RelocationRef > relocation_iterator
content_iterator< BasicSymbolRef > basic_symbol_iterator
content_iterator< DelayImportDirectoryEntryRef > delay_import_directory_iterator
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.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
void sort(IteratorTy Start, IteratorTy End)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ Ref
The access may reference the value stored in memory.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
support::ulittle32_t ImportAddressTableRVA
support::ulittle32_t NameRVA
support::ulittle32_t ImportLookupTableRVA
support::ulittle16_t Type
support::ulittle32_t VirtualAddress
support::ulittle16_t NumberOfNameEntries
support::ulittle16_t NumberOfIDEntries
support::ulittle32_t PointerToRawData
char Name[COFF::NameSize]
support::ulittle32_t VirtualSize
bool hasExtendedRelocations() const
uint32_t getAlignment() const
support::ulittle32_t Characteristics
support::ulittle32_t SizeOfRawData
support::ulittle32_t VirtualAddress
support::ulittle32_t PointerToRelocations
support::ulittle16_t NumberOfRelocations
uint8_t NumberOfAuxSymbols
support::ulittle32_t RelativeVirtualAddress
support::ulittle32_t Size
support::ulittle32_t SizeOfData
support::ulittle32_t AddressOfRawData
support::ulittle32_t DelayImportAddressTable
support::ulittle32_t Name
support::ulittle32_t OrdinalBase
support::ulittle32_t ExportAddressTableRVA
support::ulittle32_t NameRVA
support::ulittle32_t NumberOfNamePointers
support::ulittle32_t NamePointerRVA
support::ulittle32_t AddressTableEntries
support::ulittle32_t OrdinalTableRVA
uint32_t getHintNameRVA() const
uint16_t getOrdinal() const