35 #include <system_error> 59 const uint64_t
Size =
sizeof(
T)) {
60 uintptr_t Addr = uintptr_t(Ptr);
63 Obj =
reinterpret_cast<const T *
>(Addr);
64 return std::error_code();
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] ==
'/')
90 Value = (Value * 64) + CharVal;
101 template <
typename coff_symbol_type>
102 const coff_symbol_type *COFFObjectFile::toSymb(
DataRefImpl Ref)
const {
103 const coff_symbol_type *Addr =
104 reinterpret_cast<const coff_symbol_type *
>(Ref.
p);
109 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(
base());
112 "Symbol did not point to the beginning of a symbol");
126 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(SectionTable);
128 "Section did not point to the beginning of a section");
135 auto End =
reinterpret_cast<uintptr_t
>(StringTable);
139 Ref.
p = std::min(reinterpret_cast<uintptr_t>(Symb), End);
140 }
else if (SymbolTable32) {
143 Ref.
p = std::min(reinterpret_cast<uintptr_t>(Symb), End);
178 if (std::error_code EC =
getSection(SectionNumber, Section))
257 Ret.
p =
reinterpret_cast<uintptr_t
>(Sec);
269 Ref.
p =
reinterpret_cast<uintptr_t
>(Sec);
288 return toSec(Sec) - SectionTable;
351 if (Sec->hasExtendedRelocations()) {
352 const coff_relocation *FirstReloc;
353 if (
getObject(FirstReloc, M, reinterpret_cast<const coff_relocation*>(
354 base + Sec->PointerToRelocations)))
357 return FirstReloc->VirtualAddress - 1;
359 return Sec->NumberOfRelocations;
362 static const coff_relocation *
367 auto begin =
reinterpret_cast<const coff_relocation *
>(
368 Base + Sec->PointerToRelocations);
369 if (Sec->hasExtendedRelocations()) {
375 sizeof(coff_relocation) * NumRelocs))
386 Ret.
p =
reinterpret_cast<uintptr_t
>(
begin);
396 Ret.
p =
reinterpret_cast<uintptr_t
>(
I);
401 std::error_code COFFObjectFile::initSymbolTablePtr() {
408 if (COFFBigObjHeader)
419 const uint8_t *StringTableAddr =
base() + StringTableOffset;
421 if (std::error_code EC =
getObject(StringTableSizePtr,
Data, StringTableAddr))
423 StringTableSize = *StringTableSizePtr;
424 if (std::error_code EC =
425 getObject(StringTable,
Data, StringTableAddr, StringTableSize))
430 if (StringTableSize < 4)
434 if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
436 return std::error_code();
442 else if (PE32PlusHeader)
451 uint64_t Rva = Addr - ImageBase;
452 assert(Rva <= UINT32_MAX);
462 if (SectionStart <= Addr && Addr < SectionEnd) {
465 return std::error_code();
479 uint32_t OffsetIntoSection = RVA - SectionStart;
480 if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize &&
481 Size <= Section->VirtualSize - OffsetIntoSection) {
486 return std::error_code();
496 uintptr_t IntPtr = 0;
497 if (std::error_code EC =
getRvaPtr(Rva, IntPtr))
499 const uint8_t *Ptr =
reinterpret_cast<const uint8_t *
>(IntPtr);
500 Hint = *
reinterpret_cast<const ulittle16_t *
>(Ptr);
501 Name =
StringRef(reinterpret_cast<const char *>(Ptr + 2));
502 return std::error_code();
513 if (InfoBytes.
size() <
sizeof(*PDBInfo) + 1)
516 InfoBytes = InfoBytes.
drop_front(
sizeof(*PDBInfo));
517 PDBFileName =
StringRef(reinterpret_cast<const char *>(InfoBytes.
data()),
520 PDBFileName = PDBFileName.
split(
'\0').first;
521 return std::error_code();
533 return std::error_code();
537 std::error_code COFFObjectFile::initImportTablePtr() {
542 return std::error_code();
546 return std::error_code();
552 uintptr_t IntPtr = 0;
553 if (std::error_code EC =
getRvaPtr(ImportTableRva, IntPtr))
557 ImportDirectory =
reinterpret_cast< 559 return std::error_code();
563 std::error_code COFFObjectFile::initDelayImportTablePtr() {
566 return std::error_code();
568 return std::error_code();
571 NumberOfDelayImportDirectory = DataEntry->
Size /
574 uintptr_t IntPtr = 0;
575 if (std::error_code EC =
getRvaPtr(RVA, IntPtr))
577 DelayImportDirectory =
reinterpret_cast< 579 return std::error_code();
583 std::error_code COFFObjectFile::initExportTablePtr() {
588 return std::error_code();
592 return std::error_code();
595 uintptr_t IntPtr = 0;
596 if (std::error_code EC =
getRvaPtr(ExportTableRva, IntPtr))
600 return std::error_code();
603 std::error_code COFFObjectFile::initBaseRelocPtr() {
606 return std::error_code();
608 return std::error_code();
610 uintptr_t IntPtr = 0;
616 IntPtr + DataEntry->
Size);
619 return std::error_code();
622 std::error_code COFFObjectFile::initDebugDirectoryPtr() {
626 return std::error_code();
630 return std::error_code();
636 uintptr_t IntPtr = 0;
639 DebugDirectoryBegin =
reinterpret_cast<const debug_directory *
>(IntPtr);
641 IntPtr + DataEntry->
Size);
644 return std::error_code();
647 std::error_code COFFObjectFile::initLoadConfigPtr() {
651 return std::error_code();
655 return std::error_code();
656 uintptr_t IntPtr = 0;
660 LoadConfig = (
const void *)IntPtr;
661 return std::error_code();
666 COFFBigObjHeader(nullptr), PE32Header(nullptr), PE32PlusHeader(nullptr),
667 DataDirectory(nullptr), SectionTable(nullptr), SymbolTable16(nullptr),
668 SymbolTable32(nullptr), StringTable(nullptr), StringTableSize(0),
669 ImportDirectory(nullptr),
670 DelayImportDirectory(nullptr), NumberOfDelayImportDirectory(0),
671 ExportDirectory(nullptr), BaseRelocHeader(nullptr), BaseRelocEnd(nullptr),
672 DebugDirectoryBegin(nullptr), DebugDirectoryEnd(nullptr) {
682 bool HasPEHeader =
false;
689 if (DH->Magic[0] ==
'M' && DH->Magic[1] ==
'Z') {
716 COFFHeader =
nullptr;
720 COFFBigObjHeader =
nullptr;
726 EC = std::error_code();
738 const uint8_t *DataDirAddr;
739 uint64_t DataDirSize;
753 if ((EC =
getObject(DataDirectory,
Data, DataDirAddr, DataDirSize)))
766 if ((EC = initSymbolTablePtr())) {
767 SymbolTable16 =
nullptr;
768 SymbolTable32 =
nullptr;
769 StringTable =
nullptr;
781 if ((EC = initImportTablePtr()))
783 if ((EC = initDelayImportTablePtr()))
787 if ((EC = initExportTablePtr()))
791 if ((EC = initBaseRelocPtr()))
795 if ((EC = initDebugDirectoryPtr()))
798 if ((EC = initLoadConfigPtr()))
801 EC = std::error_code();
813 Ret.
p =
reinterpret_cast<uintptr_t
>(StringTable);
818 if (!ImportDirectory)
820 if (ImportDirectory->
isNull())
841 DelayImportDirectory, NumberOfDelayImportDirectory,
this));
850 if (!ExportDirectory)
859 Ret.
p =
reinterpret_cast<uintptr_t
>(SectionTable);
867 Ret.
p =
reinterpret_cast<uintptr_t
>(SectionTable + NumSections);
888 return "COFF-x86-64";
894 return "COFF-<unknown arch>";
943 if (!DataDirectory) {
947 assert(PE32Header || PE32PlusHeader);
950 if (Index >= NumEnt) {
954 Res = &DataDirectory[
Index];
955 return std::error_code();
962 return std::error_code();
965 Result = SectionTable + (Index - 1);
966 return std::error_code();
975 auto NameOrErr =
Section.getName();
979 if (*NameOrErr == SectionName) {
981 return std::error_code();
989 if (StringTableSize <= 4)
992 if (Offset >= StringTableSize)
994 Result =
StringRef(StringTable + Offset);
995 return std::error_code();
1009 return std::error_code();
1018 return std::error_code();
1023 const uint8_t *Aux =
nullptr;
1028 Aux =
reinterpret_cast<const uint8_t *
>(Symbol.
getRawPtr()) + SymbolSize;
1031 uintptr_t Offset = uintptr_t(Aux) - uintptr_t(
base());
1038 "Aux Symbol data did not point to the beginning of a symbol");
1048 "Symbol did not point to the beginning of a symbol");
1070 "inalid section name");
1074 "invalid section name");
1076 if (std::error_code EC = getString(Offset, Name))
1111 return make_error<BinaryError>();
1112 Res =
makeArrayRef(reinterpret_cast<const uint8_t *>(ConStart), SectionSize);
1121 Rel.
p =
reinterpret_cast<uintptr_t
>(
1137 else if (SymbolTable32)
1156 return toSymb<coff_symbol16>(Ref);
1158 return toSymb<coff_symbol32>(Ref);
1177 #define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \ 1178 case COFF::reloc_type: \ 1275 #undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME 1285 return !DataDirectory;
1290 .Case(
"eh_fram",
"eh_frame")
1296 return ImportTable == Other.ImportTable && Index == Other.Index;
1301 if (ImportTable[Index].isNull()) {
1303 ImportTable =
nullptr;
1309 return getObject(Result, OwningObject->Data, ImportTable + Index);
1314 uintptr_t Ptr,
int Index) {
1315 if (Object->getBytesInAddress() == 4) {
1325 uintptr_t IntPtr = 0;
1326 Object->getRvaPtr(RVA, IntPtr);
1332 uintptr_t IntPtr = 0;
1333 Object->getRvaPtr(RVA, IntPtr);
1336 if (Object->getBytesInAddress() == 4) {
1362 return make_range(imported_symbol_begin(), imported_symbol_end());
1377 return make_range(lookup_table_begin(), lookup_table_end());
1381 uintptr_t IntPtr = 0;
1382 if (std::error_code EC =
1383 OwningObject->getRvaPtr(ImportTable[Index].NameRVA, IntPtr))
1385 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1386 return std::error_code();
1391 Result = ImportTable[
Index].ImportLookupTableRVA;
1392 return std::error_code();
1397 Result = ImportTable[
Index].ImportAddressTableRVA;
1398 return std::error_code();
1403 return Table == Other.Table && Index == Other.Index;
1424 return make_range(imported_symbol_begin(), imported_symbol_end());
1428 uintptr_t IntPtr = 0;
1429 if (std::error_code EC = OwningObject->getRvaPtr(Table[Index].Name, IntPtr))
1431 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1432 return std::error_code();
1437 Result = &Table[
Index];
1438 return std::error_code();
1444 AddrIndex * (OwningObject->is64() ? 8 : 4);
1445 uintptr_t IntPtr = 0;
1446 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1448 if (OwningObject->is64())
1449 Result = *reinterpret_cast<const ulittle64_t *>(IntPtr);
1451 Result = *
reinterpret_cast<const ulittle32_t *
>(IntPtr);
1452 return std::error_code();
1457 return ExportTable == Other.ExportTable && Index == Other.Index;
1467 uintptr_t IntPtr = 0;
1468 if (std::error_code EC =
1469 OwningObject->getRvaPtr(ExportTable->NameRVA, IntPtr))
1471 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1472 return std::error_code();
1478 Result = ExportTable->OrdinalBase;
1479 return std::error_code();
1484 Result = ExportTable->OrdinalBase +
Index;
1485 return std::error_code();
1490 uintptr_t IntPtr = 0;
1491 if (std::error_code EC =
1492 OwningObject->getRvaPtr(ExportTable->ExportAddressTableRVA, IntPtr))
1497 return std::error_code();
1504 uintptr_t IntPtr = 0;
1505 if (std::error_code EC =
1506 OwningObject->getRvaPtr(ExportTable->OrdinalTableRVA, IntPtr))
1510 uint32_t NumEntries = ExportTable->NumberOfNamePointers;
1516 if (std::error_code EC =
1517 OwningObject->getRvaPtr(ExportTable->NamePointerRVA, IntPtr))
1520 if (std::error_code EC = OwningObject->getRvaPtr(NamePtr[Offset], IntPtr))
1522 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1523 return std::error_code();
1526 return std::error_code();
1534 if (
auto EC = getExportRVA(RVA))
1538 Result = (Begin <= RVA && RVA < End);
1539 return std::error_code();
1544 if (
auto EC = getExportRVA(RVA))
1546 uintptr_t IntPtr = 0;
1547 if (
auto EC = OwningObject->getRvaPtr(RVA, IntPtr))
1549 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1550 return std::error_code();
1555 return Entry32 == Other.Entry32 && Entry64 == Other.Entry64
1556 && Index == Other.Index;
1568 if (Entry32[Index].isOrdinal())
1569 return std::error_code();
1570 RVA = Entry32[
Index].getHintNameRVA();
1572 if (Entry64[Index].isOrdinal())
1573 return std::error_code();
1574 RVA = Entry64[
Index].getHintNameRVA();
1576 uintptr_t IntPtr = 0;
1577 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1580 Result =
StringRef(reinterpret_cast<const char *>(IntPtr + 2));
1581 return std::error_code();
1586 Result = Entry32[
Index].isOrdinal();
1588 Result = Entry64[
Index].isOrdinal();
1589 return std::error_code();
1594 Result = Entry32[
Index].getHintNameRVA();
1596 Result = Entry64[
Index].getHintNameRVA();
1597 return std::error_code();
1603 if (Entry32[Index].isOrdinal()) {
1604 Result = Entry32[
Index].getOrdinal();
1605 return std::error_code();
1607 RVA = Entry32[
Index].getHintNameRVA();
1609 if (Entry64[Index].isOrdinal()) {
1610 Result = Entry64[
Index].getOrdinal();
1611 return std::error_code();
1613 RVA = Entry64[
Index].getHintNameRVA();
1615 uintptr_t IntPtr = 0;
1616 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1618 Result = *
reinterpret_cast<const ulittle16_t *
>(IntPtr);
1619 return std::error_code();
1628 return std::move(Ret);
1632 return Header == Other.Header && Index == Other.Index;
1640 if (Size == Header->BlockSize) {
1646 reinterpret_cast<const uint8_t *
>(Header) + Size);
1656 return std::error_code();
1661 Result = Header->PageRVA +
Entry[
Index].getOffset();
1662 return std::error_code();
1665 #define RETURN_IF_ERROR(Expr) \ 1669 return std::move(E); \ 1673 ResourceSectionRef::getDirStringAtOffset(
uint32_t Offset) {
1680 return RawDirString;
1685 return getDirStringAtOffset(Entry.
Identifier.getNameOffset());
1689 ResourceSectionRef::getTableAtOffset(
uint32_t Offset) {
1695 assert(Table !=
nullptr);
1700 ResourceSectionRef::getTableEntryAtOffset(
uint32_t Offset) {
1706 assert(Entry !=
nullptr);
1711 ResourceSectionRef::getDataEntryAtOffset(
uint32_t Offset) {
1717 assert(Entry !=
nullptr);
1724 return getTableAtOffset(Entry.
Offset.value());
1730 return getDataEntryAtOffset(Entry.
Offset.value());
1734 return getTableAtOffset(0);
1742 const uint8_t *TablePtr =
reinterpret_cast<const uint8_t *
>(&Table);
1743 ptrdiff_t TableOffset = TablePtr - BBS.data().data();
1744 return getTableEntryAtOffset(TableOffset +
sizeof(Table) +
1754 if (*Name ==
".rsrc" || *Name ==
".rsrc$01")
1758 "no resource section found");
1770 Relocs.reserve(OrigRelocs.
size());
1772 Relocs.push_back(&R);
1787 const uint8_t *EntryPtr =
reinterpret_cast<const uint8_t *
>(&Entry);
1788 ptrdiff_t EntryOffset = EntryPtr - BBS.data().data();
1791 auto RelocsForOffset =
1792 std::equal_range(Relocs.begin(), Relocs.end(), &RelocTarget,
1794 return A->VirtualAddress <
B->VirtualAddress;
1797 if (RelocsForOffset.first != RelocsForOffset.second) {
1802 switch (Obj->getMachine()) {
1817 "unsupported architecture");
1819 if (R.
Type != RVAReloc)
1821 "unexpected relocation type");
1828 if (std::error_code EC = Obj->getSection(Sym->getSectionNumber(),
Section))
1832 uint64_t Offset = Entry.
DataRVA + Sym->getValue();
1834 if (
Error E = Obj->getSectionContents(Section, Contents))
1835 return std::move(
E);
1838 "data outside of section");
1840 return StringRef(reinterpret_cast<const char *>(Contents.
data()) + Offset,
1844 if (Obj->isRelocatableObject())
1846 "no relocation found for DataRVA");
1849 uint64_t VA = Entry.
DataRVA + Obj->getImageBase();
1850 for (
const SectionRef &S : Obj->sections()) {
1851 if (VA >= S.getAddress() &&
1852 VA + Entry.
DataSize <= S.getAddress() + S.getSize()) {
1853 uint64_t Offset = VA - S.getAddress();
1857 return Contents->slice(Offset, Offset + Entry.
DataSize);
1861 "address not found in image");
uint32_t getAlignment() const
static uint32_t getNumberOfRelocations(const coff_section *Sec, MemoryBufferRef M, const uint8_t *base)
std::error_code getHintNameRVA(uint32_t &Result) const
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
std::error_code getImportAddress(int AddrIndex, uint64_t &Result) const
section_iterator section_begin() const override
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer...
std::error_code getType(uint8_t &Type) const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
const coff_section * getCOFFSection(const SectionRef &Section) const
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
COFFObjectFile(MemoryBufferRef Object, std::error_code &EC)
uint64_t getRelocationOffset(DataRefImpl Rel) const override
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
support::ulittle32_t VirtualAddress
bool operator==(const DelayImportDirectoryEntryRef &Other) const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void moveSectionNext(DataRefImpl &Sec) const override
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
static std::error_code checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
export_directory_iterator export_directory_end() const
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
std::error_code getSection(int32_t index, const coff_section *&Res) const
std::error_code getOrdinal(uint32_t &Result) const
base_reloc_iterator base_reloc_end() const
void moveRelocationNext(DataRefImpl &Rel) const override
This class is the base class for all object file types.
content_iterator< DelayImportDirectoryEntryRef > delay_import_directory_iterator
uint32_t getPointerToSymbolTable() const
static const coff_relocation * getFirstReloc(const coff_section *Sec, MemoryBufferRef M, const uint8_t *Base)
iterator_range< imported_symbol_iterator > imported_symbols() const
bool isSectionDefinition() const
uint64_t getImageBase() const
bool isSectionCompressed(DataRefImpl Sec) const override
const uint8_t * base() const
uint8_t getNumberOfAuxSymbols() const
export_directory_iterator export_directory_begin() const
std::error_code getName(StringRef &Result) const
Error takeError()
Take ownership of the stored error.
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
static const char BigObjMagic[]
const coff_relocation * getCOFFRelocation(const RelocationRef &Reloc) const
import_directory_iterator import_directory_begin() const
iterator_range< const debug_directory * > debug_directories() const
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
basic_symbol_iterator symbol_end() const override
detail::packed_endian_specific_integral< uint64_t, little, unaligned > ulittle64_t
char ShortName[COFF::NameSize]
friend class ExportDirectoryEntryRef
uint64_t getSectionAlignment(DataRefImpl Sec) const override
char Name[COFF::NameSize]
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
DataRefImpl getRawDataRefImpl() const
support::ulittle16_t NumberOfNameEntries
This is a value type class that represents a single relocation in the list of relocations in the obje...
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
The access may reference the value stored in memory.
LLVM_NODISCARD R Default(T Value)
iterator_range< base_reloc_iterator > base_relocs() const
Tagged union holding either a T or a Error.
static imported_symbol_iterator importedSymbolBegin(uint32_t RVA, const COFFObjectFile *Object)
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
bool isReservedSectionNumber(int32_t SectionNumber)
imported_symbol_iterator lookup_table_begin() const
std::error_code getRvaAndSizeAsBytes(uint32_t RVA, uint32_t Size, ArrayRef< uint8_t > &Contents) const
Given an RVA base and size, returns a valid array of bytes or an error code if the RVA and size is no...
support::ulittle32_t VirtualSize
#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type)
content_iterator< SectionRef > section_iterator
iterator_range< imported_symbol_iterator > imported_symbols() const
union llvm::object::coff_symbol_generic::@284 Name
Error load(const COFFObjectFile *O)
imported_symbol_iterator imported_symbol_end() const
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
int32_t getSectionNumber() const
uint32_t getSymbolFlags(DataRefImpl Symb) const override
std::error_code getDllName(StringRef &Result) const
#define RETURN_IF_ERROR(Expr)
union llvm::object::coff_resource_dir_entry::@286 Offset
uint64_t getSectionAddress(DataRefImpl Sec) const override
LLVM_NODISCARD size_t size() const
size - Get the string size.
section_iterator_range sections() const
void moveSymbolNext(DataRefImpl &Symb) const override
uint8_t getComplexType() const
support::ulittle32_t ExportRVA
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
std::error_code getRVA(uint32_t &Result) const
Expected< StringRef > getContents(const coff_resource_data_entry &Entry)
static bool checkSize(MemoryBufferRef M, std::error_code &EC, uint64_t Size)
relocation_iterator section_rel_end(DataRefImpl Sec) const override
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
std::error_code getDelayImportTable(const delay_import_directory_table_entry *&Result) const
support::ulittle32_t Characteristics
A switch()-like statement whose cases are string literals.
base_reloc_iterator base_reloc_begin() const
std::error_code getName(StringRef &Result) const
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
content_iterator< ExportDirectoryEntryRef > export_directory_iterator
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
support::ulittle16_t NumberOfIDEntries
size_t getBufferSize() const
delay_import_directory_iterator delay_import_directory_end() const
The instances of the Type class are immutable: once they are created, they are never changed...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
bool operator==(const BaseRelocRef &Other) const
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Expected< const coff_resource_data_entry & > getEntryData(const coff_resource_dir_entry &Entry)
const dos_header * getDOSHeader() const
content_iterator< ImportedSymbolRef > imported_symbol_iterator
std::error_code getOrdinal(uint16_t &Result) const
import_lookup_table_entry< support::little64_t > import_lookup_table_entry64
std::error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const
bool operator==(const ImportedSymbolRef &Other) const
delay_import_directory_iterator delay_import_directory_begin() const
support::ulittle32_t RelativeVirtualAddress
content_iterator< ImportDirectoryEntryRef > import_directory_iterator
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
std::error_code isForwarder(bool &Result) const
support::ulittle32_t DataSize
std::error_code getSymbolName(StringRef &Result) const
imported_symbol_iterator imported_symbol_begin() const
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
const void * getRawPtr() const
support::ulittle16_t Type
std::error_code getDebugPDBInfo(const debug_directory *DebugDir, const codeview::DebugInfo *&Info, StringRef &PDBFileName) const
Get PDB information out of a codeview debug directory entry.
const coff_symbol_generic * getGeneric() const
static imported_symbol_iterator makeImportedSymbolIterator(const COFFObjectFile *Object, uintptr_t Ptr, int Index)
support::ulittle32_t SizeOfRawData
uint64_t getRelocationType(DataRefImpl Rel) const override
std::error_code getOrdinalBase(uint32_t &Result) const
StringRef getFileFormatName() const override
DataRefImpl getRawDataRefImpl() const
unsigned getSectionID(SectionRef Sec) const
support::ulittle32_t VirtualAddress
support::ulittle32_t SymbolTableIndex
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
StringRef getRelocationTypeName(uint16_t Type) const
import_directory_iterator import_directory_end() const
uint16_t getMachine() const
friend class ImportDirectoryEntryRef
std::error_code isOrdinal(bool &Result) const
void sort(IteratorTy Start, IteratorTy End)
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
const coff_aux_weak_external * getWeakExternal() const
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
imported_symbol_iterator imported_symbol_begin() const
void setOffset(uint32_t Off)
static ErrorSuccess success()
Create a success value.
support::ulittle32_t PointerToRawData
friend class RelocationRef
iterator_range< import_directory_iterator > import_directories() const
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
Align max(MaybeAlign Lhs, Align Rhs)
Expected< const coff_resource_dir_table & > getEntrySubDir(const coff_resource_dir_entry &Entry)
uint32_t getNumberOfSections() const
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
Expected< ArrayRef< UTF16 > > getEntryNameString(const coff_resource_dir_entry &Entry)
basic_symbol_iterator symbol_begin() const override
static bool decodeBase64StringEntry(StringRef Str, uint32_t &Result)
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool isSectionData(DataRefImpl Sec) const override
uint64_t getSymbolValue(DataRefImpl Symb) const
std::error_code getForwardTo(StringRef &Result) const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const
content_iterator< BasicSymbolRef > basic_symbol_iterator
std::error_code getExportRVA(uint32_t &Result) const
A range adaptor for a pair of iterators.
std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const
section_iterator section_end() const override
support::ulittle32_t AddressOfRawData
size_t getSymbolTableEntrySize() const
Expected< uint64_t > getStartAddress() const override
support::ulittle32_t Size
std::error_code getDataDirectory(uint32_t index, const data_directory *&Res) const
Expected< const coff_resource_dir_entry & > getTableEntry(const coff_resource_dir_table &Table, uint32_t Index)
Triple::ArchType getArch() const override
This is a value type class that represents a single symbol in the list of symbols in the object file...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
support::ulittle32_t Zeroes
StringRef mapDebugSectionName(StringRef Name) const override
Maps a debug section name to a standard DWARF section name.
ArrayRef< coff_relocation > getRelocations(const coff_section *Sec) const
bool operator==(const ExportDirectoryEntryRef &Other) const
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
bool isWeakExternal() const
bool isSectionText(DataRefImpl Sec) const override
Merge contiguous icmps into a memcmp
std::error_code getImportTableEntry(const coff_import_directory_table_entry *&Result) const
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Expected< const coff_resource_dir_table & > getBaseTable()
detail::packed_endian_specific_integral< int16_t, little, unaligned > little16_t
support::ulittle32_t AddressTableEntries
iterator_range< export_directory_iterator > export_directories() const
static const char PEMagic[]
support::ulittle32_t DataRVA
bool isAnyUndefined() const
bool isSectionVirtual(DataRefImpl Sec) const override
static imported_symbol_iterator importedSymbolEnd(uint32_t RVA, const COFFObjectFile *Object)
ArrayRef< uint8_t > getSymbolAuxData(COFFSymbolRef Symbol) const
uint64_t getSectionSize(DataRefImpl Sec) const override
iterator_range< imported_symbol_iterator > lookup_table_symbols() const
uint8_t NumberOfAuxSymbols
support::ulittle32_t SizeOfData
bool isSectionBSS(DataRefImpl Sec) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uintptr_t getSymbolTable() const
bool isFileRecord() const
LLVM Value Representation.
content_iterator< BaseRelocRef > base_reloc_iterator
Lightweight error class with error context and mandatory checking.
imported_symbol_iterator imported_symbol_end() const
content_iterator< RelocationRef > relocation_iterator
import_lookup_table_entry< support::little32_t > import_lookup_table_entry32
std::error_code getImportAddressTableRVA(uint32_t &Result) const
uint32_t getValue() const
print Instructions which execute on loop entry
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
bool operator==(const ImportDirectoryEntryRef &Other) const
std::error_code getImportLookupTableRVA(uint32_t &Result) const
uint32_t getSymbolIndex(COFFSymbolRef Symbol) const
imported_symbol_iterator lookup_table_end() const
uint64_t getSectionIndex(DataRefImpl Sec) const override
unsigned getSymbolSectionID(SymbolRef Sym) const
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
DataRefImpl getRawDataRefImpl() const
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 ...
std::error_code getSymbolName(StringRef &Result) const
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
iterator_range< delay_import_directory_iterator > delay_import_directories() const
This is a value type class that represents a single section in the list of sections in the object fil...
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
uint32_t getNumberOfSymbols() const
support::ulittle32_t Offset
union llvm::object::coff_resource_dir_entry::@285 Identifier
A function that returns a base type.