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