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