LLVM 19.0.0git
COFF.h
Go to the documentation of this file.
1//===- COFF.h - COFF object file implementation -----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the COFFObjectFile class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_COFF_H
14#define LLVM_OBJECT_COFF_H
15
18#include "llvm/Object/Binary.h"
20#include "llvm/Object/Error.h"
24#include "llvm/Support/Endian.h"
27#include <cassert>
28#include <cstddef>
29#include <cstdint>
30#include <system_error>
31
32namespace llvm {
33
34template <typename T> class ArrayRef;
35
36namespace object {
37
38class BaseRelocRef;
39class DelayImportDirectoryEntryRef;
40class ExportDirectoryEntryRef;
41class ImportDirectoryEntryRef;
42class ImportedSymbolRef;
43class ResourceSectionRef;
44
51
52/// The DOS compatible header at the front of all PE/COFF executables.
53struct dos_header {
54 char Magic[2];
73};
74
83
84 bool isImportLibrary() const { return NumberOfSections == 0xffff; }
85};
86
93 uint8_t UUID[16];
101};
102
103/// The 32-bit PE header that follows the COFF header.
128 // FIXME: This should be DllCharacteristics.
135 // FIXME: This should be NumberOfRvaAndSizes.
137};
138
139/// The 64-bit PE header that follows the COFF header.
170};
171
175};
176
186};
187
188template <typename IntTy>
190 IntTy Data;
191
192 bool isOrdinal() const { return Data < 0; }
193
195 assert(isOrdinal() && "ILT entry is not an ordinal!");
196 return Data & 0xFFFF;
197 }
198
200 assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
201 return Data & 0xFFFFFFFF;
202 }
203};
204
209
211 // dumpbin reports this field as "Characteristics" instead of "Attributes".
220};
221
234};
235
239};
240
243
247};
248
249template <typename SectionNumberType>
251 union {
255
257 SectionNumberType SectionNumber;
258
260
263};
264
267
268// Contains only common parts of coff_symbol16 and coff_symbol32.
270 union {
275};
276
279
281public:
282 COFFSymbolRef() = default;
283 COFFSymbolRef(const coff_symbol16 *CS) : CS16(CS) {}
284 COFFSymbolRef(const coff_symbol32 *CS) : CS32(CS) {}
285
286 const void *getRawPtr() const {
287 return CS16 ? static_cast<const void *>(CS16) : CS32;
288 }
289
291 if (CS16)
292 return reinterpret_cast<const coff_symbol_generic *>(CS16);
293 return reinterpret_cast<const coff_symbol_generic *>(CS32);
294 }
295
297 return A.getRawPtr() < B.getRawPtr();
298 }
299
300 bool isBigObj() const {
301 if (CS16)
302 return false;
303 if (CS32)
304 return true;
305 llvm_unreachable("COFFSymbolRef points to nothing!");
306 }
307
308 const char *getShortName() const {
309 return CS16 ? CS16->Name.ShortName : CS32->Name.ShortName;
310 }
311
313 assert(isSet() && "COFFSymbolRef points to nothing!");
314 return CS16 ? CS16->Name.Offset : CS32->Name.Offset;
315 }
316
318 assert(isSet() && "COFFSymbolRef points to nothing!");
319 return CS16 ? CS16->Value : CS32->Value;
320 }
321
322 int32_t getSectionNumber() const {
323 assert(isSet() && "COFFSymbolRef points to nothing!");
324 if (CS16) {
325 // Reserved sections are returned as negative numbers.
327 return CS16->SectionNumber;
328 return static_cast<int16_t>(CS16->SectionNumber);
329 }
330 return static_cast<int32_t>(CS32->SectionNumber);
331 }
332
334 assert(isSet() && "COFFSymbolRef points to nothing!");
335 return CS16 ? CS16->Type : CS32->Type;
336 }
337
338 uint8_t getStorageClass() const {
339 assert(isSet() && "COFFSymbolRef points to nothing!");
340 return CS16 ? CS16->StorageClass : CS32->StorageClass;
341 }
342
343 uint8_t getNumberOfAuxSymbols() const {
344 assert(isSet() && "COFFSymbolRef points to nothing!");
345 return CS16 ? CS16->NumberOfAuxSymbols : CS32->NumberOfAuxSymbols;
346 }
347
348 uint8_t getBaseType() const { return getType() & 0x0F; }
349
350 uint8_t getComplexType() const {
351 return (getType() & 0xF0) >> COFF::SCT_COMPLEX_TYPE_SHIFT;
352 }
353
354 template <typename T> const T *getAux() const {
355 return CS16 ? reinterpret_cast<const T *>(CS16 + 1)
356 : reinterpret_cast<const T *>(CS32 + 1);
357 }
358
360 if (!getNumberOfAuxSymbols() ||
362 return nullptr;
363 return getAux<coff_aux_section_definition>();
364 }
365
367 if (!getNumberOfAuxSymbols() ||
369 return nullptr;
370 return getAux<coff_aux_weak_external>();
371 }
372
373 bool isAbsolute() const {
374 return getSectionNumber() == -1;
375 }
376
377 bool isExternal() const {
379 }
380
381 bool isCommon() const {
382 return (isExternal() || isSection()) &&
384 }
385
386 bool isUndefined() const {
388 getValue() == 0;
389 }
390
391 bool isWeakExternal() const {
393 }
394
395 bool isFunctionDefinition() const {
399 }
400
401 bool isFunctionLineInfo() const {
403 }
404
405 bool isAnyUndefined() const {
406 return isUndefined() || isWeakExternal();
407 }
408
409 bool isFileRecord() const {
411 }
412
413 bool isSection() const {
415 }
416
417 bool isSectionDefinition() const {
418 // C++/CLI creates external ABS symbols for non-const appdomain globals.
419 // These are also followed by an auxiliary section definition.
420 bool isAppdomainGlobal =
423 bool isOrdinarySection = getStorageClass() == COFF::IMAGE_SYM_CLASS_STATIC;
425 return false;
426 return isAppdomainGlobal || isOrdinarySection;
427 }
428
429 bool isCLRToken() const {
431 }
432
433private:
434 bool isSet() const { return CS16 || CS32; }
435
436 const coff_symbol16 *CS16 = nullptr;
437 const coff_symbol32 *CS32 = nullptr;
438};
439
451
452 // Returns true if the actual number of relocations is stored in
453 // VirtualAddress field of the first relocation table entry.
456 NumberOfRelocations == UINT16_MAX;
457 }
458
460 // The IMAGE_SCN_TYPE_NO_PAD bit is a legacy way of getting to
461 // IMAGE_SCN_ALIGN_1BYTES.
463 return 1;
464
465 // Bit [20:24] contains section alignment. 0 means use a default alignment
466 // of 16.
467 uint32_t Shift = (Characteristics >> 20) & 0xF;
468 if (Shift > 0)
469 return 1U << (Shift - 1);
470 return 16;
471 }
472};
473
478};
479
485 char Unused1[2];
486};
487
488static_assert(sizeof(coff_aux_function_definition) == 18,
489 "auxiliary entry must be 18 bytes");
490
492 char Unused1[4];
494 char Unused2[6];
496 char Unused3[2];
497};
498
499static_assert(sizeof(coff_aux_bf_and_ef_symbol) == 18,
500 "auxiliary entry must be 18 bytes");
501
505 char Unused1[10];
506};
507
508static_assert(sizeof(coff_aux_weak_external) == 18,
509 "auxiliary entry must be 18 bytes");
510
517 uint8_t Selection;
518 uint8_t Unused;
520 int32_t getNumber(bool IsBigObj) const {
521 uint32_t Number = static_cast<uint32_t>(NumberLowPart);
522 if (IsBigObj)
523 Number |= static_cast<uint32_t>(NumberHighPart) << 16;
524 return static_cast<int32_t>(Number);
525 }
526};
527
528static_assert(sizeof(coff_aux_section_definition) == 18,
529 "auxiliary entry must be 18 bytes");
530
532 uint8_t AuxType;
533 uint8_t Reserved;
535 char MBZ[12];
536};
537
538static_assert(sizeof(coff_aux_clr_token) == 18,
539 "auxiliary entry must be 18 bytes");
540
550
551 int getType() const { return TypeInfo & 0x3; }
552 int getNameType() const { return (TypeInfo >> 2) & 0x7; }
553};
554
561
562 bool isNull() const {
563 return ImportLookupTableRVA == 0 && TimeDateStamp == 0 &&
564 ForwarderChain == 0 && NameRVA == 0 && ImportAddressTableRVA == 0;
565 }
566};
567
568template <typename IntTy>
576
578 // Bit [20:24] contains section alignment.
580 if (Shift > 0)
581 return 1U << (Shift - 1);
582 return 0;
583 }
584
586 uint32_t AlignBits = 0;
587 if (Align) {
588 assert(llvm::isPowerOf2_32(Align) && "alignment is not a power of 2");
589 assert(llvm::Log2_32(Align) <= 13 && "alignment requested is too large");
590 AlignBits = (llvm::Log2_32(Align) + 1) << 20;
591 }
593 (Characteristics & ~COFF::IMAGE_SCN_ALIGN_MASK) | AlignBits;
594 }
595};
596
599
600enum class frame_type : uint16_t { Fpo = 0, Trap = 1, Tss = 2, NonFpo = 3 };
601
607};
608
609/// 32-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY32)
631
632 // Added in MSVC 2015 for /guard:cf.
637 support::ulittle32_t GuardFlags; // coff_guard_flags
638
639 // Added in MSVC 2017
654
655 // Added in MSVC 2019
665};
666
667/// 64-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY64)
689
690 // Added in MSVC 2015 for /guard:cf.
696
697 // Added in MSVC 2017
712
713 // Added in MSVC 2019
723};
724
746};
747
748enum chpe_range_type { Arm64 = 0, Arm64EC = 1, Amd64 = 2 };
749
753
754 // The two low bits of StartOffset contain a range type.
755 static constexpr uint32_t TypeMask = 3;
756
757 uint32_t getStart() const { return StartOffset & ~TypeMask; }
758 uint16_t getType() const { return StartOffset & TypeMask; }
759};
760
765};
766
770};
771
776};
777
781};
782
785
786 int getType() const { return Data >> 12; }
787 int getOffset() const { return Data & ((1 << 12) - 1); }
788};
789
791 union {
794 uint32_t getNameOffset() const {
795 return maskTrailingOnes<uint32_t>(31) & NameOffset;
796 }
797 // Even though the PE/COFF spec doesn't mention this, the high bit of a name
798 // offset is set.
799 void setNameOffset(uint32_t Offset) { NameOffset = Offset | (1 << 31); }
801 union {
804
805 bool isSubDir() const { return SubdirOffset >> 31; }
806 uint32_t value() const {
807 return maskTrailingOnes<uint32_t>(31) & SubdirOffset;
808 }
809
811};
812
818};
819
827};
828
833};
834
836private:
838
841 const coff_file_header *COFFHeader;
842 const coff_bigobj_file_header *COFFBigObjHeader;
843 const pe32_header *PE32Header;
844 const pe32plus_header *PE32PlusHeader;
845 const data_directory *DataDirectory;
846 const coff_section *SectionTable;
847 const coff_symbol16 *SymbolTable16;
848 const coff_symbol32 *SymbolTable32;
849 const char *StringTable;
850 uint32_t StringTableSize;
851 const coff_import_directory_table_entry *ImportDirectory;
852 const delay_import_directory_table_entry *DelayImportDirectory;
853 uint32_t NumberOfDelayImportDirectory;
854 const export_directory_table_entry *ExportDirectory;
855 const coff_base_reloc_block_header *BaseRelocHeader;
856 const coff_base_reloc_block_header *BaseRelocEnd;
857 const debug_directory *DebugDirectoryBegin;
858 const debug_directory *DebugDirectoryEnd;
859 const coff_tls_directory32 *TLSDirectory32;
860 const coff_tls_directory64 *TLSDirectory64;
861 // Either coff_load_configuration32 or coff_load_configuration64.
862 const void *LoadConfig = nullptr;
863 const chpe_metadata *CHPEMetadata = nullptr;
864
865 Expected<StringRef> getString(uint32_t offset) const;
866
867 template <typename coff_symbol_type>
868 const coff_symbol_type *toSymb(DataRefImpl Symb) const;
869 const coff_section *toSec(DataRefImpl Sec) const;
870 const coff_relocation *toRel(DataRefImpl Rel) const;
871
872 // Finish initializing the object and return success or an error.
874
875 Error initSymbolTablePtr();
876 Error initImportTablePtr();
877 Error initDelayImportTablePtr();
878 Error initExportTablePtr();
879 Error initBaseRelocPtr();
880 Error initDebugDirectoryPtr();
881 Error initTLSDirectoryPtr();
882 Error initLoadConfigPtr();
883
884public:
886 create(MemoryBufferRef Object);
887
888 uintptr_t getSymbolTable() const {
889 if (SymbolTable16)
890 return reinterpret_cast<uintptr_t>(SymbolTable16);
891 if (SymbolTable32)
892 return reinterpret_cast<uintptr_t>(SymbolTable32);
893 return uintptr_t(0);
894 }
895
897 if (COFFHeader) {
898 if (CHPEMetadata) {
899 switch (COFFHeader->Machine) {
904 }
905 }
906 return COFFHeader->Machine;
907 }
908 if (COFFBigObjHeader)
909 return COFFBigObjHeader->Machine;
910 llvm_unreachable("no COFF header!");
911 }
912
914 if (COFFHeader)
915 return COFFHeader->isImportLibrary() ? 0
916 : COFFHeader->SizeOfOptionalHeader;
917 // bigobj doesn't have this field.
918 if (COFFBigObjHeader)
919 return 0;
920 llvm_unreachable("no COFF header!");
921 }
922
924 if (COFFHeader)
925 return COFFHeader->isImportLibrary() ? 0 : COFFHeader->Characteristics;
926 // bigobj doesn't have characteristics to speak of,
927 // editbin will silently lie to you if you attempt to set any.
928 if (COFFBigObjHeader)
929 return 0;
930 llvm_unreachable("no COFF header!");
931 }
932
934 if (COFFHeader)
935 return COFFHeader->TimeDateStamp;
936 if (COFFBigObjHeader)
937 return COFFBigObjHeader->TimeDateStamp;
938 llvm_unreachable("no COFF header!");
939 }
940
942 if (COFFHeader)
943 return COFFHeader->isImportLibrary() ? 0 : COFFHeader->NumberOfSections;
944 if (COFFBigObjHeader)
945 return COFFBigObjHeader->NumberOfSections;
946 llvm_unreachable("no COFF header!");
947 }
948
950 if (COFFHeader)
951 return COFFHeader->isImportLibrary() ? 0
952 : COFFHeader->PointerToSymbolTable;
953 if (COFFBigObjHeader)
954 return COFFBigObjHeader->PointerToSymbolTable;
955 llvm_unreachable("no COFF header!");
956 }
957
959 if (COFFHeader)
960 return COFFHeader->isImportLibrary() ? 0 : COFFHeader->NumberOfSymbols;
961 if (COFFBigObjHeader)
962 return COFFBigObjHeader->NumberOfSymbols;
963 llvm_unreachable("no COFF header!");
964 }
965
967 if (!SymbolTable16 && !SymbolTable32)
968 return 0;
969 return getRawNumberOfSymbols();
970 }
971
972 uint32_t getStringTableSize() const { return StringTableSize; }
973
975 return ExportDirectory;
976 }
977
979 assert(!is64());
980 return reinterpret_cast<const coff_load_configuration32 *>(LoadConfig);
981 }
982
984 assert(is64());
985 return reinterpret_cast<const coff_load_configuration64 *>(LoadConfig);
986 }
987
988 const chpe_metadata *getCHPEMetadata() const { return CHPEMetadata; }
989
991
992protected:
993 void moveSymbolNext(DataRefImpl &Symb) const override;
994 Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
996 uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
997 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
998 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
999 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
1002 void moveSectionNext(DataRefImpl &Sec) const override;
1004 uint64_t getSectionAddress(DataRefImpl Sec) const override;
1005 uint64_t getSectionIndex(DataRefImpl Sec) const override;
1006 uint64_t getSectionSize(DataRefImpl Sec) const override;
1008 getSectionContents(DataRefImpl Sec) const override;
1009 uint64_t getSectionAlignment(DataRefImpl Sec) const override;
1010 bool isSectionCompressed(DataRefImpl Sec) const override;
1011 bool isSectionText(DataRefImpl Sec) const override;
1012 bool isSectionData(DataRefImpl Sec) const override;
1013 bool isSectionBSS(DataRefImpl Sec) const override;
1014 bool isSectionVirtual(DataRefImpl Sec) const override;
1015 bool isDebugSection(DataRefImpl Sec) const override;
1018
1019 void moveRelocationNext(DataRefImpl &Rel) const override;
1020 uint64_t getRelocationOffset(DataRefImpl Rel) const override;
1022 uint64_t getRelocationType(DataRefImpl Rel) const override;
1024 SmallVectorImpl<char> &Result) const override;
1025
1026public:
1027 basic_symbol_iterator symbol_begin() const override;
1028 basic_symbol_iterator symbol_end() const override;
1029 section_iterator section_begin() const override;
1030 section_iterator section_end() const override;
1031
1032 bool is64Bit() const override { return false; }
1033
1034 const coff_section *getCOFFSection(const SectionRef &Section) const;
1036 COFFSymbolRef getCOFFSymbol(const SymbolRef &Symbol) const;
1037 const coff_relocation *getCOFFRelocation(const RelocationRef &Reloc) const;
1038 unsigned getSectionID(SectionRef Sec) const;
1039 unsigned getSymbolSectionID(SymbolRef Sym) const;
1040
1041 uint8_t getBytesInAddress() const override;
1042 StringRef getFileFormatName() const override;
1043 Triple::ArchType getArch() const override;
1044 Expected<uint64_t> getStartAddress() const override;
1046 return SubtargetFeatures();
1047 }
1048
1058 return DebugDirectoryBegin;
1059 }
1061 return DebugDirectoryEnd;
1062 }
1063
1071 }
1072
1074 return TLSDirectory32;
1075 }
1077 return TLSDirectory64;
1078 }
1079
1080 const dos_header *getDOSHeader() const {
1081 if (!PE32Header && !PE32PlusHeader)
1082 return nullptr;
1083 return reinterpret_cast<const dos_header *>(base());
1084 }
1085
1086 const coff_file_header *getCOFFHeader() const { return COFFHeader; }
1088 return COFFBigObjHeader;
1089 }
1090 const pe32_header *getPE32Header() const { return PE32Header; }
1091 const pe32plus_header *getPE32PlusHeader() const { return PE32PlusHeader; }
1092
1093 const data_directory *getDataDirectory(uint32_t index) const;
1094 Expected<const coff_section *> getSection(int32_t index) const;
1095
1097 if (index >= getNumberOfSymbols())
1099 if (SymbolTable16)
1100 return COFFSymbolRef(SymbolTable16 + index);
1101 if (SymbolTable32)
1102 return COFFSymbolRef(SymbolTable32 + index);
1104 }
1105
1106 template <typename T>
1107 Error getAuxSymbol(uint32_t index, const T *&Res) const {
1109 if (Error E = S.takeError())
1110 return E;
1111 Res = reinterpret_cast<const T *>(S->getRawPtr());
1112 return Error::success();
1113 }
1114
1117
1119
1121
1123 if (COFFHeader)
1124 return sizeof(coff_symbol16);
1125 if (COFFBigObjHeader)
1126 return sizeof(coff_symbol32);
1127 llvm_unreachable("null symbol table pointer!");
1128 }
1129
1131
1133 uint64_t getSectionSize(const coff_section *Sec) const;
1135 ArrayRef<uint8_t> &Res) const;
1136
1137 uint64_t getImageBase() const;
1138 Error getVaPtr(uint64_t VA, uintptr_t &Res) const;
1139 Error getRvaPtr(uint32_t Rva, uintptr_t &Res,
1140 const char *ErrorContext = nullptr) const;
1141
1142 /// Given an RVA base and size, returns a valid array of bytes or an error
1143 /// code if the RVA and size is not contained completely within a valid
1144 /// section.
1146 ArrayRef<uint8_t> &Contents,
1147 const char *ErrorContext = nullptr) const;
1148
1150 StringRef &Name) const;
1151
1152 /// Get PDB information out of a codeview debug directory entry.
1153 Error getDebugPDBInfo(const debug_directory *DebugDir,
1154 const codeview::DebugInfo *&Info,
1155 StringRef &PDBFileName) const;
1156
1157 /// Get PDB information from an executable. If the information is not present,
1158 /// Info will be set to nullptr and PDBFileName will be empty. An error is
1159 /// returned only on corrupt object files. Convenience accessor that can be
1160 /// used if the debug directory is not already handy.
1162 StringRef &PDBFileName) const;
1163
1164 bool isRelocatableObject() const override;
1165 bool is64() const { return PE32PlusHeader; }
1166
1168
1169 static bool classof(const Binary *v) { return v->isCOFF(); }
1170};
1171
1172// The iterator for the import directory table.
1174public:
1177 uint32_t I, const COFFObjectFile *Owner)
1178 : ImportTable(Table), Index(I), OwningObject(Owner) {}
1179
1180 bool operator==(const ImportDirectoryEntryRef &Other) const;
1181 void moveNext();
1182
1186
1190
1191 Error getName(StringRef &Result) const;
1192 Error getImportLookupTableRVA(uint32_t &Result) const;
1194
1195 Error
1197
1198private:
1199 const coff_import_directory_table_entry *ImportTable;
1201 const COFFObjectFile *OwningObject = nullptr;
1202};
1203
1205public:
1208 uint32_t I, const COFFObjectFile *Owner)
1209 : Table(T), Index(I), OwningObject(Owner) {}
1210
1212 void moveNext();
1213
1217
1218 Error getName(StringRef &Result) const;
1220 const delay_import_directory_table_entry *&Result) const;
1221 Error getImportAddress(int AddrIndex, uint64_t &Result) const;
1222
1223private:
1226 const COFFObjectFile *OwningObject = nullptr;
1227};
1228
1229// The iterator for the export directory table entry.
1231public:
1234 const COFFObjectFile *Owner)
1235 : ExportTable(Table), Index(I), OwningObject(Owner) {}
1236
1237 bool operator==(const ExportDirectoryEntryRef &Other) const;
1238 void moveNext();
1239
1240 Error getDllName(StringRef &Result) const;
1241 Error getOrdinalBase(uint32_t &Result) const;
1242 Error getOrdinal(uint32_t &Result) const;
1243 Error getExportRVA(uint32_t &Result) const;
1244 Error getSymbolName(StringRef &Result) const;
1245
1246 Error isForwarder(bool &Result) const;
1247 Error getForwardTo(StringRef &Result) const;
1248
1249private:
1250 const export_directory_table_entry *ExportTable;
1252 const COFFObjectFile *OwningObject = nullptr;
1253};
1254
1256public:
1259 const COFFObjectFile *Owner)
1260 : Entry32(Entry), Entry64(nullptr), Index(I), OwningObject(Owner) {}
1262 const COFFObjectFile *Owner)
1263 : Entry32(nullptr), Entry64(Entry), Index(I), OwningObject(Owner) {}
1264
1265 bool operator==(const ImportedSymbolRef &Other) const;
1266 void moveNext();
1267
1268 Error getSymbolName(StringRef &Result) const;
1269 Error isOrdinal(bool &Result) const;
1270 Error getOrdinal(uint16_t &Result) const;
1271 Error getHintNameRVA(uint32_t &Result) const;
1272
1273private:
1274 const import_lookup_table_entry32 *Entry32;
1275 const import_lookup_table_entry64 *Entry64;
1277 const COFFObjectFile *OwningObject = nullptr;
1278};
1279
1281public:
1282 BaseRelocRef() = default;
1284 const COFFObjectFile *Owner)
1285 : Header(Header), Index(0) {}
1286
1287 bool operator==(const BaseRelocRef &Other) const;
1288 void moveNext();
1289
1290 Error getType(uint8_t &Type) const;
1291 Error getRVA(uint32_t &Result) const;
1292
1293private:
1294 const coff_base_reloc_block_header *Header;
1296};
1297
1299public:
1302 : BBS(Ref, llvm::endianness::little) {}
1303
1304 Error load(const COFFObjectFile *O);
1305 Error load(const COFFObjectFile *O, const SectionRef &S);
1306
1316
1318
1319private:
1320 BinaryByteStream BBS;
1321
1322 SectionRef Section;
1323 const COFFObjectFile *Obj = nullptr;
1324
1325 std::vector<const coff_relocation *> Relocs;
1326
1329 getTableEntryAtOffset(uint32_t Offset);
1331 getDataEntryAtOffset(uint32_t Offset);
1332 Expected<ArrayRef<UTF16>> getDirStringAtOffset(uint32_t Offset);
1333};
1334
1335// Corresponds to `_FPO_DATA` structure in the PE/COFF spec.
1336struct FpoData {
1337 support::ulittle32_t Offset; // ulOffStart: Offset 1st byte of function code
1338 support::ulittle32_t Size; // cbProcSize: # bytes in function
1339 support::ulittle32_t NumLocals; // cdwLocals: # bytes in locals/4
1340 support::ulittle16_t NumParams; // cdwParams: # bytes in params/4
1342
1343 // cbProlog: # bytes in prolog
1344 int getPrologSize() const { return Attributes & 0xF; }
1345
1346 // cbRegs: # regs saved
1347 int getNumSavedRegs() const { return (Attributes >> 8) & 0x7; }
1348
1349 // fHasSEH: true if seh is func
1350 bool hasSEH() const { return (Attributes >> 9) & 1; }
1351
1352 // fUseBP: true if EBP has been allocated
1353 bool useBP() const { return (Attributes >> 10) & 1; }
1354
1355 // cbFrame: frame pointer
1356 frame_type getFP() const { return static_cast<frame_type>(Attributes >> 14); }
1357};
1358
1360 : public ErrorInfo<SectionStrippedError, BinaryError> {
1361public:
1363};
1364
1365} // end namespace object
1366
1367} // end namespace llvm
1368
1369#endif // LLVM_OBJECT_COFF_H
AMDGPU Mark last scratch load
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
Given that RA is a live value
std::string Name
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define I(x, y, z)
Definition: MD5.cpp:58
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
std::pair< llvm::MachO::Target, std::string > UUID
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
Base class for user error types.
Definition: Error.h:352
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:334
Tagged union holding either a T or a Error.
Definition: Error.h:474
Error takeError()
Take ownership of the stored error.
Definition: Error.h:601
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Manages the enabling and disabling of subtarget specific features.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A range adaptor for a pair of iterators.
BaseRelocRef(const coff_base_reloc_block_header *Header, const COFFObjectFile *Owner)
Definition: COFF.h:1283
Error getType(uint8_t &Type) const
bool operator==(const BaseRelocRef &Other) const
Error getRVA(uint32_t &Result) const
const dos_header * getDOSHeader() const
Definition: COFF.h:1080
uint64_t getSectionSize(DataRefImpl Sec) const override
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
static bool classof(const Binary *v)
Definition: COFF.h:1169
uint64_t getSectionIndex(DataRefImpl Sec) const override
uint32_t getRawNumberOfSymbols() const
Definition: COFF.h:958
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
bool isSectionCompressed(DataRefImpl Sec) const override
const coff_tls_directory64 * getTLSDirectory64() const
Definition: COFF.h:1076
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
const pe32_header * getPE32Header() const
Definition: COFF.h:1090
Expected< COFFSymbolRef > getSymbol(uint32_t index) const
Definition: COFF.h:1096
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
const debug_directory * debug_directory_end() const
Definition: COFF.h:1060
import_directory_iterator import_directory_end() const
const coff_tls_directory32 * getTLSDirectory32() const
Definition: COFF.h:1073
Expected< SubtargetFeatures > getFeatures() const override
Definition: COFF.h:1045
uint32_t getPointerToSymbolTable() const
Definition: COFF.h:949
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
Definition: COFF.h:1069
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
Definition: COFF.h:966
section_iterator section_begin() const override
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
const coff_file_header * getCOFFHeader() const
Definition: COFF.h:1086
size_t getSymbolTableEntrySize() const
Definition: COFF.h:1122
export_directory_iterator export_directory_end() const
Error getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const
Error getAuxSymbol(uint32_t index, const T *&Res) const
Definition: COFF.h:1107
uintptr_t getSymbolTable() const
Definition: COFF.h:888
static Expected< std::unique_ptr< COFFObjectFile > > create(MemoryBufferRef Object)
bool isSectionVirtual(DataRefImpl Sec) const override
unsigned getSectionID(SectionRef Sec) const
const coff_bigobj_file_header * getCOFFBigObjHeader() const
Definition: COFF.h:1087
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...
const coff_load_configuration64 * getLoadConfig64() const
Definition: COFF.h:983
iterator_range< export_directory_iterator > export_directories() const
uint32_t getNumberOfSections() const
Definition: COFF.h:941
uint64_t getRelocationOffset(DataRefImpl Rel) const override
basic_symbol_iterator symbol_begin() const override
uint32_t getTimeDateStamp() const
Definition: COFF.h:933
Triple::ArchType getArch() const override
uint32_t getStringTableSize() const
Definition: COFF.h:972
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
const chpe_metadata * getCHPEMetadata() const
Definition: COFF.h:988
const debug_directory * debug_directory_begin() const
Definition: COFF.h:1057
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
const coff_load_configuration32 * getLoadConfig32() const
Definition: COFF.h:978
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
uint16_t getSizeOfOptionalHeader() const
Definition: COFF.h:913
Error getRvaPtr(uint32_t Rva, uintptr_t &Res, const char *ErrorContext=nullptr) const
uint16_t getCharacteristics() const
Definition: COFF.h:923
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.
const pe32plus_header * getPE32PlusHeader() const
Definition: COFF.h:1091
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
uint64_t getSectionAlignment(DataRefImpl Sec) const override
uint32_t getSymbolIndex(COFFSymbolRef Symbol) const
uint16_t getMachine() const
Definition: COFF.h:896
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
const export_directory_table_entry * getExportTable() const
Definition: COFF.h:974
Expected< uint64_t > getStartAddress() const override
iterator_range< base_reloc_iterator > base_relocs() const
bool isSectionData(DataRefImpl Sec) const override
bool is64Bit() const override
Definition: COFF.h:1032
StringRef getFileFormatName() const override
const void * getRawPtr() const
Definition: COFF.h:286
bool isCommon() const
Definition: COFF.h:381
const StringTableOffset & getStringTableOffset() const
Definition: COFF.h:312
uint8_t getStorageClass() const
Definition: COFF.h:338
uint16_t getType() const
Definition: COFF.h:333
const T * getAux() const
Definition: COFF.h:354
bool isAnyUndefined() const
Definition: COFF.h:405
bool isFileRecord() const
Definition: COFF.h:409
const coff_symbol_generic * getGeneric() const
Definition: COFF.h:290
const coff_aux_weak_external * getWeakExternal() const
Definition: COFF.h:366
bool isAbsolute() const
Definition: COFF.h:373
bool isSectionDefinition() const
Definition: COFF.h:417
uint8_t getComplexType() const
Definition: COFF.h:350
uint8_t getNumberOfAuxSymbols() const
Definition: COFF.h:343
bool isExternal() const
Definition: COFF.h:377
bool isFunctionLineInfo() const
Definition: COFF.h:401
uint8_t getBaseType() const
Definition: COFF.h:348
COFFSymbolRef(const coff_symbol32 *CS)
Definition: COFF.h:284
COFFSymbolRef(const coff_symbol16 *CS)
Definition: COFF.h:283
uint32_t getValue() const
Definition: COFF.h:317
const coff_aux_section_definition * getSectionDefinition() const
Definition: COFF.h:359
bool isWeakExternal() const
Definition: COFF.h:391
friend bool operator<(COFFSymbolRef A, COFFSymbolRef B)
Definition: COFF.h:296
const char * getShortName() const
Definition: COFF.h:308
bool isSection() const
Definition: COFF.h:413
int32_t getSectionNumber() const
Definition: COFF.h:322
bool isCLRToken() const
Definition: COFF.h:429
bool isBigObj() const
Definition: COFF.h:300
bool isUndefined() const
Definition: COFF.h:386
bool isFunctionDefinition() const
Definition: COFF.h:395
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
DelayImportDirectoryEntryRef(const delay_import_directory_table_entry *T, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1207
Error getName(StringRef &Result) const
bool operator==(const ExportDirectoryEntryRef &Other) const
Error getDllName(StringRef &Result) const
ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1233
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
ImportDirectoryEntryRef(const coff_import_directory_table_entry *Table, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1176
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
ImportedSymbolRef(const import_lookup_table_entry32 *Entry, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1258
Error getOrdinal(uint16_t &Result) const
Error getSymbolName(StringRef &Result) const
ImportedSymbolRef(const import_lookup_table_entry64 *Entry, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1261
Error isOrdinal(bool &Result) const
This class is the base class for all object file types.
Definition: ObjectFile.h:229
const uint8_t * base() const
Definition: ObjectFile.h:235
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:52
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)
ResourceSectionRef(StringRef Ref)
Definition: COFF.h:1301
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...
Definition: ObjectFile.h:81
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:168
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
Definition: COFF.h:100
@ IMAGE_FILE_MACHINE_AMD64
Definition: COFF.h:97
@ IMAGE_FILE_MACHINE_ARM64EC
Definition: COFF.h:101
@ IMAGE_FILE_MACHINE_ARM64X
Definition: COFF.h:102
@ IMAGE_SCN_ALIGN_MASK
Definition: COFF.h:328
@ IMAGE_SCN_LNK_NRELOC_OVFL
Definition: COFF.h:329
@ IMAGE_SCN_TYPE_NO_PAD
Definition: COFF.h:301
@ NameSize
Definition: COFF.h:57
@ IMAGE_SYM_CLASS_SECTION
Line number, reformatted as symbol.
Definition: COFF.h:247
@ IMAGE_SYM_CLASS_FUNCTION
".bf" or ".ef" - beginning or end of function
Definition: COFF.h:243
@ IMAGE_SYM_CLASS_EXTERNAL
External symbol.
Definition: COFF.h:223
@ IMAGE_SYM_CLASS_FILE
File name.
Definition: COFF.h:245
@ IMAGE_SYM_CLASS_CLR_TOKEN
External symbol in dmert public lib.
Definition: COFF.h:250
@ IMAGE_SYM_CLASS_WEAK_EXTERNAL
Duplicate tag.
Definition: COFF.h:248
@ IMAGE_SYM_CLASS_STATIC
Static.
Definition: COFF.h:224
const int32_t MaxNumberOfSections16
Definition: COFF.h:32
bool isReservedSectionNumber(int32_t SectionNumber)
Definition: COFF.h:815
@ IMAGE_SYM_TYPE_NULL
No type information or unknown base type.
Definition: COFF.h:254
@ IMAGE_SYM_UNDEFINED
Definition: COFF.h:213
@ IMAGE_SYM_ABSOLUTE
Definition: COFF.h:212
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
Definition: COFF.h:275
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition: COFF.h:279
coff_symbol< support::ulittle32_t > coff_symbol32
Definition: COFF.h:266
coff_symbol< support::ulittle16_t > coff_symbol16
Definition: COFF.h:265
chpe_range_type
Definition: COFF.h:748
@ Arm64EC
Definition: COFF.h:748
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
Definition: Endian.h:266
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
Definition: Endian.h:269
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:313
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:264
@ Ref
The access may reference the value stored in memory.
@ Other
Any other memory.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:103
endianness
Definition: bit.h:70
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
support::ulittle32_t NumLocals
Definition: COFF.h:1339
bool hasSEH() const
Definition: COFF.h:1350
bool useBP() const
Definition: COFF.h:1353
int getNumSavedRegs() const
Definition: COFF.h:1347
support::ulittle32_t Size
Definition: COFF.h:1338
int getPrologSize() const
Definition: COFF.h:1344
frame_type getFP() const
Definition: COFF.h:1356
support::ulittle16_t NumParams
Definition: COFF.h:1340
support::ulittle16_t Attributes
Definition: COFF.h:1341
support::ulittle32_t Offset
Definition: COFF.h:1337
support::ulittle32_t Offset
Definition: COFF.h:246
support::ulittle32_t Zeroes
Definition: COFF.h:245
Definition: COFF.h:761
support::ulittle32_t EntryPoint
Definition: COFF.h:764
support::ulittle32_t StartRva
Definition: COFF.h:762
support::ulittle32_t EndRva
Definition: COFF.h:763
support::ulittle32_t AlternateEntryPoint
Definition: COFF.h:736
support::ulittle32_t SetX64InformationFunctionPointer
Definition: COFF.h:741
support::ulittle32_t ExtraRFETableSize
Definition: COFF.h:743
support::ulittle32_t __os_arm64x_dispatch_ret
Definition: COFF.h:732
support::ulittle32_t __os_arm64x_dispatch_call_no_redirect
Definition: COFF.h:731
support::ulittle32_t RedirectionMetadataCount
Definition: COFF.h:739
support::ulittle32_t __os_arm64x_dispatch_icall_cfg
Definition: COFF.h:735
support::ulittle32_t CodeMap
Definition: COFF.h:727
support::ulittle32_t AuxiliaryIATCopy
Definition: COFF.h:745
support::ulittle32_t __os_arm64x_dispatch_icall
Definition: COFF.h:734
support::ulittle32_t CodeRangesToEntryPointsCount
Definition: COFF.h:738
support::ulittle32_t AuxiliaryIAT
Definition: COFF.h:737
support::ulittle32_t GetX64InformationFunctionPointer
Definition: COFF.h:740
support::ulittle32_t ExtraRFETable
Definition: COFF.h:742
support::ulittle32_t Version
Definition: COFF.h:726
support::ulittle32_t CodeMapCount
Definition: COFF.h:728
support::ulittle32_t __os_arm64x_dispatch_fptr
Definition: COFF.h:744
support::ulittle32_t RedirectionMetadata
Definition: COFF.h:730
support::ulittle32_t CodeRangesToEntryPoints
Definition: COFF.h:729
support::ulittle32_t __os_arm64x_dispatch_call
Definition: COFF.h:733
Definition: COFF.h:750
support::ulittle32_t Length
Definition: COFF.h:752
static constexpr uint32_t TypeMask
Definition: COFF.h:755
support::ulittle32_t StartOffset
Definition: COFF.h:751
uint32_t getStart() const
Definition: COFF.h:757
uint16_t getType() const
Definition: COFF.h:758
Definition: COFF.h:767
support::ulittle32_t Source
Definition: COFF.h:768
support::ulittle32_t Destination
Definition: COFF.h:769
support::ulittle32_t PointerToNextFunction
Definition: COFF.h:495
support::ulittle16_t Linenumber
Definition: COFF.h:493
support::ulittle32_t SymbolTableIndex
Definition: COFF.h:534
support::ulittle32_t PointerToLinenumber
Definition: COFF.h:483
support::ulittle32_t TotalSize
Definition: COFF.h:482
support::ulittle32_t PointerToNextFunction
Definition: COFF.h:484
support::ulittle16_t NumberOfLinenumbers
Definition: COFF.h:514
support::ulittle32_t CheckSum
Definition: COFF.h:515
int32_t getNumber(bool IsBigObj) const
Definition: COFF.h:520
support::ulittle16_t NumberHighPart
Definition: COFF.h:519
support::ulittle16_t NumberLowPart
Definition: COFF.h:516
support::ulittle16_t NumberOfRelocations
Definition: COFF.h:513
support::ulittle32_t Characteristics
Definition: COFF.h:504
support::ulittle32_t TagIndex
Definition: COFF.h:503
Definition: COFF.h:783
support::ulittle16_t Data
Definition: COFF.h:784
int getOffset() const
Definition: COFF.h:787
int getType() const
Definition: COFF.h:786
support::ulittle32_t BlockSize
Definition: COFF.h:780
support::ulittle32_t unused2
Definition: COFF.h:95
support::ulittle16_t Version
Definition: COFF.h:90
support::ulittle32_t PointerToSymbolTable
Definition: COFF.h:99
support::ulittle32_t unused1
Definition: COFF.h:94
support::ulittle16_t Sig1
Definition: COFF.h:88
support::ulittle32_t NumberOfSections
Definition: COFF.h:98
support::ulittle16_t Machine
Definition: COFF.h:91
support::ulittle32_t unused4
Definition: COFF.h:97
support::ulittle32_t unused3
Definition: COFF.h:96
support::ulittle32_t TimeDateStamp
Definition: COFF.h:92
support::ulittle16_t Sig2
Definition: COFF.h:89
support::ulittle32_t NumberOfSymbols
Definition: COFF.h:100
support::ulittle16_t Machine
Definition: COFF.h:76
support::ulittle32_t NumberOfSymbols
Definition: COFF.h:80
support::ulittle16_t Characteristics
Definition: COFF.h:82
support::ulittle32_t PointerToSymbolTable
Definition: COFF.h:79
support::ulittle16_t NumberOfSections
Definition: COFF.h:77
bool isImportLibrary() const
Definition: COFF.h:84
support::ulittle16_t SizeOfOptionalHeader
Definition: COFF.h:81
support::ulittle32_t TimeDateStamp
Definition: COFF.h:78
Definition: COFF.h:555
support::ulittle32_t TimeDateStamp
Definition: COFF.h:557
support::ulittle32_t ImportAddressTableRVA
Definition: COFF.h:560
support::ulittle32_t ForwarderChain
Definition: COFF.h:558
bool isNull() const
Definition: COFF.h:562
support::ulittle32_t NameRVA
Definition: COFF.h:559
support::ulittle32_t ImportLookupTableRVA
Definition: COFF.h:556
support::ulittle16_t TypeInfo
Definition: COFF.h:549
support::ulittle16_t Machine
Definition: COFF.h:545
support::ulittle32_t SizeOfData
Definition: COFF.h:547
support::ulittle16_t Sig2
Definition: COFF.h:543
support::ulittle16_t OrdinalHint
Definition: COFF.h:548
support::ulittle32_t TimeDateStamp
Definition: COFF.h:546
support::ulittle16_t Version
Definition: COFF.h:544
support::ulittle16_t Sig1
Definition: COFF.h:542
32-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY32)
Definition: COFF.h:610
support::ulittle16_t MinorVersion
Definition: COFF.h:614
support::ulittle32_t SEHandlerCount
Definition: COFF.h:630
support::ulittle32_t GuardAddressTakenIatEntryCount
Definition: COFF.h:642
support::ulittle32_t GuardRFFailureRoutineFunctionPointer
Definition: COFF.h:648
support::ulittle32_t DynamicValueRelocTable
Definition: COFF.h:645
support::ulittle32_t GuardCFCheckFunction
Definition: COFF.h:633
support::ulittle32_t GuardRFVerifyStackPointerFunctionPointer
Definition: COFF.h:652
support::ulittle32_t GuardEHContinuationTable
Definition: COFF.h:659
support::ulittle32_t Size
Definition: COFF.h:611
support::ulittle32_t SEHandlerTable
Definition: COFF.h:629
support::ulittle32_t LockPrefixTable
Definition: COFF.h:620
support::ulittle16_t CSDVersion
Definition: COFF.h:625
support::ulittle16_t Reserved2
Definition: COFF.h:651
support::ulittle32_t CHPEMetadataPointer
Definition: COFF.h:646
support::ulittle32_t VirtualMemoryThreshold
Definition: COFF.h:622
support::ulittle32_t GuardCFFunctionCount
Definition: COFF.h:636
support::ulittle32_t DeCommitFreeBlockThreshold
Definition: COFF.h:618
support::ulittle32_t ProcessAffinityMask
Definition: COFF.h:623
support::ulittle32_t MaximumAllocationSize
Definition: COFF.h:621
support::ulittle32_t EnclaveConfigurationPointer
Definition: COFF.h:657
support::ulittle16_t DependentLoadFlags
Definition: COFF.h:626
support::ulittle32_t TimeDateStamp
Definition: COFF.h:612
support::ulittle32_t GuardXFGCheckFunctionPointer
Definition: COFF.h:661
support::ulittle32_t GuardCFCheckDispatch
Definition: COFF.h:634
support::ulittle32_t GuardLongJumpTargetCount
Definition: COFF.h:644
support::ulittle32_t GuardLongJumpTargetTable
Definition: COFF.h:643
support::ulittle32_t Reserved3
Definition: COFF.h:656
support::ulittle32_t GuardAddressTakenIatEntryTable
Definition: COFF.h:641
support::ulittle32_t CriticalSectionDefaultTimeout
Definition: COFF.h:617
support::ulittle32_t GuardEHContinuationCount
Definition: COFF.h:660
support::ulittle16_t DynamicValueRelocTableSection
Definition: COFF.h:650
support::ulittle32_t GuardXFGTableDispatchFunctionPointer
Definition: COFF.h:663
support::ulittle32_t GuardCFFunctionTable
Definition: COFF.h:635
support::ulittle32_t GuardFlags
Definition: COFF.h:637
support::ulittle32_t SecurityCookie
Definition: COFF.h:628
support::ulittle32_t HotPatchTableOffset
Definition: COFF.h:653
coff_load_config_code_integrity CodeIntegrity
Definition: COFF.h:640
support::ulittle16_t MajorVersion
Definition: COFF.h:613
support::ulittle32_t ProcessHeapFlags
Definition: COFF.h:624
support::ulittle32_t GuardXFGDispatchFunctionPointer
Definition: COFF.h:662
support::ulittle32_t GuardRFFailureRoutine
Definition: COFF.h:647
support::ulittle32_t DynamicValueRelocTableOffset
Definition: COFF.h:649
support::ulittle32_t DeCommitTotalFreeThreshold
Definition: COFF.h:619
support::ulittle32_t GlobalFlagsSet
Definition: COFF.h:616
support::ulittle32_t EditList
Definition: COFF.h:627
support::ulittle32_t GlobalFlagsClear
Definition: COFF.h:615
support::ulittle32_t CastGuardOsDeterminedFailureMode
Definition: COFF.h:664
support::ulittle32_t VolatileMetadataPointer
Definition: COFF.h:658
64-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY64)
Definition: COFF.h:668
support::ulittle64_t VirtualMemoryThreshold
Definition: COFF.h:680
support::ulittle32_t TimeDateStamp
Definition: COFF.h:670
support::ulittle64_t GuardCFFunctionCount
Definition: COFF.h:694
support::ulittle32_t GuardFlags
Definition: COFF.h:695
support::ulittle64_t VolatileMetadataPointer
Definition: COFF.h:716
support::ulittle16_t MinorVersion
Definition: COFF.h:672
support::ulittle16_t MajorVersion
Definition: COFF.h:671
support::ulittle64_t GuardRFFailureRoutineFunctionPointer
Definition: COFF.h:706
support::ulittle32_t DynamicValueRelocTableOffset
Definition: COFF.h:707
support::ulittle16_t DependentLoadFlags
Definition: COFF.h:684
support::ulittle16_t Reserved2
Definition: COFF.h:709
support::ulittle32_t GlobalFlagsSet
Definition: COFF.h:674
support::ulittle64_t GuardAddressTakenIatEntryTable
Definition: COFF.h:699
support::ulittle64_t EditList
Definition: COFF.h:685
support::ulittle64_t DeCommitFreeBlockThreshold
Definition: COFF.h:676
support::ulittle64_t GuardXFGCheckFunctionPointer
Definition: COFF.h:719
coff_load_config_code_integrity CodeIntegrity
Definition: COFF.h:698
support::ulittle64_t DynamicValueRelocTable
Definition: COFF.h:703
support::ulittle64_t ProcessAffinityMask
Definition: COFF.h:681
support::ulittle64_t DeCommitTotalFreeThreshold
Definition: COFF.h:677
support::ulittle64_t GuardAddressTakenIatEntryCount
Definition: COFF.h:700
support::ulittle64_t GuardEHContinuationCount
Definition: COFF.h:718
support::ulittle64_t GuardRFFailureRoutine
Definition: COFF.h:705
support::ulittle32_t CriticalSectionDefaultTimeout
Definition: COFF.h:675
support::ulittle64_t GuardCFFunctionTable
Definition: COFF.h:693
support::ulittle64_t GuardLongJumpTargetTable
Definition: COFF.h:701
support::ulittle64_t SEHandlerTable
Definition: COFF.h:687
support::ulittle64_t MaximumAllocationSize
Definition: COFF.h:679
support::ulittle64_t SEHandlerCount
Definition: COFF.h:688
support::ulittle64_t GuardCFCheckFunction
Definition: COFF.h:691
support::ulittle32_t Reserved3
Definition: COFF.h:714
support::ulittle32_t HotPatchTableOffset
Definition: COFF.h:711
support::ulittle64_t GuardCFCheckDispatch
Definition: COFF.h:692
support::ulittle64_t GuardXFGTableDispatchFunctionPointer
Definition: COFF.h:721
support::ulittle64_t SecurityCookie
Definition: COFF.h:686
support::ulittle64_t GuardEHContinuationTable
Definition: COFF.h:717
support::ulittle64_t LockPrefixTable
Definition: COFF.h:678
support::ulittle16_t CSDVersion
Definition: COFF.h:683
support::ulittle64_t CastGuardOsDeterminedFailureMode
Definition: COFF.h:722
support::ulittle32_t GlobalFlagsClear
Definition: COFF.h:673
support::ulittle32_t ProcessHeapFlags
Definition: COFF.h:682
support::ulittle16_t DynamicValueRelocTableSection
Definition: COFF.h:708
support::ulittle64_t CHPEMetadataPointer
Definition: COFF.h:704
support::ulittle64_t GuardXFGDispatchFunctionPointer
Definition: COFF.h:720
support::ulittle64_t GuardRFVerifyStackPointerFunctionPointer
Definition: COFF.h:710
support::ulittle64_t GuardLongJumpTargetCount
Definition: COFF.h:702
support::ulittle64_t EnclaveConfigurationPointer
Definition: COFF.h:715
support::ulittle32_t Size
Definition: COFF.h:669
support::ulittle16_t Type
Definition: COFF.h:477
support::ulittle32_t SymbolTableIndex
Definition: COFF.h:476
support::ulittle32_t VirtualAddress
Definition: COFF.h:475
Definition: COFF.h:813
support::ulittle32_t Reserved
Definition: COFF.h:817
support::ulittle32_t DataSize
Definition: COFF.h:815
support::ulittle32_t Codepage
Definition: COFF.h:816
support::ulittle32_t DataRVA
Definition: COFF.h:814
Definition: COFF.h:790
support::ulittle32_t NameOffset
Definition: COFF.h:792
support::ulittle32_t DataEntryOffset
Definition: COFF.h:802
union llvm::object::coff_resource_dir_entry::@349 Offset
support::ulittle32_t ID
Definition: COFF.h:793
union llvm::object::coff_resource_dir_entry::@348 Identifier
support::ulittle32_t SubdirOffset
Definition: COFF.h:803
support::ulittle16_t NumberOfNameEntries
Definition: COFF.h:825
support::ulittle32_t Characteristics
Definition: COFF.h:821
support::ulittle16_t NumberOfIDEntries
Definition: COFF.h:826
support::ulittle32_t TimeDateStamp
Definition: COFF.h:822
support::ulittle16_t MinorVersion
Definition: COFF.h:824
support::ulittle16_t MajorVersion
Definition: COFF.h:823
support::ulittle32_t BeginAddress
Definition: COFF.h:773
support::ulittle32_t UnwindInformation
Definition: COFF.h:775
support::ulittle32_t EndAddress
Definition: COFF.h:774
support::ulittle32_t PointerToRawData
Definition: COFF.h:445
char Name[COFF::NameSize]
Definition: COFF.h:441
support::ulittle32_t VirtualSize
Definition: COFF.h:442
bool hasExtendedRelocations() const
Definition: COFF.h:454
uint32_t getAlignment() const
Definition: COFF.h:459
support::ulittle32_t Characteristics
Definition: COFF.h:450
support::ulittle16_t NumberOfLinenumbers
Definition: COFF.h:449
support::ulittle32_t SizeOfRawData
Definition: COFF.h:444
support::ulittle32_t VirtualAddress
Definition: COFF.h:443
support::ulittle32_t PointerToRelocations
Definition: COFF.h:446
support::ulittle16_t NumberOfRelocations
Definition: COFF.h:448
support::ulittle32_t PointerToLinenumbers
Definition: COFF.h:447
support::ulittle32_t Value
Definition: COFF.h:274
StringTableOffset Offset
Definition: COFF.h:272
char ShortName[COFF::NameSize]
Definition: COFF.h:271
union llvm::object::coff_symbol_generic::@347 Name
StringTableOffset Offset
Definition: COFF.h:253
SectionNumberType SectionNumber
Definition: COFF.h:257
support::ulittle32_t Value
Definition: COFF.h:256
char ShortName[COFF::NameSize]
Definition: COFF.h:252
support::ulittle16_t Type
Definition: COFF.h:259
uint8_t NumberOfAuxSymbols
Definition: COFF.h:262
union llvm::object::coff_symbol::@346 Name
support::ulittle32_t SizeOfZeroFill
Definition: COFF.h:574
uint32_t getAlignment() const
Definition: COFF.h:577
support::ulittle32_t Characteristics
Definition: COFF.h:575
void setAlignment(uint32_t Align)
Definition: COFF.h:585
support::ulittle32_t RelativeVirtualAddress
Definition: COFF.h:173
support::ulittle32_t Size
Definition: COFF.h:174
support::ulittle16_t MajorVersion
Definition: COFF.h:180
support::ulittle32_t SizeOfData
Definition: COFF.h:183
support::ulittle32_t PointerToRawData
Definition: COFF.h:185
support::ulittle32_t AddressOfRawData
Definition: COFF.h:184
support::ulittle32_t TimeDateStamp
Definition: COFF.h:179
support::ulittle32_t Type
Definition: COFF.h:182
support::ulittle32_t Characteristics
Definition: COFF.h:178
support::ulittle16_t MinorVersion
Definition: COFF.h:181
support::ulittle16_t HashAlgorithm
Definition: COFF.h:832
support::ulittle16_t Version
Definition: COFF.h:831
support::ulittle32_t Magic
Definition: COFF.h:830
Definition: COFF.h:210
support::ulittle32_t DelayImportNameTable
Definition: COFF.h:216
support::ulittle32_t DelayImportAddressTable
Definition: COFF.h:215
support::ulittle32_t Name
Definition: COFF.h:213
support::ulittle32_t UnloadDelayImportTable
Definition: COFF.h:218
support::ulittle32_t BoundDelayImportTable
Definition: COFF.h:217
support::ulittle32_t TimeStamp
Definition: COFF.h:219
support::ulittle32_t Attributes
Definition: COFF.h:212
support::ulittle32_t ModuleHandle
Definition: COFF.h:214
The DOS compatible header at the front of all PE/COFF executables.
Definition: COFF.h:53
support::ulittle16_t AddressOfRelocationTable
Definition: COFF.h:66
support::ulittle16_t NumberOfRelocationItems
Definition: COFF.h:57
support::ulittle16_t InitialSP
Definition: COFF.h:62
support::ulittle16_t HeaderSizeInParagraphs
Definition: COFF.h:58
support::ulittle16_t InitialIP
Definition: COFF.h:64
support::ulittle32_t AddressOfNewExeHeader
Definition: COFF.h:72
support::ulittle16_t MaximumExtraParagraphs
Definition: COFF.h:60
support::ulittle16_t InitialRelativeSS
Definition: COFF.h:61
support::ulittle16_t OEMid
Definition: COFF.h:69
support::ulittle16_t OverlayNumber
Definition: COFF.h:67
support::ulittle16_t UsedBytesInTheLastPage
Definition: COFF.h:55
support::ulittle16_t Reserved[4]
Definition: COFF.h:68
support::ulittle16_t Checksum
Definition: COFF.h:63
support::ulittle16_t FileSizeInPages
Definition: COFF.h:56
support::ulittle16_t OEMinfo
Definition: COFF.h:70
support::ulittle16_t InitialRelativeCS
Definition: COFF.h:65
support::ulittle16_t Reserved2[10]
Definition: COFF.h:71
support::ulittle16_t MinimumExtraParagraphs
Definition: COFF.h:59
Definition: COFF.h:222
support::ulittle32_t OrdinalBase
Definition: COFF.h:228
support::ulittle32_t ExportAddressTableRVA
Definition: COFF.h:231
support::ulittle32_t NameRVA
Definition: COFF.h:227
support::ulittle32_t NumberOfNamePointers
Definition: COFF.h:230
support::ulittle32_t NamePointerRVA
Definition: COFF.h:232
support::ulittle32_t ExportFlags
Definition: COFF.h:223
support::ulittle32_t AddressTableEntries
Definition: COFF.h:229
support::ulittle16_t MinorVersion
Definition: COFF.h:226
support::ulittle16_t MajorVersion
Definition: COFF.h:225
support::ulittle32_t TimeDateStamp
Definition: COFF.h:224
support::ulittle32_t OrdinalTableRVA
Definition: COFF.h:233
Definition: COFF.h:189
bool isOrdinal() const
Definition: COFF.h:192
uint32_t getHintNameRVA() const
Definition: COFF.h:199
IntTy Data
Definition: COFF.h:190
uint16_t getOrdinal() const
Definition: COFF.h:194
The 32-bit PE header that follows the COFF header.
Definition: COFF.h:104
support::ulittle16_t MajorImageVersion
Definition: COFF.h:119
support::ulittle16_t Subsystem
Definition: COFF.h:127
support::ulittle16_t MinorImageVersion
Definition: COFF.h:120
support::ulittle16_t DLLCharacteristics
Definition: COFF.h:129
support::ulittle32_t CheckSum
Definition: COFF.h:126
uint8_t MinorLinkerVersion
Definition: COFF.h:107
support::ulittle32_t SizeOfStackCommit
Definition: COFF.h:131
support::ulittle32_t SizeOfStackReserve
Definition: COFF.h:130
support::ulittle32_t NumberOfRvaAndSize
Definition: COFF.h:136
support::ulittle16_t MinorOperatingSystemVersion
Definition: COFF.h:118
support::ulittle32_t SectionAlignment
Definition: COFF.h:115
support::ulittle32_t SizeOfInitializedData
Definition: COFF.h:109
support::ulittle32_t SizeOfHeapCommit
Definition: COFF.h:133
support::ulittle32_t AddressOfEntryPoint
Definition: COFF.h:111
support::ulittle32_t Win32VersionValue
Definition: COFF.h:123
support::ulittle16_t MinorSubsystemVersion
Definition: COFF.h:122
support::ulittle16_t Magic
Definition: COFF.h:105
support::ulittle32_t BaseOfData
Definition: COFF.h:113
support::ulittle32_t SizeOfImage
Definition: COFF.h:124
support::ulittle32_t BaseOfCode
Definition: COFF.h:112
support::ulittle32_t ImageBase
Definition: COFF.h:114
support::ulittle16_t MajorOperatingSystemVersion
Definition: COFF.h:117
support::ulittle32_t SizeOfHeaders
Definition: COFF.h:125
support::ulittle32_t SizeOfUninitializedData
Definition: COFF.h:110
uint8_t MajorLinkerVersion
Definition: COFF.h:106
support::ulittle32_t FileAlignment
Definition: COFF.h:116
support::ulittle16_t MajorSubsystemVersion
Definition: COFF.h:121
support::ulittle32_t SizeOfCode
Definition: COFF.h:108
support::ulittle32_t SizeOfHeapReserve
Definition: COFF.h:132
support::ulittle32_t LoaderFlags
Definition: COFF.h:134
The 64-bit PE header that follows the COFF header.
Definition: COFF.h:140
support::ulittle16_t MinorOperatingSystemVersion
Definition: COFF.h:153
support::ulittle32_t SizeOfImage
Definition: COFF.h:159
support::ulittle32_t SizeOfCode
Definition: COFF.h:144
support::ulittle16_t MajorImageVersion
Definition: COFF.h:154
support::ulittle32_t SizeOfHeaders
Definition: COFF.h:160
support::ulittle32_t CheckSum
Definition: COFF.h:161
support::ulittle64_t SizeOfStackCommit
Definition: COFF.h:165
support::ulittle32_t SizeOfInitializedData
Definition: COFF.h:145
support::ulittle32_t Win32VersionValue
Definition: COFF.h:158
support::ulittle16_t MajorOperatingSystemVersion
Definition: COFF.h:152
support::ulittle16_t MajorSubsystemVersion
Definition: COFF.h:156
support::ulittle32_t LoaderFlags
Definition: COFF.h:168
support::ulittle16_t MinorImageVersion
Definition: COFF.h:155
support::ulittle32_t AddressOfEntryPoint
Definition: COFF.h:147
support::ulittle16_t MinorSubsystemVersion
Definition: COFF.h:157
support::ulittle32_t FileAlignment
Definition: COFF.h:151
support::ulittle64_t ImageBase
Definition: COFF.h:149
support::ulittle16_t Subsystem
Definition: COFF.h:162
support::ulittle16_t Magic
Definition: COFF.h:141
support::ulittle32_t SizeOfUninitializedData
Definition: COFF.h:146
support::ulittle32_t NumberOfRvaAndSize
Definition: COFF.h:169
support::ulittle32_t BaseOfCode
Definition: COFF.h:148
support::ulittle32_t SectionAlignment
Definition: COFF.h:150
support::ulittle64_t SizeOfHeapReserve
Definition: COFF.h:166
support::ulittle64_t SizeOfStackReserve
Definition: COFF.h:164
support::ulittle16_t DLLCharacteristics
Definition: COFF.h:163
support::ulittle64_t SizeOfHeapCommit
Definition: COFF.h:167
Definition: COFF.h:236
support::ulittle32_t ExportRVA
Definition: COFF.h:237
support::ulittle32_t ForwarderRVA
Definition: COFF.h:238