LLVM  8.0.1
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 getCOFFHeader(const coff_file_header *&Res) const;
975  std::error_code
976  getCOFFBigObjHeader(const coff_bigobj_file_header *&Res) const;
977  std::error_code getPE32Header(const pe32_header *&Res) const;
978  std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
979  std::error_code getDataDirectory(uint32_t index,
980  const data_directory *&Res) const;
981  std::error_code getSection(int32_t index, const coff_section *&Res) const;
982  std::error_code getSection(StringRef SectionName,
983  const coff_section *&Res) const;
984 
985  template <typename coff_symbol_type>
986  std::error_code getSymbol(uint32_t Index,
987  const coff_symbol_type *&Res) const {
988  if (Index >= getNumberOfSymbols())
990 
991  Res = reinterpret_cast<coff_symbol_type *>(getSymbolTable()) + Index;
992  return std::error_code();
993  }
995  if (SymbolTable16) {
996  const coff_symbol16 *Symb = nullptr;
997  if (std::error_code EC = getSymbol(index, Symb))
998  return errorCodeToError(EC);
999  return COFFSymbolRef(Symb);
1000  }
1001  if (SymbolTable32) {
1002  const coff_symbol32 *Symb = nullptr;
1003  if (std::error_code EC = getSymbol(index, Symb))
1004  return errorCodeToError(EC);
1005  return COFFSymbolRef(Symb);
1006  }
1008  }
1009 
1010  template <typename T>
1011  std::error_code getAuxSymbol(uint32_t index, const T *&Res) const {
1013  if (Error E = S.takeError())
1014  return errorToErrorCode(std::move(E));
1015  Res = reinterpret_cast<const T *>(S->getRawPtr());
1016  return std::error_code();
1017  }
1018 
1019  std::error_code getSymbolName(COFFSymbolRef Symbol, StringRef &Res) const;
1020  std::error_code getSymbolName(const coff_symbol_generic *Symbol,
1021  StringRef &Res) const;
1022 
1023  ArrayRef<uint8_t> getSymbolAuxData(COFFSymbolRef Symbol) const;
1024 
1025  uint32_t getSymbolIndex(COFFSymbolRef Symbol) const;
1026 
1027  size_t getSymbolTableEntrySize() const {
1028  if (COFFHeader)
1029  return sizeof(coff_symbol16);
1030  if (COFFBigObjHeader)
1031  return sizeof(coff_symbol32);
1032  llvm_unreachable("null symbol table pointer!");
1033  }
1034 
1035  ArrayRef<coff_relocation> getRelocations(const coff_section *Sec) const;
1036 
1037  std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
1038  uint64_t getSectionSize(const coff_section *Sec) const;
1039  std::error_code getSectionContents(const coff_section *Sec,
1040  ArrayRef<uint8_t> &Res) const;
1041 
1042  uint64_t getImageBase() const;
1043  std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
1044  std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
1045 
1046  /// Given an RVA base and size, returns a valid array of bytes or an error
1047  /// code if the RVA and size is not contained completely within a valid
1048  /// section.
1049  std::error_code getRvaAndSizeAsBytes(uint32_t RVA, uint32_t Size,
1050  ArrayRef<uint8_t> &Contents) const;
1051 
1052  std::error_code getHintName(uint32_t Rva, uint16_t &Hint,
1053  StringRef &Name) const;
1054 
1055  /// Get PDB information out of a codeview debug directory entry.
1056  std::error_code getDebugPDBInfo(const debug_directory *DebugDir,
1057  const codeview::DebugInfo *&Info,
1058  StringRef &PDBFileName) const;
1059 
1060  /// Get PDB information from an executable. If the information is not present,
1061  /// Info will be set to nullptr and PDBFileName will be empty. An error is
1062  /// returned only on corrupt object files. Convenience accessor that can be
1063  /// used if the debug directory is not already handy.
1064  std::error_code getDebugPDBInfo(const codeview::DebugInfo *&Info,
1065  StringRef &PDBFileName) const;
1066 
1067  bool isRelocatableObject() const override;
1068  bool is64() const { return PE32PlusHeader; }
1069 
1070  StringRef mapDebugSectionName(StringRef Name) const override;
1071 
1072  static bool classof(const Binary *v) { return v->isCOFF(); }
1073 };
1074 
1075 // The iterator for the import directory table.
1077 public:
1078  ImportDirectoryEntryRef() = default;
1080  uint32_t I, const COFFObjectFile *Owner)
1081  : ImportTable(Table), Index(I), OwningObject(Owner) {}
1082 
1083  bool operator==(const ImportDirectoryEntryRef &Other) const;
1084  void moveNext();
1085 
1086  imported_symbol_iterator imported_symbol_begin() const;
1087  imported_symbol_iterator imported_symbol_end() const;
1088  iterator_range<imported_symbol_iterator> imported_symbols() const;
1089 
1090  imported_symbol_iterator lookup_table_begin() const;
1091  imported_symbol_iterator lookup_table_end() const;
1092  iterator_range<imported_symbol_iterator> lookup_table_symbols() const;
1093 
1094  std::error_code getName(StringRef &Result) const;
1095  std::error_code getImportLookupTableRVA(uint32_t &Result) const;
1096  std::error_code getImportAddressTableRVA(uint32_t &Result) const;
1097 
1098  std::error_code
1099  getImportTableEntry(const coff_import_directory_table_entry *&Result) const;
1100 
1101 private:
1102  const coff_import_directory_table_entry *ImportTable;
1103  uint32_t Index;
1104  const COFFObjectFile *OwningObject = nullptr;
1105 };
1106 
1108 public:
1109  DelayImportDirectoryEntryRef() = default;
1111  uint32_t I, const COFFObjectFile *Owner)
1112  : Table(T), Index(I), OwningObject(Owner) {}
1113 
1114  bool operator==(const DelayImportDirectoryEntryRef &Other) const;
1115  void moveNext();
1116 
1117  imported_symbol_iterator imported_symbol_begin() const;
1118  imported_symbol_iterator imported_symbol_end() const;
1119  iterator_range<imported_symbol_iterator> imported_symbols() const;
1120 
1121  std::error_code getName(StringRef &Result) const;
1122  std::error_code getDelayImportTable(
1123  const delay_import_directory_table_entry *&Result) const;
1124  std::error_code getImportAddress(int AddrIndex, uint64_t &Result) const;
1125 
1126 private:
1128  uint32_t Index;
1129  const COFFObjectFile *OwningObject = nullptr;
1130 };
1131 
1132 // The iterator for the export directory table entry.
1134 public:
1135  ExportDirectoryEntryRef() = default;
1137  const COFFObjectFile *Owner)
1138  : ExportTable(Table), Index(I), OwningObject(Owner) {}
1139 
1140  bool operator==(const ExportDirectoryEntryRef &Other) const;
1141  void moveNext();
1142 
1143  std::error_code getDllName(StringRef &Result) const;
1144  std::error_code getOrdinalBase(uint32_t &Result) const;
1145  std::error_code getOrdinal(uint32_t &Result) const;
1146  std::error_code getExportRVA(uint32_t &Result) const;
1147  std::error_code getSymbolName(StringRef &Result) const;
1148 
1149  std::error_code isForwarder(bool &Result) const;
1150  std::error_code getForwardTo(StringRef &Result) const;
1151 
1152 private:
1153  const export_directory_table_entry *ExportTable;
1154  uint32_t Index;
1155  const COFFObjectFile *OwningObject = nullptr;
1156 };
1157 
1159 public:
1160  ImportedSymbolRef() = default;
1162  const COFFObjectFile *Owner)
1163  : Entry32(Entry), Entry64(nullptr), Index(I), OwningObject(Owner) {}
1165  const COFFObjectFile *Owner)
1166  : Entry32(nullptr), Entry64(Entry), Index(I), OwningObject(Owner) {}
1167 
1168  bool operator==(const ImportedSymbolRef &Other) const;
1169  void moveNext();
1170 
1171  std::error_code getSymbolName(StringRef &Result) const;
1172  std::error_code isOrdinal(bool &Result) const;
1173  std::error_code getOrdinal(uint16_t &Result) const;
1174  std::error_code getHintNameRVA(uint32_t &Result) const;
1175 
1176 private:
1177  const import_lookup_table_entry32 *Entry32;
1178  const import_lookup_table_entry64 *Entry64;
1179  uint32_t Index;
1180  const COFFObjectFile *OwningObject = nullptr;
1181 };
1182 
1184 public:
1185  BaseRelocRef() = default;
1187  const COFFObjectFile *Owner)
1188  : Header(Header), Index(0) {}
1189 
1190  bool operator==(const BaseRelocRef &Other) const;
1191  void moveNext();
1192 
1193  std::error_code getType(uint8_t &Type) const;
1194  std::error_code getRVA(uint32_t &Result) const;
1195 
1196 private:
1197  const coff_base_reloc_block_header *Header;
1198  uint32_t Index;
1199 };
1200 
1202 public:
1203  ResourceSectionRef() = default;
1204  explicit ResourceSectionRef(StringRef Ref) : BBS(Ref, support::little) {}
1205 
1207  getEntryNameString(const coff_resource_dir_entry &Entry);
1209  getEntrySubDir(const coff_resource_dir_entry &Entry);
1211 
1212 private:
1213  BinaryByteStream BBS;
1214 
1216  Expected<ArrayRef<UTF16>> getDirStringAtOffset(uint32_t Offset);
1217 };
1218 
1219 // Corresponds to `_FPO_DATA` structure in the PE/COFF spec.
1220 struct FpoData {
1221  support::ulittle32_t Offset; // ulOffStart: Offset 1st byte of function code
1222  support::ulittle32_t Size; // cbProcSize: # bytes in function
1223  support::ulittle32_t NumLocals; // cdwLocals: # bytes in locals/4
1224  support::ulittle16_t NumParams; // cdwParams: # bytes in params/4
1226 
1227  // cbProlog: # bytes in prolog
1228  int getPrologSize() const { return Attributes & 0xF; }
1229 
1230  // cbRegs: # regs saved
1231  int getNumSavedRegs() const { return (Attributes >> 8) & 0x7; }
1232 
1233  // fHasSEH: true if seh is func
1234  bool hasSEH() const { return (Attributes >> 9) & 1; }
1235 
1236  // fUseBP: true if EBP has been allocated
1237  bool useBP() const { return (Attributes >> 10) & 1; }
1238 
1239  // cbFrame: frame pointer
1240  frame_type getFP() const { return static_cast<frame_type>(Attributes >> 14); }
1241 };
1242 
1243 } // end namespace object
1244 
1245 } // end namespace llvm
1246 
1247 #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
This class represents lattice values for constants.
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:202
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:1164
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:1161
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:986
support::ulittle16_t Machine
Definition: COFF.h:543
support::ulittle32_t SizeOfInitializedData
Definition: COFF.h:146
support::ulittle32_t AddressOfEntryPoint
Definition: COFF.h:112
static StringRef getSymbolName(SymbolKind SymKind)
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:1223
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:784
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:994
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:1224
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
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
int32_t getNumber(bool IsBigObj) const
Definition: COFF.h:518
support::ulittle16_t MinorVersion
Definition: COFF.h:611
int getPrologSize() const
Definition: COFF.h:1228
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:1011
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:88
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:1222
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:1231
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:1110
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:1234
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:1186
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:1136
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:1221
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:1027
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:141
support::ulittle32_t ImageBase
Definition: COFF.h:115
const char * getShortName() const
Definition: COFF.h:309
support::ulittle16_t Attributes
Definition: COFF.h:1225
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:1240
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:1079
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:1204
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:1072
support::ulittle16_t NumberOfRelocationItems
Definition: COFF.h:58
support::ulittle32_t ExportAddressTableRVA
Definition: COFF.h:232
bool useBP() const
Definition: COFF.h:1237
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:94
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
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