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