LLVM  8.0.0svn
COFF.h
Go to the documentation of this file.
1 //===- COFF.h - COFF object file implementation -----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the COFFObjectFile class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_COFF_H
15 #define LLVM_OBJECT_COFF_H
16 
18 #include "llvm/BinaryFormat/COFF.h"
20 #include "llvm/Object/Binary.h"
22 #include "llvm/Object/Error.h"
23 #include "llvm/Object/ObjectFile.h"
26 #include "llvm/Support/Endian.h"
28 #include <cassert>
29 #include <cstddef>
30 #include <cstdint>
31 #include <system_error>
32 
33 namespace llvm {
34 
35 template <typename T> class ArrayRef;
36 
37 namespace object {
38 
39 class BaseRelocRef;
40 class DelayImportDirectoryEntryRef;
41 class ExportDirectoryEntryRef;
42 class ImportDirectoryEntryRef;
43 class ImportedSymbolRef;
44 class ResourceSectionRef;
45 
52 
53 /// The DOS compatible header at the front of all PE/COFF executables.
54 struct dos_header {
55  char Magic[2];
74 };
75 
84 
85  bool isImportLibrary() const { return NumberOfSections == 0xffff; }
86 };
87 
94  uint8_t UUID[16];
102 };
103 
104 /// The 32-bit PE header that follows the COFF header.
105 struct pe32_header {
129  // FIXME: This should be DllCharacteristics.
136  // FIXME: This should be NumberOfRvaAndSizes.
138 };
139 
140 /// The 64-bit PE header that follows the COFF header.
171 };
172 
176 };
177 
187 };
188 
189 template <typename IntTy>
191  IntTy Data;
192 
193  bool isOrdinal() const { return Data < 0; }
194 
195  uint16_t getOrdinal() const {
196  assert(isOrdinal() && "ILT entry is not an ordinal!");
197  return Data & 0xFFFF;
198  }
199 
201  assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
202  return Data & 0xFFFFFFFF;
203  }
204 };
205 
210 
212  // dumpbin reports this field as "Characteristics" instead of "Attributes".
221 };
222 
235 };
236 
240 };
241 
244 
248 };
249 
250 template <typename SectionNumberType>
251 struct coff_symbol {
252  union {
255  } Name;
256 
258  SectionNumberType SectionNumber;
259 
261 
262  uint8_t StorageClass;
264 };
265 
268 
269 // Contains only common parts of coff_symbol16 and coff_symbol32.
271  union {
274  } Name;
276 };
277 
280 
282 public:
283  COFFSymbolRef() = default;
284  COFFSymbolRef(const coff_symbol16 *CS) : CS16(CS) {}
285  COFFSymbolRef(const coff_symbol32 *CS) : CS32(CS) {}
286 
287  const void *getRawPtr() const {
288  return CS16 ? static_cast<const void *>(CS16) : CS32;
289  }
290 
292  if (CS16)
293  return reinterpret_cast<const coff_symbol_generic *>(CS16);
294  return reinterpret_cast<const coff_symbol_generic *>(CS32);
295  }
296 
298  return A.getRawPtr() < B.getRawPtr();
299  }
300 
301  bool isBigObj() const {
302  if (CS16)
303  return false;
304  if (CS32)
305  return true;
306  llvm_unreachable("COFFSymbolRef points to nothing!");
307  }
308 
309  const char *getShortName() const {
310  return CS16 ? CS16->Name.ShortName : CS32->Name.ShortName;
311  }
312 
314  assert(isSet() && "COFFSymbolRef points to nothing!");
315  return CS16 ? CS16->Name.Offset : CS32->Name.Offset;
316  }
317 
318  uint32_t getValue() const { return CS16 ? CS16->Value : CS32->Value; }
319 
320  int32_t getSectionNumber() const {
321  assert(isSet() && "COFFSymbolRef points to nothing!");
322  if (CS16) {
323  // Reserved sections are returned as negative numbers.
324  if (CS16->SectionNumber <= COFF::MaxNumberOfSections16)
325  return CS16->SectionNumber;
326  return static_cast<int16_t>(CS16->SectionNumber);
327  }
328  return static_cast<int32_t>(CS32->SectionNumber);
329  }
330 
331  uint16_t getType() const {
332  assert(isSet() && "COFFSymbolRef points to nothing!");
333  return CS16 ? CS16->Type : CS32->Type;
334  }
335 
336  uint8_t getStorageClass() const {
337  assert(isSet() && "COFFSymbolRef points to nothing!");
338  return CS16 ? CS16->StorageClass : CS32->StorageClass;
339  }
340 
341  uint8_t getNumberOfAuxSymbols() const {
342  assert(isSet() && "COFFSymbolRef points to nothing!");
343  return CS16 ? CS16->NumberOfAuxSymbols : CS32->NumberOfAuxSymbols;
344  }
345 
346  uint8_t getBaseType() const { return getType() & 0x0F; }
347 
348  uint8_t getComplexType() const {
349  return (getType() & 0xF0) >> COFF::SCT_COMPLEX_TYPE_SHIFT;
350  }
351 
352  template <typename T> const T *getAux() const {
353  return CS16 ? reinterpret_cast<const T *>(CS16 + 1)
354  : reinterpret_cast<const T *>(CS32 + 1);
355  }
356 
358  if (!getNumberOfAuxSymbols() ||
359  getStorageClass() != COFF::IMAGE_SYM_CLASS_STATIC)
360  return nullptr;
361  return getAux<coff_aux_section_definition>();
362  }
363 
365  if (!getNumberOfAuxSymbols() ||
366  getStorageClass() != COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL)
367  return nullptr;
368  return getAux<coff_aux_weak_external>();
369  }
370 
371  bool isAbsolute() const {
372  return getSectionNumber() == -1;
373  }
374 
375  bool isExternal() const {
376  return getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL;
377  }
378 
379  bool isCommon() const {
380  return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED &&
381  getValue() != 0;
382  }
383 
384  bool isUndefined() const {
385  return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED &&
386  getValue() == 0;
387  }
388 
389  bool isWeakExternal() const {
390  return getStorageClass() == COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
391  }
392 
393  bool isFunctionDefinition() const {
394  return isExternal() && getBaseType() == COFF::IMAGE_SYM_TYPE_NULL &&
395  getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION &&
396  !COFF::isReservedSectionNumber(getSectionNumber());
397  }
398 
399  bool isFunctionLineInfo() const {
400  return getStorageClass() == COFF::IMAGE_SYM_CLASS_FUNCTION;
401  }
402 
403  bool isAnyUndefined() const {
404  return isUndefined() || isWeakExternal();
405  }
406 
407  bool isFileRecord() const {
408  return getStorageClass() == COFF::IMAGE_SYM_CLASS_FILE;
409  }
410 
411  bool isSection() const {
412  return getStorageClass() == COFF::IMAGE_SYM_CLASS_SECTION;
413  }
414 
415  bool isSectionDefinition() const {
416  // C++/CLI creates external ABS symbols for non-const appdomain globals.
417  // These are also followed by an auxiliary section definition.
418  bool isAppdomainGlobal =
419  getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
420  getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE;
421  bool isOrdinarySection = getStorageClass() == COFF::IMAGE_SYM_CLASS_STATIC;
422  if (!getNumberOfAuxSymbols())
423  return false;
424  return isAppdomainGlobal || isOrdinarySection;
425  }
426 
427  bool isCLRToken() const {
428  return getStorageClass() == COFF::IMAGE_SYM_CLASS_CLR_TOKEN;
429  }
430 
431 private:
432  bool isSet() const { return CS16 || CS32; }
433 
434  const coff_symbol16 *CS16 = nullptr;
435  const coff_symbol32 *CS32 = nullptr;
436 };
437 
438 struct coff_section {
449 
450  // Returns true if the actual number of relocations is stored in
451  // VirtualAddress field of the first relocation table entry.
452  bool hasExtendedRelocations() const {
453  return (Characteristics & COFF::IMAGE_SCN_LNK_NRELOC_OVFL) &&
454  NumberOfRelocations == UINT16_MAX;
455  }
456 
458  // The IMAGE_SCN_TYPE_NO_PAD bit is a legacy way of getting to
459  // IMAGE_SCN_ALIGN_1BYTES.
460  if (Characteristics & COFF::IMAGE_SCN_TYPE_NO_PAD)
461  return 1;
462 
463  // Bit [20:24] contains section alignment. 0 means use a default alignment
464  // of 16.
465  uint32_t Shift = (Characteristics >> 20) & 0xF;
466  if (Shift > 0)
467  return 1U << (Shift - 1);
468  return 16;
469  }
470 };
471 
476 };
477 
483  char Unused1[2];
484 };
485 
486 static_assert(sizeof(coff_aux_function_definition) == 18,
487  "auxiliary entry must be 18 bytes");
488 
490  char Unused1[4];
492  char Unused2[6];
494  char Unused3[2];
495 };
496 
497 static_assert(sizeof(coff_aux_bf_and_ef_symbol) == 18,
498  "auxiliary entry must be 18 bytes");
499 
503  char Unused1[10];
504 };
505 
506 static_assert(sizeof(coff_aux_weak_external) == 18,
507  "auxiliary entry must be 18 bytes");
508 
515  uint8_t Selection;
516  uint8_t Unused;
518  int32_t getNumber(bool IsBigObj) const {
519  uint32_t Number = static_cast<uint32_t>(NumberLowPart);
520  if (IsBigObj)
521  Number |= static_cast<uint32_t>(NumberHighPart) << 16;
522  return static_cast<int32_t>(Number);
523  }
524 };
525 
526 static_assert(sizeof(coff_aux_section_definition) == 18,
527  "auxiliary entry must be 18 bytes");
528 
530  uint8_t AuxType;
531  uint8_t Reserved;
533  char MBZ[12];
534 };
535 
536 static_assert(sizeof(coff_aux_clr_token) == 18,
537  "auxiliary entry must be 18 bytes");
538 
548 
549  int getType() const { return TypeInfo & 0x3; }
550  int getNameType() const { return (TypeInfo >> 2) & 0x7; }
551 };
552 
559 
560  bool isNull() const {
561  return ImportLookupTableRVA == 0 && TimeDateStamp == 0 &&
562  ForwarderChain == 0 && NameRVA == 0 && ImportAddressTableRVA == 0;
563  }
564 };
565 
566 template <typename IntTy>
574 
576  // Bit [20:24] contains section alignment.
577  uint32_t Shift = (Characteristics & 0x00F00000) >> 20;
578  if (Shift > 0)
579  return 1U << (Shift - 1);
580  return 0;
581  }
582 };
583 
586 
587 /// Bits in control flow guard flags as we understand them.
589  CFInstrumented = 0x00000100,
590  HasFidTable = 0x00000400,
591  ProtectDelayLoadIAT = 0x00001000,
592  DelayLoadIATSection = 0x00002000, // Delay load in separate section
593  HasLongJmpTable = 0x00010000,
594  FidTableHasFlags = 0x10000000, // Indicates that fid tables are 5 bytes
595 };
596 
597 enum class frame_type : uint16_t { Fpo = 0, Trap = 1, Tss = 2, NonFpo = 3 };
598 
604 };
605 
606 /// 32-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY32)
628 
629  // Added in MSVC 2015 for /guard:cf.
634  support::ulittle32_t GuardFlags; // coff_guard_flags
635 
636  // Added in MSVC 2017
651 };
652 
653 /// 64-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY64)
675 
676  // Added in MSVC 2015 for /guard:cf.
682 
683  // Added in MSVC 2017
698 };
699 
704 };
705 
709 };
710 
713 
714  int getType() const { return Data >> 12; }
715  int getOffset() const { return Data & ((1 << 12) - 1); }
716 };
717 
719  union {
722  uint32_t getNameOffset() const {
723  return maskTrailingOnes<uint32_t>(31) & NameOffset;
724  }
725  // Even though the PE/COFF spec doesn't mention this, the high bit of a name
726  // offset is set.
727  void setNameOffset(uint32_t Offset) { NameOffset = Offset | (1 << 31); }
728  } Identifier;
729  union {
732 
733  bool isSubDir() const { return SubdirOffset >> 31; }
734  uint32_t value() const {
735  return maskTrailingOnes<uint32_t>(31) & SubdirOffset;
736  }
737 
738  } Offset;
739 };
740 
746 };
747 
755 };
756 
761 };
762 
763 class COFFObjectFile : public ObjectFile {
764 private:
767  const coff_file_header *COFFHeader;
768  const coff_bigobj_file_header *COFFBigObjHeader;
769  const pe32_header *PE32Header;
770  const pe32plus_header *PE32PlusHeader;
771  const data_directory *DataDirectory;
772  const coff_section *SectionTable;
773  const coff_symbol16 *SymbolTable16;
774  const coff_symbol32 *SymbolTable32;
775  const char *StringTable;
776  uint32_t StringTableSize;
777  const coff_import_directory_table_entry *ImportDirectory;
778  const delay_import_directory_table_entry *DelayImportDirectory;
779  uint32_t NumberOfDelayImportDirectory;
780  const export_directory_table_entry *ExportDirectory;
781  const coff_base_reloc_block_header *BaseRelocHeader;
782  const coff_base_reloc_block_header *BaseRelocEnd;
783  const debug_directory *DebugDirectoryBegin;
784  const debug_directory *DebugDirectoryEnd;
785  // Either coff_load_configuration32 or coff_load_configuration64.
786  const void *LoadConfig = nullptr;
787 
788  std::error_code getString(uint32_t offset, StringRef &Res) const;
789 
790  template <typename coff_symbol_type>
791  const coff_symbol_type *toSymb(DataRefImpl Symb) const;
792  const coff_section *toSec(DataRefImpl Sec) const;
793  const coff_relocation *toRel(DataRefImpl Rel) const;
794 
795  std::error_code initSymbolTablePtr();
796  std::error_code initImportTablePtr();
797  std::error_code initDelayImportTablePtr();
798  std::error_code initExportTablePtr();
799  std::error_code initBaseRelocPtr();
800  std::error_code initDebugDirectoryPtr();
801  std::error_code initLoadConfigPtr();
802 
803 public:
804  uintptr_t getSymbolTable() const {
805  if (SymbolTable16)
806  return reinterpret_cast<uintptr_t>(SymbolTable16);
807  if (SymbolTable32)
808  return reinterpret_cast<uintptr_t>(SymbolTable32);
809  return uintptr_t(0);
810  }
811 
812  uint16_t getMachine() const {
813  if (COFFHeader)
814  return COFFHeader->Machine;
815  if (COFFBigObjHeader)
816  return COFFBigObjHeader->Machine;
817  llvm_unreachable("no COFF header!");
818  }
819 
820  uint16_t getSizeOfOptionalHeader() const {
821  if (COFFHeader)
822  return COFFHeader->isImportLibrary() ? 0
823  : COFFHeader->SizeOfOptionalHeader;
824  // bigobj doesn't have this field.
825  if (COFFBigObjHeader)
826  return 0;
827  llvm_unreachable("no COFF header!");
828  }
829 
830  uint16_t getCharacteristics() const {
831  if (COFFHeader)
832  return COFFHeader->isImportLibrary() ? 0 : COFFHeader->Characteristics;
833  // bigobj doesn't have characteristics to speak of,
834  // editbin will silently lie to you if you attempt to set any.
835  if (COFFBigObjHeader)
836  return 0;
837  llvm_unreachable("no COFF header!");
838  }
839 
841  if (COFFHeader)
842  return COFFHeader->TimeDateStamp;
843  if (COFFBigObjHeader)
844  return COFFBigObjHeader->TimeDateStamp;
845  llvm_unreachable("no COFF header!");
846  }
847 
849  if (COFFHeader)
850  return COFFHeader->isImportLibrary() ? 0 : COFFHeader->NumberOfSections;
851  if (COFFBigObjHeader)
852  return COFFBigObjHeader->NumberOfSections;
853  llvm_unreachable("no COFF header!");
854  }
855 
857  if (COFFHeader)
858  return COFFHeader->isImportLibrary() ? 0
859  : COFFHeader->PointerToSymbolTable;
860  if (COFFBigObjHeader)
861  return COFFBigObjHeader->PointerToSymbolTable;
862  llvm_unreachable("no COFF header!");
863  }
864 
866  if (COFFHeader)
867  return COFFHeader->isImportLibrary() ? 0 : COFFHeader->NumberOfSymbols;
868  if (COFFBigObjHeader)
869  return COFFBigObjHeader->NumberOfSymbols;
870  llvm_unreachable("no COFF header!");
871  }
872 
874  if (!SymbolTable16 && !SymbolTable32)
875  return 0;
876  return getRawNumberOfSymbols();
877  }
878 
880  assert(!is64());
881  return reinterpret_cast<const coff_load_configuration32 *>(LoadConfig);
882  }
883 
885  assert(is64());
886  return reinterpret_cast<const coff_load_configuration64 *>(LoadConfig);
887  }
888  StringRef getRelocationTypeName(uint16_t Type) const;
889 
890 protected:
891  void moveSymbolNext(DataRefImpl &Symb) const override;
892  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
893  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
894  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
895  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
896  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
897  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
899  Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
900  void moveSectionNext(DataRefImpl &Sec) const override;
901  std::error_code getSectionName(DataRefImpl Sec,
902  StringRef &Res) const override;
903  uint64_t getSectionAddress(DataRefImpl Sec) const override;
904  uint64_t getSectionIndex(DataRefImpl Sec) const override;
905  uint64_t getSectionSize(DataRefImpl Sec) const override;
906  std::error_code getSectionContents(DataRefImpl Sec,
907  StringRef &Res) const override;
908  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
909  bool isSectionCompressed(DataRefImpl Sec) const override;
910  bool isSectionText(DataRefImpl Sec) const override;
911  bool isSectionData(DataRefImpl Sec) const override;
912  bool isSectionBSS(DataRefImpl Sec) const override;
913  bool isSectionVirtual(DataRefImpl Sec) const override;
914  relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
915  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
916 
917  void moveRelocationNext(DataRefImpl &Rel) const override;
918  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
919  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
920  uint64_t getRelocationType(DataRefImpl Rel) const override;
921  void getRelocationTypeName(DataRefImpl Rel,
922  SmallVectorImpl<char> &Result) const override;
923 
924 public:
925  COFFObjectFile(MemoryBufferRef Object, std::error_code &EC);
926 
927  basic_symbol_iterator symbol_begin() const override;
928  basic_symbol_iterator symbol_end() const override;
929  section_iterator section_begin() const override;
930  section_iterator section_end() const override;
931 
932  const coff_section *getCOFFSection(const SectionRef &Section) const;
933  COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const;
934  COFFSymbolRef getCOFFSymbol(const SymbolRef &Symbol) const;
935  const coff_relocation *getCOFFRelocation(const RelocationRef &Reloc) const;
936  unsigned getSectionID(SectionRef Sec) const;
937  unsigned getSymbolSectionID(SymbolRef Sym) const;
938 
939  uint8_t getBytesInAddress() const override;
940  StringRef getFileFormatName() const override;
941  Triple::ArchType getArch() const override;
942  Expected<uint64_t> getStartAddress() const override;
943  SubtargetFeatures getFeatures() const override { return SubtargetFeatures(); }
944 
945  import_directory_iterator import_directory_begin() const;
946  import_directory_iterator import_directory_end() const;
947  delay_import_directory_iterator delay_import_directory_begin() const;
948  delay_import_directory_iterator delay_import_directory_end() const;
949  export_directory_iterator export_directory_begin() const;
950  export_directory_iterator export_directory_end() const;
951  base_reloc_iterator base_reloc_begin() const;
952  base_reloc_iterator base_reloc_end() const;
954  return DebugDirectoryBegin;
955  }
957  return DebugDirectoryEnd;
958  }
959 
960  iterator_range<import_directory_iterator> import_directories() const;
962  delay_import_directories() const;
963  iterator_range<export_directory_iterator> export_directories() const;
964  iterator_range<base_reloc_iterator> base_relocs() const;
966  return make_range(debug_directory_begin(), debug_directory_end());
967  }
968 
969  const dos_header *getDOSHeader() const {
970  if (!PE32Header && !PE32PlusHeader)
971  return nullptr;
972  return reinterpret_cast<const dos_header *>(base());
973  }
974  std::error_code getPE32Header(const pe32_header *&Res) const;
975  std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
976  std::error_code getDataDirectory(uint32_t index,
977  const data_directory *&Res) const;
978  std::error_code getSection(int32_t index, const coff_section *&Res) const;
979  std::error_code getSection(StringRef SectionName,
980  const coff_section *&Res) const;
981 
982  template <typename coff_symbol_type>
983  std::error_code getSymbol(uint32_t Index,
984  const coff_symbol_type *&Res) const {
985  if (Index >= getNumberOfSymbols())
987 
988  Res = reinterpret_cast<coff_symbol_type *>(getSymbolTable()) + Index;
989  return std::error_code();
990  }
992  if (SymbolTable16) {
993  const coff_symbol16 *Symb = nullptr;
994  if (std::error_code EC = getSymbol(index, Symb))
995  return errorCodeToError(EC);
996  return COFFSymbolRef(Symb);
997  }
998  if (SymbolTable32) {
999  const coff_symbol32 *Symb = nullptr;
1000  if (std::error_code EC = getSymbol(index, Symb))
1001  return errorCodeToError(EC);
1002  return COFFSymbolRef(Symb);
1003  }
1005  }
1006 
1007  template <typename T>
1008  std::error_code getAuxSymbol(uint32_t index, const T *&Res) const {
1010  if (Error E = S.takeError())
1011  return errorToErrorCode(std::move(E));
1012  Res = reinterpret_cast<const T *>(S->getRawPtr());
1013  return std::error_code();
1014  }
1015 
1016  std::error_code getSymbolName(COFFSymbolRef Symbol, StringRef &Res) const;
1017  std::error_code getSymbolName(const coff_symbol_generic *Symbol,
1018  StringRef &Res) const;
1019 
1020  ArrayRef<uint8_t> getSymbolAuxData(COFFSymbolRef Symbol) const;
1021 
1022  size_t getSymbolTableEntrySize() const {
1023  if (COFFHeader)
1024  return sizeof(coff_symbol16);
1025  if (COFFBigObjHeader)
1026  return sizeof(coff_symbol32);
1027  llvm_unreachable("null symbol table pointer!");
1028  }
1029 
1030  ArrayRef<coff_relocation> getRelocations(const coff_section *Sec) const;
1031 
1032  std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
1033  uint64_t getSectionSize(const coff_section *Sec) const;
1034  std::error_code getSectionContents(const coff_section *Sec,
1035  ArrayRef<uint8_t> &Res) const;
1036 
1037  uint64_t getImageBase() const;
1038  std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
1039  std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
1040 
1041  /// Given an RVA base and size, returns a valid array of bytes or an error
1042  /// code if the RVA and size is not contained completely within a valid
1043  /// section.
1044  std::error_code getRvaAndSizeAsBytes(uint32_t RVA, uint32_t Size,
1045  ArrayRef<uint8_t> &Contents) const;
1046 
1047  std::error_code getHintName(uint32_t Rva, uint16_t &Hint,
1048  StringRef &Name) const;
1049 
1050  /// Get PDB information out of a codeview debug directory entry.
1051  std::error_code getDebugPDBInfo(const debug_directory *DebugDir,
1052  const codeview::DebugInfo *&Info,
1053  StringRef &PDBFileName) const;
1054 
1055  /// Get PDB information from an executable. If the information is not present,
1056  /// Info will be set to nullptr and PDBFileName will be empty. An error is
1057  /// returned only on corrupt object files. Convenience accessor that can be
1058  /// used if the debug directory is not already handy.
1059  std::error_code getDebugPDBInfo(const codeview::DebugInfo *&Info,
1060  StringRef &PDBFileName) const;
1061 
1062  bool isRelocatableObject() const override;
1063  bool is64() const { return PE32PlusHeader; }
1064 
1065  static bool classof(const Binary *v) { return v->isCOFF(); }
1066 };
1067 
1068 // The iterator for the import directory table.
1070 public:
1071  ImportDirectoryEntryRef() = default;
1073  uint32_t I, const COFFObjectFile *Owner)
1074  : ImportTable(Table), Index(I), OwningObject(Owner) {}
1075 
1076  bool operator==(const ImportDirectoryEntryRef &Other) const;
1077  void moveNext();
1078 
1079  imported_symbol_iterator imported_symbol_begin() const;
1080  imported_symbol_iterator imported_symbol_end() const;
1081  iterator_range<imported_symbol_iterator> imported_symbols() const;
1082 
1083  imported_symbol_iterator lookup_table_begin() const;
1084  imported_symbol_iterator lookup_table_end() const;
1085  iterator_range<imported_symbol_iterator> lookup_table_symbols() const;
1086 
1087  std::error_code getName(StringRef &Result) const;
1088  std::error_code getImportLookupTableRVA(uint32_t &Result) const;
1089  std::error_code getImportAddressTableRVA(uint32_t &Result) const;
1090 
1091  std::error_code
1092  getImportTableEntry(const coff_import_directory_table_entry *&Result) const;
1093 
1094 private:
1095  const coff_import_directory_table_entry *ImportTable;
1096  uint32_t Index;
1097  const COFFObjectFile *OwningObject = nullptr;
1098 };
1099 
1101 public:
1102  DelayImportDirectoryEntryRef() = default;
1104  uint32_t I, const COFFObjectFile *Owner)
1105  : Table(T), Index(I), OwningObject(Owner) {}
1106 
1107  bool operator==(const DelayImportDirectoryEntryRef &Other) const;
1108  void moveNext();
1109 
1110  imported_symbol_iterator imported_symbol_begin() const;
1111  imported_symbol_iterator imported_symbol_end() const;
1112  iterator_range<imported_symbol_iterator> imported_symbols() const;
1113 
1114  std::error_code getName(StringRef &Result) const;
1115  std::error_code getDelayImportTable(
1116  const delay_import_directory_table_entry *&Result) const;
1117  std::error_code getImportAddress(int AddrIndex, uint64_t &Result) const;
1118 
1119 private:
1121  uint32_t Index;
1122  const COFFObjectFile *OwningObject = nullptr;
1123 };
1124 
1125 // The iterator for the export directory table entry.
1127 public:
1128  ExportDirectoryEntryRef() = default;
1130  const COFFObjectFile *Owner)
1131  : ExportTable(Table), Index(I), OwningObject(Owner) {}
1132 
1133  bool operator==(const ExportDirectoryEntryRef &Other) const;
1134  void moveNext();
1135 
1136  std::error_code getDllName(StringRef &Result) const;
1137  std::error_code getOrdinalBase(uint32_t &Result) const;
1138  std::error_code getOrdinal(uint32_t &Result) const;
1139  std::error_code getExportRVA(uint32_t &Result) const;
1140  std::error_code getSymbolName(StringRef &Result) const;
1141 
1142  std::error_code isForwarder(bool &Result) const;
1143  std::error_code getForwardTo(StringRef &Result) const;
1144 
1145 private:
1146  const export_directory_table_entry *ExportTable;
1147  uint32_t Index;
1148  const COFFObjectFile *OwningObject = nullptr;
1149 };
1150 
1152 public:
1153  ImportedSymbolRef() = default;
1155  const COFFObjectFile *Owner)
1156  : Entry32(Entry), Entry64(nullptr), Index(I), OwningObject(Owner) {}
1158  const COFFObjectFile *Owner)
1159  : Entry32(nullptr), Entry64(Entry), Index(I), OwningObject(Owner) {}
1160 
1161  bool operator==(const ImportedSymbolRef &Other) const;
1162  void moveNext();
1163 
1164  std::error_code getSymbolName(StringRef &Result) const;
1165  std::error_code isOrdinal(bool &Result) const;
1166  std::error_code getOrdinal(uint16_t &Result) const;
1167  std::error_code getHintNameRVA(uint32_t &Result) const;
1168 
1169 private:
1170  const import_lookup_table_entry32 *Entry32;
1171  const import_lookup_table_entry64 *Entry64;
1172  uint32_t Index;
1173  const COFFObjectFile *OwningObject = nullptr;
1174 };
1175 
1177 public:
1178  BaseRelocRef() = default;
1180  const COFFObjectFile *Owner)
1181  : Header(Header), Index(0) {}
1182 
1183  bool operator==(const BaseRelocRef &Other) const;
1184  void moveNext();
1185 
1186  std::error_code getType(uint8_t &Type) const;
1187  std::error_code getRVA(uint32_t &Result) const;
1188 
1189 private:
1190  const coff_base_reloc_block_header *Header;
1191  uint32_t Index;
1192 };
1193 
1195 public:
1196  ResourceSectionRef() = default;
1197  explicit ResourceSectionRef(StringRef Ref) : BBS(Ref, support::little) {}
1198 
1200  getEntryNameString(const coff_resource_dir_entry &Entry);
1202  getEntrySubDir(const coff_resource_dir_entry &Entry);
1204 
1205 private:
1206  BinaryByteStream BBS;
1207 
1209  Expected<ArrayRef<UTF16>> getDirStringAtOffset(uint32_t Offset);
1210 };
1211 
1212 // Corresponds to `_FPO_DATA` structure in the PE/COFF spec.
1213 struct FpoData {
1214  support::ulittle32_t Offset; // ulOffStart: Offset 1st byte of function code
1215  support::ulittle32_t Size; // cbProcSize: # bytes in function
1216  support::ulittle32_t NumLocals; // cdwLocals: # bytes in locals/4
1217  support::ulittle16_t NumParams; // cdwParams: # bytes in params/4
1219 
1220  // cbProlog: # bytes in prolog
1221  int getPrologSize() const { return Attributes & 0xF; }
1222 
1223  // cbRegs: # regs saved
1224  int getNumSavedRegs() const { return (Attributes >> 8) & 0x7; }
1225 
1226  // fHasSEH: true if seh is func
1227  bool hasSEH() const { return (Attributes >> 9) & 1; }
1228 
1229  // fUseBP: true if EBP has been allocated
1230  bool useBP() const { return (Attributes >> 10) & 1; }
1231 
1232  // cbFrame: frame pointer
1233  frame_type getFP() const { return static_cast<frame_type>(Attributes >> 14); }
1234 };
1235 
1236 } // end namespace object
1237 
1238 } // end namespace llvm
1239 
1240 #endif // LLVM_OBJECT_COFF_H
support::ulittle64_t GuardCFFunctionCount
Definition: COFF.h:680
bool isNull() const
Definition: COFF.h:560
uint32_t getAlignment() const
Definition: COFF.h:457
support::ulittle32_t GuardCFFunctionTable
Definition: COFF.h:632
coff_symbol< support::ulittle16_t > coff_symbol16
Definition: COFF.h:266
64-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY64)
Definition: COFF.h:654
support::ulittle64_t SizeOfStackReserve
Definition: COFF.h:165
bool isCommon() const
Definition: COFF.h:379
support::ulittle64_t MaximumAllocationSize
Definition: COFF.h:665
support::ulittle64_t DynamicValueRelocTable
Definition: COFF.h:689
support::ulittle16_t DLLCharacteristics
Definition: COFF.h:130
support::ulittle64_t GuardLongJumpTargetCount
Definition: COFF.h:688
support::ulittle16_t MajorVersion
Definition: COFF.h:751
The 64-bit PE header that follows the COFF header.
Definition: COFF.h:141
support::ulittle32_t HotPatchTableOffset
Definition: COFF.h:697
support::ulittle64_t GuardCFCheckDispatch
Definition: COFF.h:678
support::ulittle16_t Sig1
Definition: COFF.h:540
int getType() const
Definition: COFF.h:714
support::ulittle32_t SizeOfImage
Definition: COFF.h:160
support::ulittle32_t PointerToNextFunction
Definition: COFF.h:493
support::ulittle16_t Machine
Definition: COFF.h:77
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer...
support::ulittle64_t SecurityCookie
Definition: COFF.h:672
support::ulittle64_t DeCommitTotalFreeThreshold
Definition: COFF.h:663
support::ulittle16_t InitialIP
Definition: COFF.h:65
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
support::ulittle32_t SizeOfStackCommit
Definition: COFF.h:132
bool isCLRToken() const
Definition: COFF.h:427
support::ulittle16_t MaximumExtraParagraphs
Definition: COFF.h:61
support::ulittle32_t TimeDateStamp
Definition: COFF.h:555
support::ulittle16_t MajorVersion
Definition: COFF.h:657
support::ulittle16_t MinorOperatingSystemVersion
Definition: COFF.h:154
support::ulittle32_t PointerToLinenumbers
Definition: COFF.h:445
support::ulittle32_t Name
Definition: COFF.h:214
support::ulittle32_t OrdinalBase
Definition: COFF.h:229
support::ulittle32_t CheckSum
Definition: COFF.h:127
support::ulittle32_t SizeOfUninitializedData
Definition: COFF.h:111
support::ulittle32_t GlobalFlagsClear
Definition: COFF.h:612
const debug_directory * debug_directory_begin() const
Definition: COFF.h:953
support::ulittle32_t UnloadDelayImportTable
Definition: COFF.h:219
support::ulittle32_t SizeOfHeaders
Definition: COFF.h:161
support::ulittle32_t VirtualAddress
Definition: COFF.h:441
support::ulittle16_t Reserved[4]
Definition: COFF.h:69
support::ulittle32_t Attributes
Definition: COFF.h:213
support::ulittle32_t GuardCFFunctionCount
Definition: COFF.h:633
Definition: COFF.h:223
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
support::ulittle32_t GuardCFCheckDispatch
Definition: COFF.h:631
support::ulittle64_t GuardAddressTakenIatEntryCount
Definition: COFF.h:686
support::ulittle16_t MajorVersion
Definition: COFF.h:181
support::ulittle32_t TimeDateStamp
Definition: COFF.h:544
support::ulittle16_t NumberOfLinenumbers
Definition: COFF.h:512
support::ulittle32_t CHPEMetadataPointer
Definition: COFF.h:643
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null, or not exclusively derived from constant.
support::ulittle64_t GuardRFVerifyStackPointerFunctionPointer
Definition: COFF.h:696
support::ulittle16_t Version
Definition: COFF.h:91
This class is the base class for all object file types.
Definition: ObjectFile.h:190
uint8_t MajorLinkerVersion
Definition: COFF.h:107
support::ulittle16_t NumberOfSections
Definition: COFF.h:78
uint32_t getPointerToSymbolTable() const
Definition: COFF.h:856
support::ulittle32_t SizeOfImage
Definition: COFF.h:125
support::ulittle32_t PointerToRelocations
Definition: COFF.h:444
32-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY32)
Definition: COFF.h:607
bool isSectionDefinition() const
Definition: COFF.h:415
support::ulittle32_t DynamicValueRelocTableOffset
Definition: COFF.h:646
support::ulittle16_t OrdinalHint
Definition: COFF.h:546
ImportedSymbolRef(const import_lookup_table_entry64 *Entry, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1157
uint8_t getNumberOfAuxSymbols() const
Definition: COFF.h:341
support::ulittle16_t NumberLowPart
Definition: COFF.h:514
Definition: COFF.h:237
Error takeError()
Take ownership of the stored error.
Definition: Error.h:553
detail::packed_endian_specific_integral< uint16_t, little, unaligned > ulittle16_t
Definition: Endian.h:269
support::ulittle16_t Sig2
Definition: COFF.h:541
uint16_t getSizeOfOptionalHeader() const
Definition: COFF.h:820
support::ulittle16_t UsedBytesInTheLastPage
Definition: COFF.h:56
uint16_t getOrdinal() const
Definition: COFF.h:195
support::ulittle32_t SizeOfData
Definition: COFF.h:545
support::ulittle16_t Data
Definition: COFF.h:712
support::ulittle64_t SizeOfHeapCommit
Definition: COFF.h:168
support::ulittle32_t DelayImportAddressTable
Definition: COFF.h:216
iterator_range< const debug_directory * > debug_directories() const
Definition: COFF.h:965
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
Definition: SymbolSize.cpp:34
support::ulittle32_t CheckSum
Definition: COFF.h:513
support::ulittle32_t SecurityCookie
Definition: COFF.h:625
support::ulittle16_t Reserved2
Definition: COFF.h:648
support::ulittle16_t MajorOperatingSystemVersion
Definition: COFF.h:118
bool isCOFF() const
Definition: Binary.h:117
ImportedSymbolRef(const import_lookup_table_entry32 *Entry, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1154
support::ulittle16_t HeaderSizeInParagraphs
Definition: COFF.h:59
amdgpu Simplify well known AMD library false Value Value const Twine & Name
support::ulittle64_t ImageBase
Definition: COFF.h:150
support::ulittle32_t NameRVA
Definition: COFF.h:228
support::ulittle32_t GuardFlags
Definition: COFF.h:634
support::ulittle64_t GuardLongJumpTargetTable
Definition: COFF.h:687
support::ulittle32_t Reserved
Definition: COFF.h:745
Definition: COFF.h:190
support::ulittle64_t SEHandlerTable
Definition: COFF.h:673
".bf" or ".ef" - beginning or end of function
Definition: COFF.h:230
coff_symbol< support::ulittle32_t > coff_symbol32
Definition: COFF.h:267
support::ulittle32_t LoaderFlags
Definition: COFF.h:169
support::ulittle16_t MajorVersion
Definition: COFF.h:226
std::error_code getSymbol(uint32_t Index, const coff_symbol_type *&Res) const
Definition: COFF.h:983
support::ulittle16_t Machine
Definition: COFF.h:543
support::ulittle32_t SizeOfInitializedData
Definition: COFF.h:146
support::ulittle32_t AddressOfEntryPoint
Definition: COFF.h:112
support::ulittle32_t Type
Definition: COFF.h:183
support::ulittle16_t NumberOfNameEntries
Definition: COFF.h:753
support::ulittle32_t TimeDateStamp
Definition: COFF.h:79
support::ulittle32_t PointerToSymbolTable
Definition: COFF.h:100
support::ulittle16_t Machine
Definition: COFF.h:92
support::ulittle32_t LoaderFlags
Definition: COFF.h:135
bool isFunctionLineInfo() const
Definition: COFF.h:399
support::ulittle32_t PointerToRawData
Definition: COFF.h:186
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:52
support::ulittle16_t SizeOfOptionalHeader
Definition: COFF.h:82
The access may reference the value stored in memory.
support::ulittle32_t SizeOfUninitializedData
Definition: COFF.h:147
const StringTableOffset & getStringTableOffset() const
Definition: COFF.h:313
static StringRef getName(Value *V)
support::ulittle32_t NumLocals
Definition: COFF.h:1216
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
support::ulittle32_t DynamicValueRelocTableOffset
Definition: COFF.h:693
support::ulittle16_t MajorVersion
Definition: COFF.h:610
const int32_t MaxNumberOfSections16
Definition: COFF.h:34
support::ulittle16_t MajorOperatingSystemVersion
Definition: COFF.h:153
External symbol in dmert public lib.
Definition: COFF.h:237
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:773
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Definition: ELF.h:275
bool isReservedSectionNumber(int32_t SectionNumber)
Definition: COFF.h:720
support::ulittle16_t Reserved2
Definition: COFF.h:695
coff_load_config_code_integrity CodeIntegrity
Definition: COFF.h:637
support::ulittle16_t MinorSubsystemVersion
Definition: COFF.h:123
uint8_t getStorageClass() const
Definition: COFF.h:336
Expected< COFFSymbolRef > getSymbol(uint32_t index) const
Definition: COFF.h:991
support::ulittle32_t VirtualSize
Definition: COFF.h:440
support::ulittle64_t LockPrefixTable
Definition: COFF.h:664
support::ulittle16_t InitialRelativeSS
Definition: COFF.h:62
support::ulittle64_t GuardAddressTakenIatEntryTable
Definition: COFF.h:685
support::ulittle32_t NumberOfSymbols
Definition: COFF.h:101
support::ulittle16_t InitialSP
Definition: COFF.h:63
support::ulittle32_t SizeOfInitializedData
Definition: COFF.h:110
support::ulittle16_t DynamicValueRelocTableSection
Definition: COFF.h:694
int32_t getSectionNumber() const
Definition: COFF.h:320
support::ulittle32_t Magic
Definition: COFF.h:758
support::ulittle32_t Win32VersionValue
Definition: COFF.h:159
support::ulittle16_t MajorImageVersion
Definition: COFF.h:155
support::ulittle32_t ExportFlags
Definition: COFF.h:224
support::ulittle16_t OEMinfo
Definition: COFF.h:71
support::ulittle64_t GuardRFFailureRoutineFunctionPointer
Definition: COFF.h:692
bool isFunctionDefinition() const
Definition: COFF.h:393
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition: COFF.h:266
support::ulittle16_t MinorVersion
Definition: COFF.h:182
support::ulittle16_t NumParams
Definition: COFF.h:1217
support::ulittle32_t NamePointerRVA
Definition: COFF.h:233
uint8_t getComplexType() const
Definition: COFF.h:348
support::ulittle32_t ExportRVA
Definition: COFF.h:238
support::ulittle32_t NameRVA
Definition: COFF.h:557
support::ulittle32_t Size
Definition: COFF.h:655
uint16_t getType() const
Definition: COFF.h:331
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
Definition: ELF.h:337
support::ulittle32_t GlobalFlagsSet
Definition: COFF.h:660
int32_t getNumber(bool IsBigObj) const
Definition: COFF.h:518
support::ulittle16_t MinorVersion
Definition: COFF.h:611
int getPrologSize() const
Definition: COFF.h:1221
support::ulittle32_t TagIndex
Definition: COFF.h:501
support::ulittle32_t TimeDateStamp
Definition: COFF.h:93
support::ulittle32_t ProcessHeapFlags
Definition: COFF.h:668
support::ulittle16_t Magic
Definition: COFF.h:106
support::ulittle32_t GlobalFlagsSet
Definition: COFF.h:613
support::ulittle32_t ProcessHeapFlags
Definition: COFF.h:621
support::ulittle32_t GuardAddressTakenIatEntryTable
Definition: COFF.h:638
support::ulittle16_t Version
Definition: COFF.h:542
support::ulittle32_t Characteristics
Definition: COFF.h:448
support::ulittle16_t NumberHighPart
Definition: COFF.h:517
support::ulittle32_t NumberOfRvaAndSize
Definition: COFF.h:170
support::ulittle32_t FileAlignment
Definition: COFF.h:117
support::ulittle32_t Characteristics
Definition: COFF.h:502
std::error_code getAuxSymbol(uint32_t index, const T *&Res) const
Definition: COFF.h:1008
support::ulittle32_t DeCommitTotalFreeThreshold
Definition: COFF.h:616
uint16_t getCharacteristics() const
Definition: COFF.h:830
uint32_t getRawNumberOfSymbols() const
Definition: COFF.h:865
support::ulittle16_t MinorSubsystemVersion
Definition: COFF.h:158
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
support::ulittle16_t InitialRelativeCS
Definition: COFF.h:66
support::ulittle16_t NumberOfIDEntries
Definition: COFF.h:754
support::ulittle64_t SizeOfHeapReserve
Definition: COFF.h:167
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
Definition: Endian.h:271
support::ulittle32_t unused1
Definition: COFF.h:95
Line number, reformatted as symbol.
Definition: COFF.h:234
support::ulittle32_t SubdirOffset
Definition: COFF.h:731
bool isOrdinal() const
Definition: COFF.h:193
support::ulittle32_t SizeOfZeroFill
Definition: COFF.h:572
support::ulittle32_t CheckSum
Definition: COFF.h:162
support::ulittle32_t VirtualMemoryThreshold
Definition: COFF.h:619
support::ulittle32_t MaximumAllocationSize
Definition: COFF.h:618
support::ulittle32_t Win32VersionValue
Definition: COFF.h:124
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
support::ulittle16_t MinorImageVersion
Definition: COFF.h:121
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
const dos_header * getDOSHeader() const
Definition: COFF.h:969
support::ulittle64_t SizeOfStackCommit
Definition: COFF.h:166
support::ulittle16_t Characteristics
Definition: COFF.h:83
uint32_t getHintNameRVA() const
Definition: COFF.h:200
The 32-bit PE header that follows the COFF header.
Definition: COFF.h:105
support::ulittle32_t SymbolTableIndex
Definition: COFF.h:532
Definition: COFF.h:741
support::ulittle16_t MinorVersion
Definition: COFF.h:752
support::ulittle32_t CriticalSectionDefaultTimeout
Definition: COFF.h:614
IntTy Data
Definition: COFF.h:191
COFFSymbolRef(const coff_symbol16 *CS)
Definition: COFF.h:284
support::ulittle16_t HashAlgorithm
Definition: COFF.h:760
COFFSymbolRef(const coff_symbol32 *CS)
Definition: COFF.h:285
support::ulittle32_t Size
Definition: COFF.h:1215
support::ulittle32_t RelativeVirtualAddress
Definition: COFF.h:174
support::ulittle16_t FileSizeInPages
Definition: COFF.h:57
support::ulittle32_t Value
Definition: COFF.h:275
support::ulittle16_t Magic
Definition: COFF.h:142
support::ulittle16_t MajorSubsystemVersion
Definition: COFF.h:157
support::ulittle32_t TimeStamp
Definition: COFF.h:220
support::ulittle32_t DataSize
Definition: COFF.h:743
No type information or unknown base type.
Definition: COFF.h:241
const coff_aux_section_definition * getSectionDefinition() const
Definition: COFF.h:357
support::ulittle32_t ImportAddressTableRVA
Definition: COFF.h:558
support::ulittle16_t TypeInfo
Definition: COFF.h:547
support::ulittle32_t NameOffset
Definition: COFF.h:720
support::ulittle16_t Subsystem
Definition: COFF.h:128
support::ulittle32_t Characteristics
Definition: COFF.h:179
const void * getRawPtr() const
Definition: COFF.h:287
support::ulittle16_t Type
Definition: COFF.h:475
support::ulittle16_t MajorSubsystemVersion
Definition: COFF.h:122
int getNumSavedRegs() const
Definition: COFF.h:1224
support::ulittle32_t EndAddress
Definition: COFF.h:702
support::ulittle32_t OrdinalTableRVA
Definition: COFF.h:234
support::ulittle32_t GuardRFFailureRoutine
Definition: COFF.h:644
const coff_symbol_generic * getGeneric() const
Definition: COFF.h:291
support::ulittle16_t Reserved2[10]
Definition: COFF.h:72
StringTableOffset Offset
Definition: COFF.h:273
support::ulittle32_t SizeOfRawData
Definition: COFF.h:442
SubtargetFeatures getFeatures() const override
Definition: COFF.h:943
static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)
Definition: SymbolSize.cpp:28
support::ulittle16_t Linenumber
Definition: COFF.h:491
support::ulittle32_t SizeOfHeapCommit
Definition: COFF.h:134
bool isImportLibrary() const
Definition: COFF.h:85
DelayImportDirectoryEntryRef(const delay_import_directory_table_entry *T, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1103
support::ulittle32_t ForwarderChain
Definition: COFF.h:556
static wasm::ValType getType(const TargetRegisterClass *RC)
support::ulittle32_t VirtualAddress
Definition: COFF.h:473
support::ulittle32_t SymbolTableIndex
Definition: COFF.h:474
const debug_directory * debug_directory_end() const
Definition: COFF.h:956
support::ulittle16_t MajorImageVersion
Definition: COFF.h:120
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isUndefined() const
Definition: COFF.h:384
support::ulittle32_t unused2
Definition: COFF.h:96
uint16_t getMachine() const
Definition: COFF.h:812
Definition: COFF.h:553
support::ulittle16_t MinorOperatingSystemVersion
Definition: COFF.h:119
const coff_aux_weak_external * getWeakExternal() const
Definition: COFF.h:364
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
uint32_t Number
Definition: Profile.cpp:48
bool hasSEH() const
Definition: COFF.h:1227
support::ulittle32_t TimeDateStamp
Definition: COFF.h:656
support::ulittle32_t TimeDateStamp
Definition: COFF.h:609
support::ulittle64_t ProcessAffinityMask
Definition: COFF.h:667
support::ulittle16_t AddressOfRelocationTable
Definition: COFF.h:67
support::ulittle32_t PointerToRawData
Definition: COFF.h:443
support::ulittle32_t SizeOfStackReserve
Definition: COFF.h:131
support::ulittle32_t SizeOfCode
Definition: COFF.h:109
support::ulittle16_t Subsystem
Definition: COFF.h:163
support::ulittle32_t BaseOfData
Definition: COFF.h:114
support::ulittle64_t GuardCFCheckFunction
Definition: COFF.h:677
SectionNumberType SectionNumber
Definition: COFF.h:258
support::ulittle16_t MinorVersion
Definition: COFF.h:227
support::ulittle32_t SectionAlignment
Definition: COFF.h:116
support::ulittle64_t VirtualMemoryThreshold
Definition: COFF.h:666
support::ulittle16_t DLLCharacteristics
Definition: COFF.h:164
support::ulittle32_t BeginAddress
Definition: COFF.h:701
support::ulittle32_t DataEntryOffset
Definition: COFF.h:730
coff_load_config_code_integrity CodeIntegrity
Definition: COFF.h:684
BaseRelocRef(const coff_base_reloc_block_header *Header, const COFFObjectFile *Owner)
Definition: COFF.h:1179
uint32_t getNumberOfSections() const
Definition: COFF.h:848
support::ulittle32_t SizeOfHeaders
Definition: COFF.h:126
Definition: COFF.h:711
support::ulittle16_t Sig1
Definition: COFF.h:89
support::ulittle32_t GuardLongJumpTargetCount
Definition: COFF.h:641
bool operator==(const DataRefImpl &a, const DataRefImpl &b)
Definition: SymbolicFile.h:53
bool isAbsolute() const
Definition: COFF.h:371
support::ulittle16_t CSDVersion
Definition: COFF.h:622
support::ulittle16_t CSDVersion
Definition: COFF.h:669
ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1129
support::ulittle32_t unused4
Definition: COFF.h:98
support::ulittle64_t SEHandlerCount
Definition: COFF.h:674
support::ulittle16_t DependentLoadFlags
Definition: COFF.h:623
support::ulittle32_t GlobalFlagsClear
Definition: COFF.h:659
support::ulittle16_t NumberOfRelocations
Definition: COFF.h:511
friend bool operator<(COFFSymbolRef A, COFFSymbolRef B)
Definition: COFF.h:297
support::ulittle32_t SEHandlerTable
Definition: COFF.h:626
support::ulittle32_t Offset
Definition: COFF.h:1214
The DOS compatible header at the front of all PE/COFF executables.
Definition: COFF.h:54
support::ulittle32_t ModuleHandle
Definition: COFF.h:215
support::ulittle32_t ForwarderRVA
Definition: COFF.h:239
A range adaptor for a pair of iterators.
support::ulittle32_t EditList
Definition: COFF.h:624
support::ulittle32_t SizeOfCode
Definition: COFF.h:145
support::ulittle32_t AddressOfEntryPoint
Definition: COFF.h:148
support::ulittle32_t AddressOfRawData
Definition: COFF.h:185
Manages the enabling and disabling of subtarget specific features.
int getOffset() const
Definition: COFF.h:715
size_t getSymbolTableEntrySize() const
Definition: COFF.h:1022
support::ulittle32_t Size
Definition: COFF.h:175
uint32_t getAlignment() const
Definition: COFF.h:575
uint32_t getTimeDateStamp() const
Definition: COFF.h:840
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:129
support::ulittle32_t ImageBase
Definition: COFF.h:115
const char * getShortName() const
Definition: COFF.h:309
support::ulittle16_t Attributes
Definition: COFF.h:1218
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:34
support::ulittle32_t GuardRFVerifyStackPointerFunctionPointer
Definition: COFF.h:649
const T * getAux() const
Definition: COFF.h:352
frame_type getFP() const
Definition: COFF.h:1233
support::ulittle32_t Zeroes
Definition: COFF.h:246
ImportDirectoryEntryRef(const coff_import_directory_table_entry *Table, uint32_t I, const COFFObjectFile *Owner)
Definition: COFF.h:1072
support::ulittle16_t DynamicValueRelocTableSection
Definition: COFF.h:647
support::ulittle32_t DynamicValueRelocTable
Definition: COFF.h:642
support::ulittle32_t NumberOfNamePointers
Definition: COFF.h:231
bool isWeakExternal() const
Definition: COFF.h:389
support::ulittle32_t GuardAddressTakenIatEntryCount
Definition: COFF.h:639
support::ulittle32_t GuardFlags
Definition: COFF.h:681
support::ulittle32_t PointerToNextFunction
Definition: COFF.h:482
Definition: COFF.h:718
support::ulittle32_t BaseOfCode
Definition: COFF.h:113
support::ulittle16_t Checksum
Definition: COFF.h:64
ResourceSectionRef(StringRef Ref)
Definition: COFF.h:1197
support::ulittle16_t MinimumExtraParagraphs
Definition: COFF.h:60
uint8_t getBaseType() const
Definition: COFF.h:346
bool isSection() const
Definition: COFF.h:411
support::ulittle32_t Characteristics
Definition: COFF.h:573
support::ulittle16_t DependentLoadFlags
Definition: COFF.h:670
support::ulittle32_t SectionAlignment
Definition: COFF.h:151
support::ulittle16_t MinorImageVersion
Definition: COFF.h:156
support::ulittle32_t ImportLookupTableRVA
Definition: COFF.h:554
#define I(x, y, z)
Definition: MD5.cpp:58
support::ulittle32_t AddressTableEntries
Definition: COFF.h:230
support::ulittle32_t TimeDateStamp
Definition: COFF.h:750
const coff_load_configuration32 * getLoadConfig32() const
Definition: COFF.h:879
uint8_t MinorLinkerVersion
Definition: COFF.h:108
bool isBigObj() const
Definition: COFF.h:301
support::ulittle32_t GuardLongJumpTargetTable
Definition: COFF.h:640
uint32_t Size
Definition: Profile.cpp:47
support::ulittle32_t BlockSize
Definition: COFF.h:708
support::ulittle32_t DataRVA
Definition: COFF.h:742
support::ulittle32_t PointerToLinenumber
Definition: COFF.h:481
Definition: COFF.h:211
bool isAnyUndefined() const
Definition: COFF.h:403
support::ulittle64_t EditList
Definition: COFF.h:671
support::ulittle16_t NumberOfLinenumbers
Definition: COFF.h:447
support::ulittle64_t CHPEMetadataPointer
Definition: COFF.h:690
support::ulittle32_t CriticalSectionDefaultTimeout
Definition: COFF.h:661
support::ulittle16_t NumberOfRelocations
Definition: COFF.h:446
uint8_t NumberOfAuxSymbols
Definition: COFF.h:263
support::ulittle32_t SizeOfData
Definition: COFF.h:184
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
support::ulittle32_t AddressOfNewExeHeader
Definition: COFF.h:73
support::ulittle32_t Size
Definition: COFF.h:608
support::ulittle32_t GuardCFCheckFunction
Definition: COFF.h:630
coff_guard_flags
Bits in control flow guard flags as we understand them.
Definition: COFF.h:588
uintptr_t getSymbolTable() const
Definition: COFF.h:804
bool isFileRecord() const
Definition: COFF.h:407
support::ulittle32_t NumberOfSections
Definition: COFF.h:99
support::ulittle32_t BaseOfCode
Definition: COFF.h:149
support::ulittle32_t DeCommitFreeBlockThreshold
Definition: COFF.h:615
support::ulittle32_t GuardRFFailureRoutineFunctionPointer
Definition: COFF.h:645
support::ulittle32_t Value
Definition: COFF.h:257
const coff_load_configuration64 * getLoadConfig64() const
Definition: COFF.h:884
static bool classof(const Binary *v)
Definition: COFF.h:1065
support::ulittle16_t NumberOfRelocationItems
Definition: COFF.h:58
support::ulittle32_t ExportAddressTableRVA
Definition: COFF.h:232
bool useBP() const
Definition: COFF.h:1230
support::ulittle16_t Version
Definition: COFF.h:759
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
support::ulittle32_t TimeDateStamp
Definition: COFF.h:225
support::ulittle32_t FileAlignment
Definition: COFF.h:152
support::ulittle32_t NumberOfRvaAndSize
Definition: COFF.h:137
support::ulittle32_t HotPatchTableOffset
Definition: COFF.h:650
support::ulittle64_t GuardCFFunctionTable
Definition: COFF.h:679
uint32_t getValue() const
Definition: COFF.h:318
support::ulittle32_t NumberOfSymbols
Definition: COFF.h:81
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
support::ulittle32_t ID
Definition: COFF.h:721
support::ulittle32_t PointerToSymbolTable
Definition: COFF.h:80
bool hasExtendedRelocations() const
Definition: COFF.h:452
support::ulittle32_t DelayImportNameTable
Definition: COFF.h:217
support::ulittle32_t Characteristics
Definition: COFF.h:749
support::ulittle32_t TimeDateStamp
Definition: COFF.h:180
support::ulittle64_t GuardRFFailureRoutine
Definition: COFF.h:691
support::ulittle16_t MinorVersion
Definition: COFF.h:658
bool isExternal() const
Definition: COFF.h:375
support::ulittle32_t Codepage
Definition: COFF.h:744
support::ulittle32_t SEHandlerCount
Definition: COFF.h:627
support::ulittle16_t Sig2
Definition: COFF.h:90
StringTableOffset Offset
Definition: COFF.h:254
support::ulittle32_t SizeOfHeapReserve
Definition: COFF.h:133
support::ulittle16_t OverlayNumber
Definition: COFF.h:68
support::ulittle32_t TotalSize
Definition: COFF.h:480
support::ulittle32_t ProcessAffinityMask
Definition: COFF.h:620
support::ulittle16_t Type
Definition: COFF.h:260
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
Definition: Error.cpp:93
support::ulittle16_t OEMid
Definition: COFF.h:70
support::ulittle32_t UnwindInformation
Definition: COFF.h:703
support::ulittle32_t LockPrefixTable
Definition: COFF.h:617
support::ulittle32_t BoundDelayImportTable
Definition: COFF.h:218
support::ulittle64_t DeCommitFreeBlockThreshold
Definition: COFF.h:662
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:81
uint32_t getNumberOfSymbols() const
Definition: COFF.h:873
StringRef getSymbolName(CVSymbol Sym)
Definition: RecordName.cpp:318
support::ulittle32_t unused3
Definition: COFF.h:97
support::ulittle32_t Offset
Definition: COFF.h:247
A function that returns a base type.
Definition: COFF.h:262