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