36 #include <system_error>
39 using namespace object;
56 const uint64_t
Size) {
57 if (Addr + Size < Addr || Addr + Size < Size ||
62 return std::error_code();
70 const uint64_t
Size =
sizeof(
T)) {
71 uintptr_t Addr = uintptr_t(Ptr);
74 Obj =
reinterpret_cast<const T *
>(Addr);
75 return std::error_code();
81 assert(Str.
size() <= 6 &&
"String too long, possible overflow.");
86 while (!Str.
empty()) {
88 if (Str[0] >=
'A' && Str[0] <=
'Z')
89 CharVal = Str[0] -
'A';
90 else if (Str[0] >=
'a' && Str[0] <=
'z')
91 CharVal = Str[0] -
'a' + 26;
92 else if (Str[0] >=
'0' && Str[0] <=
'9')
93 CharVal = Str[0] -
'0' + 52;
94 else if (Str[0] ==
'+')
96 else if (Str[0] ==
'/')
101 Value = (Value * 64) + CharVal;
108 Result =
static_cast<uint32_t>(Value);
112 template <
typename coff_symbol_type>
113 const coff_symbol_type *COFFObjectFile::toSymb(
DataRefImpl Ref)
const {
114 const coff_symbol_type *Addr =
115 reinterpret_cast<const coff_symbol_type *
>(Ref.
p);
120 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(
base());
123 "Symbol did not point to the beginning of a symbol");
137 uintptr_t
Offset = uintptr_t(Addr) - uintptr_t(SectionTable);
139 "Section did not point to the beginning of a section");
146 auto End =
reinterpret_cast<uintptr_t
>(StringTable);
150 Ref.
p =
std::min(reinterpret_cast<uintptr_t>(Symb),
End);
151 }
else if (SymbolTable32) {
154 Ref.
p =
std::min(reinterpret_cast<uintptr_t>(Symb),
End);
189 if (std::error_code EC =
getSection(SectionNumber, Section))
268 Ret.
p =
reinterpret_cast<uintptr_t
>(Sec);
280 Ref.
p =
reinterpret_cast<uintptr_t
>(Sec);
300 return toSec(Sec) - SectionTable;
309 const coff_section *Sec = toSec(Ref);
363 if (Sec->hasExtendedRelocations()) {
364 const coff_relocation *FirstReloc;
365 if (
getObject(FirstReloc, M, reinterpret_cast<const coff_relocation*>(
366 base + Sec->PointerToRelocations)))
369 return FirstReloc->VirtualAddress - 1;
371 return Sec->NumberOfRelocations;
374 static const coff_relocation *
379 auto begin =
reinterpret_cast<const coff_relocation *
>(
380 Base + Sec->PointerToRelocations);
381 if (Sec->hasExtendedRelocations()) {
397 Ret.
p =
reinterpret_cast<uintptr_t
>(
begin);
407 Ret.
p =
reinterpret_cast<uintptr_t
>(
I);
412 std::error_code COFFObjectFile::initSymbolTablePtr() {
419 if (COFFBigObjHeader)
430 const uint8_t *StringTableAddr =
base() + StringTableOffset;
432 if (std::error_code EC =
getObject(StringTableSizePtr,
Data, StringTableAddr))
434 StringTableSize = *StringTableSizePtr;
435 if (std::error_code EC =
436 getObject(StringTable,
Data, StringTableAddr, StringTableSize))
441 if (StringTableSize < 4)
445 if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
447 return std::error_code();
453 else if (PE32PlusHeader)
462 uint64_t Rva = Addr - ImageBase;
463 assert(Rva <= UINT32_MAX);
473 if (SectionStart <= Addr && Addr < SectionEnd) {
474 uint32_t Offset = Addr - SectionStart;
476 return std::error_code();
490 uint32_t OffsetIntoSection = RVA - SectionStart;
491 if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize &&
492 Size <= Section->VirtualSize - OffsetIntoSection) {
497 return std::error_code();
507 uintptr_t IntPtr = 0;
508 if (std::error_code EC =
getRvaPtr(Rva, IntPtr))
510 const uint8_t *Ptr =
reinterpret_cast<const uint8_t *
>(IntPtr);
512 Name =
StringRef(reinterpret_cast<const char *>(Ptr + 2));
513 return std::error_code();
524 if (InfoBytes.
size() <
sizeof(*PDBInfo) + 1)
527 InfoBytes = InfoBytes.
drop_front(
sizeof(*PDBInfo));
528 PDBFileName =
StringRef(reinterpret_cast<const char *>(InfoBytes.
data()),
531 PDBFileName = PDBFileName.
split(
'\0').first;
532 return std::error_code();
544 return std::error_code();
548 std::error_code COFFObjectFile::initImportTablePtr() {
551 const data_directory *DataEntry;
553 return std::error_code();
556 if (DataEntry->RelativeVirtualAddress == 0)
557 return std::error_code();
559 uint32_t ImportTableRva = DataEntry->RelativeVirtualAddress;
563 uintptr_t IntPtr = 0;
564 if (std::error_code EC =
getRvaPtr(ImportTableRva, IntPtr))
568 ImportDirectory =
reinterpret_cast<
569 const coff_import_directory_table_entry *
>(IntPtr);
570 return std::error_code();
574 std::error_code COFFObjectFile::initDelayImportTablePtr() {
575 const data_directory *DataEntry;
577 return std::error_code();
578 if (DataEntry->RelativeVirtualAddress == 0)
579 return std::error_code();
581 uint32_t RVA = DataEntry->RelativeVirtualAddress;
582 NumberOfDelayImportDirectory = DataEntry->Size /
583 sizeof(delay_import_directory_table_entry) - 1;
585 uintptr_t IntPtr = 0;
586 if (std::error_code EC =
getRvaPtr(RVA, IntPtr))
588 DelayImportDirectory =
reinterpret_cast<
589 const delay_import_directory_table_entry *
>(IntPtr);
590 return std::error_code();
594 std::error_code COFFObjectFile::initExportTablePtr() {
597 const data_directory *DataEntry;
599 return std::error_code();
602 if (DataEntry->RelativeVirtualAddress == 0)
603 return std::error_code();
605 uint32_t ExportTableRva = DataEntry->RelativeVirtualAddress;
606 uintptr_t IntPtr = 0;
607 if (std::error_code EC =
getRvaPtr(ExportTableRva, IntPtr))
610 reinterpret_cast<const export_directory_table_entry *
>(IntPtr);
611 return std::error_code();
614 std::error_code COFFObjectFile::initBaseRelocPtr() {
615 const data_directory *DataEntry;
617 return std::error_code();
618 if (DataEntry->RelativeVirtualAddress == 0)
619 return std::error_code();
621 uintptr_t IntPtr = 0;
622 if (std::error_code EC =
getRvaPtr(DataEntry->RelativeVirtualAddress, IntPtr))
624 BaseRelocHeader =
reinterpret_cast<const coff_base_reloc_block_header *
>(
626 BaseRelocEnd =
reinterpret_cast<coff_base_reloc_block_header *
>(
627 IntPtr + DataEntry->Size);
628 return std::error_code();
631 std::error_code COFFObjectFile::initDebugDirectoryPtr() {
633 const data_directory *DataEntry;
635 return std::error_code();
638 if (DataEntry->RelativeVirtualAddress == 0)
639 return std::error_code();
642 if (DataEntry->Size %
sizeof(debug_directory) != 0)
645 uintptr_t IntPtr = 0;
646 if (std::error_code EC =
getRvaPtr(DataEntry->RelativeVirtualAddress, IntPtr))
648 DebugDirectoryBegin =
reinterpret_cast<const debug_directory *
>(IntPtr);
650 DataEntry->RelativeVirtualAddress + DataEntry->Size, IntPtr))
652 DebugDirectoryEnd =
reinterpret_cast<const debug_directory *
>(IntPtr);
653 return std::error_code();
656 std::error_code COFFObjectFile::initLoadConfigPtr() {
658 const data_directory *DataEntry;
660 return std::error_code();
663 if (DataEntry->RelativeVirtualAddress == 0)
664 return std::error_code();
665 uintptr_t IntPtr = 0;
666 if (std::error_code EC =
getRvaPtr(DataEntry->RelativeVirtualAddress, IntPtr))
669 LoadConfig = (
const void *)IntPtr;
670 return std::error_code();
675 COFFBigObjHeader(nullptr), PE32Header(nullptr), PE32PlusHeader(nullptr),
676 DataDirectory(nullptr), SectionTable(nullptr), SymbolTable16(nullptr),
677 SymbolTable32(nullptr), StringTable(nullptr), StringTableSize(0),
678 ImportDirectory(nullptr),
679 DelayImportDirectory(nullptr), NumberOfDelayImportDirectory(0),
680 ExportDirectory(nullptr), BaseRelocHeader(nullptr), BaseRelocEnd(nullptr),
681 DebugDirectoryBegin(nullptr), DebugDirectoryEnd(nullptr) {
691 bool HasPEHeader =
false;
698 if (DH->Magic[0] ==
'M' && DH->Magic[1] ==
'Z') {
699 CurPtr = DH->AddressOfNewExeHeader;
725 COFFHeader =
nullptr;
729 COFFBigObjHeader =
nullptr;
735 EC = std::error_code();
747 const uint8_t *DataDirAddr;
748 uint64_t DataDirSize;
762 if ((EC =
getObject(DataDirectory,
Data, DataDirAddr, DataDirSize)))
775 if ((EC = initSymbolTablePtr())) {
776 SymbolTable16 =
nullptr;
777 SymbolTable32 =
nullptr;
778 StringTable =
nullptr;
790 if ((EC = initImportTablePtr()))
792 if ((EC = initDelayImportTablePtr()))
796 if ((EC = initExportTablePtr()))
800 if ((EC = initBaseRelocPtr()))
804 if ((EC = initDebugDirectoryPtr()))
807 if ((EC = initLoadConfigPtr()))
810 EC = std::error_code();
822 Ret.
p =
reinterpret_cast<uintptr_t
>(StringTable);
827 if (!ImportDirectory)
829 if (ImportDirectory->
isNull())
850 DelayImportDirectory, NumberOfDelayImportDirectory,
this));
859 if (!ExportDirectory)
868 Ret.
p =
reinterpret_cast<uintptr_t
>(SectionTable);
876 Ret.
p =
reinterpret_cast<uintptr_t
>(SectionTable + NumSections);
897 return "COFF-x86-64";
903 return "COFF-<unknown arch>";
944 return std::error_code();
949 Res = PE32PlusHeader;
950 return std::error_code();
957 if (!DataDirectory) {
961 assert(PE32Header || PE32PlusHeader);
964 if (Index >= NumEnt) {
968 Res = &DataDirectory[Index];
969 return std::error_code();
976 return std::error_code();
979 Result = SectionTable + (Index - 1);
980 return std::error_code();
985 std::error_code COFFObjectFile::getString(
uint32_t Offset,
987 if (StringTableSize <= 4)
990 if (Offset >= StringTableSize)
992 Result =
StringRef(StringTable + Offset);
993 return std::error_code();
1004 if (Symbol->Name.Offset.Zeroes == 0) {
1005 if (std::error_code EC = getString(Symbol->Name.Offset.Offset, Res))
1007 return std::error_code();
1012 Res =
StringRef(Symbol->Name.ShortName);
1016 return std::error_code();
1021 const uint8_t *Aux =
nullptr;
1026 Aux =
reinterpret_cast<const uint8_t *
>(Symbol.
getRawPtr()) + SymbolSize;
1029 uintptr_t Offset = uintptr_t(Aux) - uintptr_t(
base());
1036 "Aux Symbol data did not point to the beginning of a symbol");
1062 if (std::error_code EC = getString(Offset, Name))
1067 return std::error_code();
1082 return std::min(Sec->VirtualSize, Sec->SizeOfRawData);
1083 return Sec->SizeOfRawData;
1091 if (Sec->PointerToRawData == 0)
1092 return std::error_code();
1096 uintptr_t ConStart = uintptr_t(
base()) + Sec->PointerToRawData;
1100 Res =
makeArrayRef(reinterpret_cast<const uint8_t *>(ConStart), SectionSize);
1101 return std::error_code();
1104 const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel)
const {
1105 return reinterpret_cast<const coff_relocation*
>(Rel.p);
1109 Rel.
p =
reinterpret_cast<uintptr_t
>(
1125 else if (SymbolTable32)
1144 return toSymb<coff_symbol16>(Ref);
1146 return toSymb<coff_symbol32>(Ref);
1154 const coff_relocation *
1168 #define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \
1169 case COFF::reloc_type: \
1170 Res = #reloc_type; \
1179 switch (Reloc->
Type) {
1202 switch (Reloc->
Type) {
1223 switch (Reloc->
Type) {
1246 switch (Reloc->
Type) {
1268 #undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME
1271 return !DataDirectory;
1276 return ImportTable == Other.ImportTable && Index == Other.Index;
1281 if (ImportTable[Index].
isNull()) {
1283 ImportTable =
nullptr;
1289 return getObject(Result, OwningObject->
Data, ImportTable + Index);
1294 uintptr_t Ptr,
int Index) {
1295 if (Object->getBytesInAddress() == 4) {
1305 uintptr_t IntPtr = 0;
1306 Object->getRvaPtr(RVA, IntPtr);
1312 uintptr_t IntPtr = 0;
1313 Object->getRvaPtr(RVA, IntPtr);
1316 if (Object->getBytesInAddress() == 4) {
1317 auto *Entry =
reinterpret_cast<ulittle32_t *
>(IntPtr);
1321 auto *Entry =
reinterpret_cast<ulittle64_t *
>(IntPtr);
1361 uintptr_t IntPtr = 0;
1362 if (std::error_code EC =
1365 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1366 return std::error_code();
1372 return std::error_code();
1378 return std::error_code();
1383 return Table == Other.Table && Index == Other.Index;
1408 uintptr_t IntPtr = 0;
1409 if (std::error_code EC = OwningObject->
getRvaPtr(Table[Index].
Name, IntPtr))
1411 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1412 return std::error_code();
1418 return std::error_code();
1424 AddrIndex * (OwningObject->
is64() ? 8 : 4);
1425 uintptr_t IntPtr = 0;
1426 if (std::error_code EC = OwningObject->
getRvaPtr(RVA, IntPtr))
1428 if (OwningObject->
is64())
1429 Result = *reinterpret_cast<const ulittle64_t *>(IntPtr);
1431 Result = *
reinterpret_cast<const ulittle32_t *
>(IntPtr);
1432 return std::error_code();
1437 return ExportTable == Other.ExportTable && Index == Other.Index;
1447 uintptr_t IntPtr = 0;
1448 if (std::error_code EC =
1451 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1452 return std::error_code();
1459 return std::error_code();
1465 return std::error_code();
1470 uintptr_t IntPtr = 0;
1471 if (std::error_code EC =
1477 return std::error_code();
1484 uintptr_t IntPtr = 0;
1485 if (std::error_code EC =
1496 if (std::error_code EC =
1500 if (std::error_code EC = OwningObject->
getRvaPtr(NamePtr[Offset], IntPtr))
1502 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1503 return std::error_code();
1506 return std::error_code();
1518 Result = (Begin <= RVA && RVA <
End);
1519 return std::error_code();
1526 uintptr_t IntPtr = 0;
1527 if (
auto EC = OwningObject->
getRvaPtr(RVA, IntPtr))
1529 Result =
StringRef(reinterpret_cast<const char *>(IntPtr));
1530 return std::error_code();
1535 return Entry32 == Other.Entry32 && Entry64 == Other.Entry64
1536 && Index == Other.Index;
1549 return std::error_code();
1553 return std::error_code();
1556 uintptr_t IntPtr = 0;
1557 if (std::error_code EC = OwningObject->
getRvaPtr(RVA, IntPtr))
1560 Result =
StringRef(reinterpret_cast<const char *>(IntPtr + 2));
1561 return std::error_code();
1569 return std::error_code();
1577 return std::error_code();
1585 return std::error_code();
1591 return std::error_code();
1595 uintptr_t IntPtr = 0;
1596 if (std::error_code EC = OwningObject->
getRvaPtr(RVA, IntPtr))
1598 Result = *
reinterpret_cast<const ulittle16_t *
>(IntPtr);
1599 return std::error_code();
1608 return std::move(Ret);
1612 return Header == Other.Header && Index == Other.Index;
1626 reinterpret_cast<const uint8_t *
>(Header) + Size);
1635 Type = Entry[Index].
getType();
1636 return std::error_code();
1641 Result = Header->
PageRVA + Entry[Index].getOffset();
1642 return std::error_code();
1645 #define RETURN_IF_ERROR(X) \
1646 if (auto EC = errorToErrorCode(X)) \
1656 return RawDirString;
1661 return getDirStringAtOffset(Entry.
Identifier.getNameOffset());
1665 ResourceSectionRef::getTableAtOffset(
uint32_t Offset) {
1669 Reader.setOffset(Offset);
1671 assert(Table !=
nullptr);
1677 return getTableAtOffset(Entry.
Offset.value());
1681 return getTableAtOffset(0);
std::error_code getRVA(uint32_t &Result) const
uint32_t getNumberOfSections() 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.
bool operator==(const ImportDirectoryEntryRef &Other) const
static uint32_t getNumberOfRelocations(const coff_section *Sec, MemoryBufferRef M, const uint8_t *base)
std::error_code getImportTableEntry(const coff_import_directory_table_entry *&Result) const
Represents either an error or a value T.
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.
section_iterator section_begin() const override
DataRefImpl getRawDataRefImpl() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
iterator_range< imported_symbol_iterator > imported_symbols() const
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
support::ulittle32_t Name
support::ulittle32_t OrdinalBase
const void * getRawPtr() const
std::error_code getDelayImportTable(const delay_import_directory_table_entry *&Result) const
COFFObjectFile(MemoryBufferRef Object, std::error_code &EC)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
uint64_t getRelocationOffset(DataRefImpl Rel) const override
std::error_code getImportAddress(int AddrIndex, uint64_t &Result) const
imported_symbol_iterator imported_symbol_begin() const
const uint8_t * base() const
support::ulittle32_t VirtualAddress
import_directory_iterator import_directory_end() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void moveSectionNext(DataRefImpl &Sec) const override
ErrorOr< const coff_resource_dir_table & > getBaseTable()
static std::error_code getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
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.
void moveRelocationNext(DataRefImpl &Rel) const override
static ErrorOr< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
This class is the base class for all object file types.
content_iterator< DelayImportDirectoryEntryRef > delay_import_directory_iterator
static const coff_relocation * getFirstReloc(const coff_section *Sec, MemoryBufferRef M, const uint8_t *Base)
const char * getBufferStart() const
bool isSectionCompressed(DataRefImpl Sec) const override
uint32_t getValue() const
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
DataRefImpl getRawDataRefImpl() const
std::error_code getImportAddressTableRVA(uint32_t &Result) const
uint32_t getAlignment() const
std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
const coff_section * getCOFFSection(const SectionRef &Section) const
std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override
std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const
static const char BigObjMagic[]
support::ulittle32_t DelayImportAddressTable
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
std::error_code isOrdinal(bool &Result) const
support::ulittle32_t NameRVA
uint16_t getOrdinal() const
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.
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
bool operator==(const ExportDirectoryEntryRef &Other) const
iterator_range< base_reloc_iterator > base_relocs() const
std::error_code getOrdinal(uint32_t &Result) const
Tagged union holding either a T or a Error.
static imported_symbol_iterator importedSymbolBegin(uint32_t RVA, const COFFObjectFile *Object)
iterator_range< import_directory_iterator > import_directories() const
bool isReservedSectionNumber(int32_t SectionNumber)
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.
std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
uint32_t getSymbolFlags(DataRefImpl Symb) const override
std::error_code getName(StringRef &Result) const
uint64_t getSectionAddress(DataRefImpl Sec) const override
iterator_range< const coff_relocation * > getRelocations(const coff_section *Sec) const
std::error_code getSymbolName(StringRef &Result) const
void moveSymbolNext(DataRefImpl &Symb) const override
support::ulittle32_t NamePointerRVA
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
support::ulittle32_t ExportRVA
support::ulittle32_t NameRVA
size_t size() const
size - Get the array size.
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
unsigned getArch() const override
imported_symbol_iterator imported_symbol_end() const
unsigned getSectionID(SectionRef Sec) 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 getForwardTo(StringRef &Result) const
support::ulittle32_t Characteristics
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
content_iterator< ExportDirectoryEntryRef > export_directory_iterator
uint64_t getImageBase() const
bool isFileRecord() 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
uint16_t getMachine() const
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::error_code getDataDirectory(uint32_t index, const data_directory *&Res) const
ErrorOr< ArrayRef< UTF16 > > getEntryNameString(const coff_resource_dir_entry &Entry)
const char * getBufferEnd() const
int32_t getSectionNumber() const
content_iterator< ImportedSymbolRef > imported_symbol_iterator
std::error_code getImportLookupTableRVA(uint32_t &Result) const
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).
import_lookup_table_entry< support::little64_t > import_lookup_table_entry64
export_directory_iterator export_directory_end() const
base_reloc_iterator base_reloc_begin() const
support::ulittle32_t RelativeVirtualAddress
content_iterator< ImportDirectoryEntryRef > import_directory_iterator
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
std::error_code getOrdinal(uint16_t &Result) const
uint8_t getComplexType() const
std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const
static const unsigned End
A function that returns a base type.
support::ulittle32_t ImportAddressTableRVA
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
iterator_range< const debug_directory * > debug_directories() const
support::ulittle16_t Type
support::ulittle32_t OrdinalTableRVA
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
section_iterator_range sections() const
export_directory_iterator export_directory_begin() const
static imported_symbol_iterator makeImportedSymbolIterator(const COFFObjectFile *Object, uintptr_t Ptr, int Index)
uint64_t getRelocationType(DataRefImpl Rel) const override
imported_symbol_iterator lookup_table_end() const
StringRef getFileFormatName() const override
support::ulittle32_t VirtualAddress
support::ulittle32_t SymbolTableIndex
union llvm::object::coff_resource_dir_entry::@224 Offset
size_t getBufferSize() const
friend class ImportDirectoryEntryRef
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
import_directory_iterator import_directory_begin() const
void setOffset(uint32_t Off)
support::ulittle32_t PointerToRawData
friend class RelocationRef
bool isWeakExternal() const
#define RETURN_IF_ERROR(X)
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
basic_symbol_iterator symbol_begin() const override
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...
static bool decodeBase64StringEntry(StringRef Str, uint32_t &Result)
iterator_range< imported_symbol_iterator > lookup_table_symbols() const
imported_symbol_iterator imported_symbol_end() const
bool isSectionData(DataRefImpl Sec) const override
const dos_header * getDOSHeader() const
imported_symbol_iterator lookup_table_begin() const
content_iterator< BasicSymbolRef > basic_symbol_iterator
A range adaptor for a pair of iterators.
section_iterator section_end() const override
support::ulittle32_t AddressOfRawData
delay_import_directory_iterator delay_import_directory_begin() const
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
support::ulittle32_t Size
uint8_t getNumberOfAuxSymbols() const
unsigned getSymbolSectionID(SymbolRef Sym) const
std::error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
std::error_code getHintNameRVA(uint32_t &Result) const
llvm_unreachable("Unknown RegBank!")
const coff_relocation * getCOFFRelocation(const RelocationRef &Reloc) const
imported_symbol_iterator imported_symbol_begin() const
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
delay_import_directory_iterator delay_import_directory_end() const
support::ulittle32_t NumberOfNamePointers
std::error_code getPE32Header(const pe32_header *&Res) const
bool isSectionDefinition() const
iterator_range< imported_symbol_iterator > imported_symbols() const
bool isSectionText(DataRefImpl Sec) const override
bool operator==(const DelayImportDirectoryEntryRef &Other) const
uintptr_t getSymbolTable() const
std::error_code getDllName(StringRef &Result) const
bool operator==(const BaseRelocRef &Other) const
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
uint64_t getSymbolValue(DataRefImpl Symb) const
support::ulittle32_t ImportLookupTableRVA
detail::packed_endian_specific_integral< int16_t, little, unaligned > little16_t
support::ulittle32_t AddressTableEntries
static const char PEMagic[]
size_t getSymbolTableEntrySize() const
iterator_range< export_directory_iterator > export_directories() const
bool isSectionVirtual(DataRefImpl Sec) const override
static imported_symbol_iterator importedSymbolEnd(uint32_t RVA, const COFFObjectFile *Object)
bool operator==(const ImportedSymbolRef &Other) const
uint64_t getSectionSize(DataRefImpl Sec) const override
uint32_t getNumberOfSymbols() const
uint8_t NumberOfAuxSymbols
bool isAnyUndefined() const
support::ulittle32_t SizeOfData
bool isSectionBSS(DataRefImpl Sec) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
base_reloc_iterator base_reloc_end() const
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
std::error_code getSymbolName(StringRef &Result) const
std::error_code getOrdinalBase(uint32_t &Result) const
LLVM Value Representation.
support::ulittle32_t ExportAddressTableRVA
content_iterator< BaseRelocRef > base_reloc_iterator
content_iterator< RelocationRef > relocation_iterator
import_lookup_table_entry< support::little32_t > import_lookup_table_entry32
static std::error_code checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
union llvm::object::coff_resource_dir_entry::@223 Identifier
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
std::error_code getType(uint8_t &Type) const
uint32_t getPointerToSymbolTable() const
std::error_code getName(StringRef &Result) const
uint32_t getHintNameRVA() const
ArrayRef< uint8_t > getSymbolAuxData(COFFSymbolRef Symbol) const
std::error_code getSection(int32_t index, const coff_section *&Res) const
std::error_code isForwarder(bool &Result) const
uint64_t getSectionIndex(DataRefImpl Sec) const override
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 getExportRVA(uint32_t &Result) 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.
iterator_range< delay_import_directory_iterator > delay_import_directories() const
ErrorOr< const coff_resource_dir_table & > getEntrySubDir(const coff_resource_dir_entry &Entry)
DataRefImpl getRawDataRefImpl() const