36 #include <system_error> 60 const uint64_t
Size =
sizeof(
T)) {
61 uintptr_t Addr = uintptr_t(Ptr);
64 Obj =
reinterpret_cast<const T *
>(Addr);
65 return std::error_code();
71 assert(Str.
size() <= 6 &&
"String too long, possible overflow.");
76 while (!Str.
empty()) {
78 if (Str[0] >=
'A' && Str[0] <=
'Z')
79 CharVal = Str[0] -
'A';
80 else if (Str[0] >=
'a' && Str[0] <=
'z')
81 CharVal = Str[0] -
'a' + 26;
82 else if (Str[0] >=
'0' && Str[0] <=
'9')
83 CharVal = Str[0] -
'0' + 52;
84 else if (Str[0] ==
'+')
86 else if (Str[0] ==
'/')
91 Value = (Value * 64) + CharVal;
98 Result =
static_cast<uint32_t>(Value);
102 template <
typename coff_symbol_type>
103 const coff_symbol_type *COFFObjectFile::toSymb(
DataRefImpl Ref)
const {
104 const coff_symbol_type *Addr =
105 reinterpret_cast<const coff_symbol_type *
>(Ref.
p);
110 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(
base());
113 "Symbol did not point to the beginning of a symbol");
127 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(SectionTable);
129 "Section did not point to the beginning of a section");
136 auto End =
reinterpret_cast<uintptr_t
>(StringTable);
140 Ref.
p = std::min(reinterpret_cast<uintptr_t>(Symb), End);
141 }
else if (SymbolTable32) {
144 Ref.
p = std::min(reinterpret_cast<uintptr_t>(Symb), End);
179 if (std::error_code EC =
getSection(SectionNumber, Section))
258 Ret.
p =
reinterpret_cast<uintptr_t
>(Sec);
270 Ref.
p =
reinterpret_cast<uintptr_t
>(Sec);
290 return toSec(Sec) - SectionTable;
353 if (Sec->hasExtendedRelocations()) {
354 const coff_relocation *FirstReloc;
355 if (
getObject(FirstReloc, M, reinterpret_cast<const coff_relocation*>(
356 base + Sec->PointerToRelocations)))
359 return FirstReloc->VirtualAddress - 1;
361 return Sec->NumberOfRelocations;
364 static const coff_relocation *
369 auto begin =
reinterpret_cast<const coff_relocation *
>(
370 Base + Sec->PointerToRelocations);
371 if (Sec->hasExtendedRelocations()) {
377 sizeof(coff_relocation) * NumRelocs))
388 Ret.
p =
reinterpret_cast<uintptr_t
>(
begin);
398 Ret.
p =
reinterpret_cast<uintptr_t
>(
I);
403 std::error_code COFFObjectFile::initSymbolTablePtr() {
410 if (COFFBigObjHeader)
421 const uint8_t *StringTableAddr =
base() + StringTableOffset;
423 if (std::error_code EC =
getObject(StringTableSizePtr,
Data, StringTableAddr))
425 StringTableSize = *StringTableSizePtr;
426 if (std::error_code EC =
427 getObject(StringTable,
Data, StringTableAddr, StringTableSize))
432 if (StringTableSize < 4)
436 if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
438 return std::error_code();
444 else if (PE32PlusHeader)
453 uint64_t Rva = Addr - ImageBase;
454 assert(Rva <= UINT32_MAX);
464 if (SectionStart <= Addr && Addr < SectionEnd) {
467 return std::error_code();
481 uint32_t OffsetIntoSection = RVA - SectionStart;
482 if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize &&
483 Size <= Section->VirtualSize - OffsetIntoSection) {
488 return std::error_code();
498 uintptr_t IntPtr = 0;
499 if (std::error_code EC =
getRvaPtr(Rva, IntPtr))
501 const uint8_t *Ptr =
reinterpret_cast<const uint8_t *
>(IntPtr);
502 Hint = *
reinterpret_cast<const ulittle16_t *
>(Ptr);
503 Name =
StringRef(reinterpret_cast<const char *>(Ptr + 2));
504 return std::error_code();
515 if (InfoBytes.
size() <
sizeof(*PDBInfo) + 1)
518 InfoBytes = InfoBytes.
drop_front(
sizeof(*PDBInfo));
519 PDBFileName =
StringRef(reinterpret_cast<const char *>(InfoBytes.
data()),
522 PDBFileName = PDBFileName.
split(
'\0').first;
523 return std::error_code();
535 return std::error_code();
539 std::error_code COFFObjectFile::initImportTablePtr() {
544 return std::error_code();
548 return std::error_code();
554 uintptr_t IntPtr = 0;
555 if (std::error_code EC =
getRvaPtr(ImportTableRva, IntPtr))
559 ImportDirectory =
reinterpret_cast< 561 return std::error_code();
565 std::error_code COFFObjectFile::initDelayImportTablePtr() {
568 return std::error_code();
570 return std::error_code();
573 NumberOfDelayImportDirectory = DataEntry->
Size /
576 uintptr_t IntPtr = 0;
577 if (std::error_code EC =
getRvaPtr(RVA, IntPtr))
579 DelayImportDirectory =
reinterpret_cast< 581 return std::error_code();
585 std::error_code COFFObjectFile::initExportTablePtr() {
590 return std::error_code();
594 return std::error_code();
597 uintptr_t IntPtr = 0;
598 if (std::error_code EC =
getRvaPtr(ExportTableRva, IntPtr))
602 return std::error_code();
605 std::error_code COFFObjectFile::initBaseRelocPtr() {
608 return std::error_code();
610 return std::error_code();
612 uintptr_t IntPtr = 0;
618 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);
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>";
941 return std::error_code();
946 Res = PE32PlusHeader;
947 return std::error_code();
954 if (!DataDirectory) {
958 assert(PE32Header || PE32PlusHeader);
961 if (Index >= NumEnt) {
965 Res = &DataDirectory[
Index];
966 return std::error_code();
973 return std::error_code();
976 Result = SectionTable + (Index - 1);
977 return std::error_code();
987 if (std::error_code
E =
Section.getName(SecName))
989 if (SecName == SectionName) {
991 return std::error_code();
999 if (StringTableSize <= 4)
1002 if (Offset >= StringTableSize)
1004 Result =
StringRef(StringTable + Offset);
1005 return std::error_code();
1019 return std::error_code();
1028 return std::error_code();
1033 const uint8_t *Aux =
nullptr;
1038 Aux =
reinterpret_cast<const uint8_t *
>(Symbol.
getRawPtr()) + SymbolSize;
1041 uintptr_t Offset = uintptr_t(Aux) - uintptr_t(
base());
1048 "Aux Symbol data did not point to the beginning of a symbol");
1074 if (std::error_code EC = getString(Offset, Name))
1079 return std::error_code();
1104 return std::error_code();
1112 Res =
makeArrayRef(reinterpret_cast<const uint8_t *>(ConStart), SectionSize);
1113 return std::error_code();
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: \ 1179 Res = #reloc_type; \ 1188 switch (Reloc->
Type) {
1211 switch (Reloc->
Type) {
1232 switch (Reloc->
Type) {
1255 switch (Reloc->
Type) {
1277 #undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME 1280 return !DataDirectory;
1285 return ImportTable == Other.ImportTable && Index == Other.Index;
1290 if (ImportTable[Index].isNull()) {
1292 ImportTable =
nullptr;
1298 return getObject(Result, OwningObject->Data, ImportTable + Index);
1303 uintptr_t Ptr,
int Index) {
1304 if (Object->getBytesInAddress() == 4) {
1314 uintptr_t IntPtr = 0;
1315 Object->getRvaPtr(RVA, IntPtr);
1321 uintptr_t IntPtr = 0;
1322 Object->getRvaPtr(RVA, IntPtr);
1325 if (Object->getBytesInAddress() == 4) {
1326 auto *Entry =
reinterpret_cast<ulittle32_t *
>(IntPtr);
1330 auto *Entry =
reinterpret_cast<ulittle64_t *
>(IntPtr);
1351 return make_range(imported_symbol_begin(), imported_symbol_end());
1366 return make_range(lookup_table_begin(), lookup_table_end());
1370 uintptr_t IntPtr = 0;
1371 if (std::error_code EC =
1372 OwningObject->getRvaPtr(ImportTable[Index].NameRVA, IntPtr))
1374 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1375 return std::error_code();
1380 Result = ImportTable[
Index].ImportLookupTableRVA;
1381 return std::error_code();
1386 Result = ImportTable[
Index].ImportAddressTableRVA;
1387 return std::error_code();
1392 return Table == Other.Table && Index == Other.Index;
1413 return make_range(imported_symbol_begin(), imported_symbol_end());
1417 uintptr_t IntPtr = 0;
1418 if (std::error_code EC = OwningObject->getRvaPtr(Table[Index].Name, IntPtr))
1420 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1421 return std::error_code();
1427 return std::error_code();
1433 AddrIndex * (OwningObject->is64() ? 8 : 4);
1434 uintptr_t IntPtr = 0;
1435 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1437 if (OwningObject->is64())
1438 Result = *reinterpret_cast<const ulittle64_t *>(IntPtr);
1440 Result = *
reinterpret_cast<const ulittle32_t *
>(IntPtr);
1441 return std::error_code();
1446 return ExportTable == Other.ExportTable && Index == Other.Index;
1456 uintptr_t IntPtr = 0;
1457 if (std::error_code EC =
1458 OwningObject->getRvaPtr(ExportTable->NameRVA, IntPtr))
1460 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1461 return std::error_code();
1467 Result = ExportTable->OrdinalBase;
1468 return std::error_code();
1473 Result = ExportTable->OrdinalBase +
Index;
1474 return std::error_code();
1479 uintptr_t IntPtr = 0;
1480 if (std::error_code EC =
1481 OwningObject->getRvaPtr(ExportTable->ExportAddressTableRVA, IntPtr))
1486 return std::error_code();
1493 uintptr_t IntPtr = 0;
1494 if (std::error_code EC =
1495 OwningObject->getRvaPtr(ExportTable->OrdinalTableRVA, IntPtr))
1499 uint32_t NumEntries = ExportTable->NumberOfNamePointers;
1505 if (std::error_code EC =
1506 OwningObject->getRvaPtr(ExportTable->NamePointerRVA, IntPtr))
1509 if (std::error_code EC = OwningObject->getRvaPtr(NamePtr[Offset], IntPtr))
1511 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1512 return std::error_code();
1515 return std::error_code();
1523 if (
auto EC = getExportRVA(RVA))
1527 Result = (Begin <= RVA && RVA < End);
1528 return std::error_code();
1533 if (
auto EC = getExportRVA(RVA))
1535 uintptr_t IntPtr = 0;
1536 if (
auto EC = OwningObject->getRvaPtr(RVA, IntPtr))
1538 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1539 return std::error_code();
1544 return Entry32 == Other.Entry32 && Entry64 == Other.Entry64
1545 && Index == Other.Index;
1557 if (Entry32[Index].isOrdinal())
1558 return std::error_code();
1559 RVA = Entry32[
Index].getHintNameRVA();
1561 if (Entry64[Index].isOrdinal())
1562 return std::error_code();
1563 RVA = Entry64[
Index].getHintNameRVA();
1565 uintptr_t IntPtr = 0;
1566 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1569 Result =
StringRef(reinterpret_cast<const char *>(IntPtr + 2));
1570 return std::error_code();
1575 Result = Entry32[
Index].isOrdinal();
1577 Result = Entry64[
Index].isOrdinal();
1578 return std::error_code();
1583 Result = Entry32[
Index].getHintNameRVA();
1585 Result = Entry64[
Index].getHintNameRVA();
1586 return std::error_code();
1592 if (Entry32[Index].isOrdinal()) {
1593 Result = Entry32[
Index].getOrdinal();
1594 return std::error_code();
1596 RVA = Entry32[
Index].getHintNameRVA();
1598 if (Entry64[Index].isOrdinal()) {
1599 Result = Entry64[
Index].getOrdinal();
1600 return std::error_code();
1602 RVA = Entry64[
Index].getHintNameRVA();
1604 uintptr_t IntPtr = 0;
1605 if (std::error_code EC = OwningObject->getRvaPtr(RVA, IntPtr))
1607 Result = *
reinterpret_cast<const ulittle16_t *
>(IntPtr);
1608 return std::error_code();
1617 return std::move(Ret);
1621 return Header == Other.Header && Index == Other.Index;
1629 if (Size == Header->BlockSize) {
1635 reinterpret_cast<const uint8_t *
>(Header) + Size);
1645 return std::error_code();
1650 Result = Header->PageRVA + Entry[
Index].getOffset();
1651 return std::error_code();
1654 #define RETURN_IF_ERROR(E) \ 1659 ResourceSectionRef::getDirStringAtOffset(
uint32_t Offset) {
1666 return RawDirString;
1671 return getDirStringAtOffset(Entry.
Identifier.getNameOffset());
1675 ResourceSectionRef::getTableAtOffset(
uint32_t Offset) {
1681 assert(Table !=
nullptr);
1687 return getTableAtOffset(Entry.
Offset.value());
1691 return getTableAtOffset(0);
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
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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
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.
Compute iterated dominance frontiers using a linear time algorithm.
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.
COFFObjectFile(MemoryBufferRef Object, std::error_code &EC)
uint64_t getRelocationOffset(DataRefImpl Rel) const override
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
static std::error_code getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
union llvm::object::coff_resource_dir_entry::@255 Offset
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
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) 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
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
The access may reference the value stored in memory.
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)
bool isReservedSectionNumber(int32_t SectionNumber)
imported_symbol_iterator lookup_table_begin() const
union llvm::object::coff_symbol_generic::@253 Name
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
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
iterator_range< imported_symbol_iterator > imported_symbols() const
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
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
uint64_t getSectionAddress(DataRefImpl Sec) const override
section_iterator_range sections() const
void moveSymbolNext(DataRefImpl &Symb) const override
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
uint8_t getComplexType() const
support::ulittle32_t ExportRVA
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
union llvm::object::coff_resource_dir_entry::@254 Identifier
std::error_code getRVA(uint32_t &Result) const
static bool checkSize(MemoryBufferRef M, std::error_code &EC, uint64_t Size)
relocation_iterator section_rel_end(DataRefImpl Sec) const override
std::error_code getDelayImportTable(const delay_import_directory_table_entry *&Result) const
support::ulittle32_t Characteristics
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
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.
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
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 getPE32Header(const pe32_header *&Res) const
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.
import_directory_iterator import_directory_end() const
uint16_t getMachine() const
friend class ImportDirectoryEntryRef
std::error_code isOrdinal(bool &Result) const
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)
support::ulittle32_t PointerToRawData
friend class RelocationRef
iterator_range< import_directory_iterator > import_directories() const
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
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")
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
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
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()
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
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[]
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
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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
#define RETURN_IF_ERROR(E)
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
std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const
imported_symbol_iterator lookup_table_end() const
uint64_t getSectionIndex(DataRefImpl Sec) const override
unsigned getSymbolSectionID(SymbolRef Sym) const
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
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
A function that returns a base type.