1 //===- COFF.h - COFF object file implementation -----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the COFFObjectFile class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_OBJECT_COFF_H
15 #define LLVM_OBJECT_COFF_H
17 #include "llvm/ADT/PointerUnion.h"
18 #include "llvm/Object/ObjectFile.h"
19 #include "llvm/Support/COFF.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/ErrorOr.h"
24 template <typename T> class ArrayRef;
27 class ImportDirectoryEntryRef;
28 class ExportDirectoryEntryRef;
29 typedef content_iterator<ImportDirectoryEntryRef> import_directory_iterator;
30 typedef content_iterator<ExportDirectoryEntryRef> export_directory_iterator;
32 /// The DOS compatible header at the front of all PE/COFF executables.
34 support::ulittle16_t Magic;
35 support::ulittle16_t UsedBytesInTheLastPage;
36 support::ulittle16_t FileSizeInPages;
37 support::ulittle16_t NumberOfRelocationItems;
38 support::ulittle16_t HeaderSizeInParagraphs;
39 support::ulittle16_t MinimumExtraParagraphs;
40 support::ulittle16_t MaximumExtraParagraphs;
41 support::ulittle16_t InitialRelativeSS;
42 support::ulittle16_t InitialSP;
43 support::ulittle16_t Checksum;
44 support::ulittle16_t InitialIP;
45 support::ulittle16_t InitialRelativeCS;
46 support::ulittle16_t AddressOfRelocationTable;
47 support::ulittle16_t OverlayNumber;
48 support::ulittle16_t Reserved[4];
49 support::ulittle16_t OEMid;
50 support::ulittle16_t OEMinfo;
51 support::ulittle16_t Reserved2[10];
52 support::ulittle32_t AddressOfNewExeHeader;
55 struct coff_file_header {
56 support::ulittle16_t Machine;
57 support::ulittle16_t NumberOfSections;
58 support::ulittle32_t TimeDateStamp;
59 support::ulittle32_t PointerToSymbolTable;
60 support::ulittle32_t NumberOfSymbols;
61 support::ulittle16_t SizeOfOptionalHeader;
62 support::ulittle16_t Characteristics;
64 bool isImportLibrary() const { return NumberOfSections == 0xffff; }
67 struct coff_bigobj_file_header {
68 support::ulittle16_t Sig1;
69 support::ulittle16_t Sig2;
70 support::ulittle16_t Version;
71 support::ulittle16_t Machine;
72 support::ulittle32_t TimeDateStamp;
74 support::ulittle32_t unused1;
75 support::ulittle32_t unused2;
76 support::ulittle32_t unused3;
77 support::ulittle32_t unused4;
78 support::ulittle32_t NumberOfSections;
79 support::ulittle32_t PointerToSymbolTable;
80 support::ulittle32_t NumberOfSymbols;
83 /// The 32-bit PE header that follows the COFF header.
85 support::ulittle16_t Magic;
86 uint8_t MajorLinkerVersion;
87 uint8_t MinorLinkerVersion;
88 support::ulittle32_t SizeOfCode;
89 support::ulittle32_t SizeOfInitializedData;
90 support::ulittle32_t SizeOfUninitializedData;
91 support::ulittle32_t AddressOfEntryPoint;
92 support::ulittle32_t BaseOfCode;
93 support::ulittle32_t BaseOfData;
94 support::ulittle32_t ImageBase;
95 support::ulittle32_t SectionAlignment;
96 support::ulittle32_t FileAlignment;
97 support::ulittle16_t MajorOperatingSystemVersion;
98 support::ulittle16_t MinorOperatingSystemVersion;
99 support::ulittle16_t MajorImageVersion;
100 support::ulittle16_t MinorImageVersion;
101 support::ulittle16_t MajorSubsystemVersion;
102 support::ulittle16_t MinorSubsystemVersion;
103 support::ulittle32_t Win32VersionValue;
104 support::ulittle32_t SizeOfImage;
105 support::ulittle32_t SizeOfHeaders;
106 support::ulittle32_t CheckSum;
107 support::ulittle16_t Subsystem;
108 support::ulittle16_t DLLCharacteristics;
109 support::ulittle32_t SizeOfStackReserve;
110 support::ulittle32_t SizeOfStackCommit;
111 support::ulittle32_t SizeOfHeapReserve;
112 support::ulittle32_t SizeOfHeapCommit;
113 support::ulittle32_t LoaderFlags;
114 support::ulittle32_t NumberOfRvaAndSize;
117 /// The 64-bit PE header that follows the COFF header.
118 struct pe32plus_header {
119 support::ulittle16_t Magic;
120 uint8_t MajorLinkerVersion;
121 uint8_t MinorLinkerVersion;
122 support::ulittle32_t SizeOfCode;
123 support::ulittle32_t SizeOfInitializedData;
124 support::ulittle32_t SizeOfUninitializedData;
125 support::ulittle32_t AddressOfEntryPoint;
126 support::ulittle32_t BaseOfCode;
127 support::ulittle64_t ImageBase;
128 support::ulittle32_t SectionAlignment;
129 support::ulittle32_t FileAlignment;
130 support::ulittle16_t MajorOperatingSystemVersion;
131 support::ulittle16_t MinorOperatingSystemVersion;
132 support::ulittle16_t MajorImageVersion;
133 support::ulittle16_t MinorImageVersion;
134 support::ulittle16_t MajorSubsystemVersion;
135 support::ulittle16_t MinorSubsystemVersion;
136 support::ulittle32_t Win32VersionValue;
137 support::ulittle32_t SizeOfImage;
138 support::ulittle32_t SizeOfHeaders;
139 support::ulittle32_t CheckSum;
140 support::ulittle16_t Subsystem;
141 support::ulittle16_t DLLCharacteristics;
142 support::ulittle64_t SizeOfStackReserve;
143 support::ulittle64_t SizeOfStackCommit;
144 support::ulittle64_t SizeOfHeapReserve;
145 support::ulittle64_t SizeOfHeapCommit;
146 support::ulittle32_t LoaderFlags;
147 support::ulittle32_t NumberOfRvaAndSize;
150 struct data_directory {
151 support::ulittle32_t RelativeVirtualAddress;
152 support::ulittle32_t Size;
155 struct import_directory_table_entry {
156 support::ulittle32_t ImportLookupTableRVA;
157 support::ulittle32_t TimeDateStamp;
158 support::ulittle32_t ForwarderChain;
159 support::ulittle32_t NameRVA;
160 support::ulittle32_t ImportAddressTableRVA;
163 struct import_lookup_table_entry32 {
164 support::ulittle32_t data;
166 bool isOrdinal() const { return data & 0x80000000; }
168 uint16_t getOrdinal() const {
169 assert(isOrdinal() && "ILT entry is not an ordinal!");
170 return data & 0xFFFF;
173 uint32_t getHintNameRVA() const {
174 assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
179 struct export_directory_table_entry {
180 support::ulittle32_t ExportFlags;
181 support::ulittle32_t TimeDateStamp;
182 support::ulittle16_t MajorVersion;
183 support::ulittle16_t MinorVersion;
184 support::ulittle32_t NameRVA;
185 support::ulittle32_t OrdinalBase;
186 support::ulittle32_t AddressTableEntries;
187 support::ulittle32_t NumberOfNamePointers;
188 support::ulittle32_t ExportAddressTableRVA;
189 support::ulittle32_t NamePointerRVA;
190 support::ulittle32_t OrdinalTableRVA;
193 union export_address_table_entry {
194 support::ulittle32_t ExportRVA;
195 support::ulittle32_t ForwarderRVA;
198 typedef support::ulittle32_t export_name_pointer_table_entry;
199 typedef support::ulittle16_t export_ordinal_table_entry;
201 struct StringTableOffset {
202 support::ulittle32_t Zeroes;
203 support::ulittle32_t Offset;
206 template <typename SectionNumberType>
209 char ShortName[COFF::NameSize];
210 StringTableOffset Offset;
213 support::ulittle32_t Value;
214 SectionNumberType SectionNumber;
216 support::ulittle16_t Type;
218 support::ulittle8_t StorageClass;
219 support::ulittle8_t NumberOfAuxSymbols;
222 typedef coff_symbol<support::ulittle16_t> coff_symbol16;
223 typedef coff_symbol<support::ulittle32_t> coff_symbol32;
225 class COFFSymbolRef {
227 COFFSymbolRef(const coff_symbol16 *CS) : CS16(CS), CS32(nullptr) {}
228 COFFSymbolRef(const coff_symbol32 *CS) : CS16(nullptr), CS32(CS) {}
229 COFFSymbolRef() : CS16(nullptr), CS32(nullptr) {}
231 const void *getRawPtr() const {
232 return CS16 ? static_cast<const void *>(CS16) : CS32;
235 friend bool operator<(COFFSymbolRef A, COFFSymbolRef B) {
236 return A.getRawPtr() < B.getRawPtr();
239 const char *getShortName() const {
240 return CS16 ? CS16->Name.ShortName : CS32->Name.ShortName;
243 const StringTableOffset &getStringTableOffset() const {
244 return CS16 ? CS16->Name.Offset : CS32->Name.Offset;
247 uint32_t getValue() const { return CS16 ? CS16->Value : CS32->Value; }
249 int32_t getSectionNumber() const {
251 // Reserved sections are returned as negative numbers.
252 if (CS16->SectionNumber <= COFF::MaxNumberOfSections16)
253 return CS16->SectionNumber;
254 return static_cast<int16_t>(CS16->SectionNumber);
256 return static_cast<int32_t>(CS32->SectionNumber);
259 uint16_t getType() const { return CS16 ? CS16->Type : CS32->Type; }
261 uint8_t getStorageClass() const {
262 return CS16 ? CS16->StorageClass : CS32->StorageClass;
265 uint8_t getNumberOfAuxSymbols() const {
266 return CS16 ? CS16->NumberOfAuxSymbols : CS32->NumberOfAuxSymbols;
269 uint8_t getBaseType() const { return getType() & 0x0F; }
271 uint8_t getComplexType() const { return (getType() & 0xF0) >> 4; }
273 bool isFunctionDefinition() const {
274 return getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
275 getBaseType() == COFF::IMAGE_SYM_TYPE_NULL &&
276 getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION &&
277 !COFF::isReservedSectionNumber(getSectionNumber());
280 bool isFunctionLineInfo() const {
281 return getStorageClass() == COFF::IMAGE_SYM_CLASS_FUNCTION;
284 bool isWeakExternal() const {
285 return getStorageClass() == COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL ||
286 (getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
287 getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED && getValue() == 0);
290 bool isFileRecord() const {
291 return getStorageClass() == COFF::IMAGE_SYM_CLASS_FILE;
294 bool isSectionDefinition() const {
295 // C++/CLI creates external ABS symbols for non-const appdomain globals.
296 // These are also followed by an auxiliary section definition.
297 bool isAppdomainGlobal =
298 getStorageClass() == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
299 getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE;
300 bool isOrdinarySection =
301 getStorageClass() == COFF::IMAGE_SYM_CLASS_STATIC && getValue() == 0;
302 return isAppdomainGlobal || isOrdinarySection;
305 bool isCLRToken() const {
306 return getStorageClass() == COFF::IMAGE_SYM_CLASS_CLR_TOKEN;
310 const coff_symbol16 *CS16;
311 const coff_symbol32 *CS32;
314 struct coff_section {
315 char Name[COFF::NameSize];
316 support::ulittle32_t VirtualSize;
317 support::ulittle32_t VirtualAddress;
318 support::ulittle32_t SizeOfRawData;
319 support::ulittle32_t PointerToRawData;
320 support::ulittle32_t PointerToRelocations;
321 support::ulittle32_t PointerToLinenumbers;
322 support::ulittle16_t NumberOfRelocations;
323 support::ulittle16_t NumberOfLinenumbers;
324 support::ulittle32_t Characteristics;
326 // Returns true if the actual number of relocations is stored in
327 // VirtualAddress field of the first relocation table entry.
328 bool hasExtendedRelocations() const {
329 return Characteristics & COFF::IMAGE_SCN_LNK_NRELOC_OVFL &&
330 NumberOfRelocations == UINT16_MAX;
334 struct coff_relocation {
335 support::ulittle32_t VirtualAddress;
336 support::ulittle32_t SymbolTableIndex;
337 support::ulittle16_t Type;
340 struct coff_aux_function_definition {
341 support::ulittle32_t TagIndex;
342 support::ulittle32_t TotalSize;
343 support::ulittle32_t PointerToLinenumber;
344 support::ulittle32_t PointerToNextFunction;
347 struct coff_aux_bf_and_ef_symbol {
349 support::ulittle16_t Linenumber;
351 support::ulittle32_t PointerToNextFunction;
354 struct coff_aux_weak_external {
355 support::ulittle32_t TagIndex;
356 support::ulittle32_t Characteristics;
359 struct coff_aux_section_definition {
360 support::ulittle32_t Length;
361 support::ulittle16_t NumberOfRelocations;
362 support::ulittle16_t NumberOfLinenumbers;
363 support::ulittle32_t CheckSum;
364 support::ulittle16_t Number;
365 support::ulittle8_t Selection;
368 struct coff_aux_clr_token {
369 support::ulittle8_t AuxType;
370 support::ulittle8_t Reserved;
371 support::ulittle32_t SymbolTableIndex;
374 struct coff_load_configuration32 {
375 support::ulittle32_t Characteristics;
376 support::ulittle32_t TimeDateStamp;
377 support::ulittle16_t MajorVersion;
378 support::ulittle16_t MinorVersion;
379 support::ulittle32_t GlobalFlagsClear;
380 support::ulittle32_t GlobalFlagsSet;
381 support::ulittle32_t CriticalSectionDefaultTimeout;
382 support::ulittle32_t DeCommitFreeBlockThreshold;
383 support::ulittle32_t DeCommitTotalFreeThreshold;
384 support::ulittle32_t LockPrefixTable;
385 support::ulittle32_t MaximumAllocationSize;
386 support::ulittle32_t VirtualMemoryThreshold;
387 support::ulittle32_t ProcessAffinityMask;
388 support::ulittle32_t ProcessHeapFlags;
389 support::ulittle16_t CSDVersion;
390 support::ulittle16_t Reserved;
391 support::ulittle32_t EditList;
392 support::ulittle32_t SecurityCookie;
393 support::ulittle32_t SEHandlerTable;
394 support::ulittle32_t SEHandlerCount;
397 struct coff_runtime_function_x64 {
398 support::ulittle32_t BeginAddress;
399 support::ulittle32_t EndAddress;
400 support::ulittle32_t UnwindInformation;
403 class COFFObjectFile : public ObjectFile {
405 friend class ImportDirectoryEntryRef;
406 friend class ExportDirectoryEntryRef;
407 const coff_file_header *COFFHeader;
408 const coff_bigobj_file_header *COFFBigObjHeader;
409 const pe32_header *PE32Header;
410 const pe32plus_header *PE32PlusHeader;
411 const data_directory *DataDirectory;
412 const coff_section *SectionTable;
413 const coff_symbol16 *SymbolTable16;
414 const coff_symbol32 *SymbolTable32;
415 const char *StringTable;
416 uint32_t StringTableSize;
417 const import_directory_table_entry *ImportDirectory;
418 uint32_t NumberOfImportDirectory;
419 const export_directory_table_entry *ExportDirectory;
421 std::error_code getString(uint32_t offset, StringRef &Res) const;
423 template <typename coff_symbol_type>
424 const coff_symbol_type *toSymb(DataRefImpl Symb) const;
425 const coff_section *toSec(DataRefImpl Sec) const;
426 const coff_relocation *toRel(DataRefImpl Rel) const;
428 std::error_code initSymbolTablePtr();
429 std::error_code initImportTablePtr();
430 std::error_code initExportTablePtr();
433 uintptr_t getSymbolTable() const {
435 return reinterpret_cast<uintptr_t>(SymbolTable16);
437 return reinterpret_cast<uintptr_t>(SymbolTable32);
440 uint16_t getMachine() const {
442 return COFFHeader->Machine;
443 if (COFFBigObjHeader)
444 return COFFBigObjHeader->Machine;
445 llvm_unreachable("no COFF header!");
447 uint16_t getSizeOfOptionalHeader() const {
449 return COFFHeader->SizeOfOptionalHeader;
450 // bigobj doesn't have this field.
451 if (COFFBigObjHeader)
453 llvm_unreachable("no COFF header!");
455 uint16_t getCharacteristics() const {
457 return COFFHeader->Characteristics;
458 // bigobj doesn't have characteristics to speak of,
459 // editbin will silently lie to you if you attempt to set any.
460 if (COFFBigObjHeader)
462 llvm_unreachable("no COFF header!");
464 uint32_t getTimeDateStamp() const {
466 return COFFHeader->TimeDateStamp;
467 if (COFFBigObjHeader)
468 return COFFBigObjHeader->TimeDateStamp;
469 llvm_unreachable("no COFF header!");
471 uint32_t getNumberOfSections() const {
473 return COFFHeader->NumberOfSections;
474 if (COFFBigObjHeader)
475 return COFFBigObjHeader->NumberOfSections;
476 llvm_unreachable("no COFF header!");
478 uint32_t getPointerToSymbolTable() const {
480 return COFFHeader->PointerToSymbolTable;
481 if (COFFBigObjHeader)
482 return COFFBigObjHeader->PointerToSymbolTable;
483 llvm_unreachable("no COFF header!");
485 uint32_t getNumberOfSymbols() const {
487 return COFFHeader->NumberOfSymbols;
488 if (COFFBigObjHeader)
489 return COFFBigObjHeader->NumberOfSymbols;
490 llvm_unreachable("no COFF header!");
493 void moveSymbolNext(DataRefImpl &Symb) const override;
494 std::error_code getSymbolName(DataRefImpl Symb,
495 StringRef &Res) const override;
496 std::error_code getSymbolAddress(DataRefImpl Symb,
497 uint64_t &Res) const override;
498 std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
499 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
500 std::error_code getSymbolType(DataRefImpl Symb,
501 SymbolRef::Type &Res) const override;
502 std::error_code getSymbolSection(DataRefImpl Symb,
503 section_iterator &Res) const override;
504 void moveSectionNext(DataRefImpl &Sec) const override;
505 std::error_code getSectionName(DataRefImpl Sec,
506 StringRef &Res) const override;
507 std::error_code getSectionAddress(DataRefImpl Sec,
508 uint64_t &Res) const override;
509 std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
510 std::error_code getSectionContents(DataRefImpl Sec,
511 StringRef &Res) const override;
512 std::error_code getSectionAlignment(DataRefImpl Sec,
513 uint64_t &Res) const override;
514 std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
515 std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
516 std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
517 std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
518 std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
519 std::error_code isSectionReadOnlyData(DataRefImpl Sec,
520 bool &Res) const override;
521 std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
522 bool &Res) const override;
523 std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
524 bool &Result) const override;
525 relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
526 relocation_iterator section_rel_end(DataRefImpl Sec) const override;
528 void moveRelocationNext(DataRefImpl &Rel) const override;
529 std::error_code getRelocationAddress(DataRefImpl Rel,
530 uint64_t &Res) const override;
531 std::error_code getRelocationOffset(DataRefImpl Rel,
532 uint64_t &Res) const override;
533 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
534 std::error_code getRelocationType(DataRefImpl Rel,
535 uint64_t &Res) const override;
537 getRelocationTypeName(DataRefImpl Rel,
538 SmallVectorImpl<char> &Result) const override;
540 getRelocationValueString(DataRefImpl Rel,
541 SmallVectorImpl<char> &Result) const override;
544 COFFObjectFile(MemoryBufferRef Object, std::error_code &EC);
545 basic_symbol_iterator symbol_begin_impl() const override;
546 basic_symbol_iterator symbol_end_impl() const override;
547 section_iterator section_begin() const override;
548 section_iterator section_end() const override;
550 const coff_section *getCOFFSection(const SectionRef &Section) const;
551 COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const;
552 COFFSymbolRef getCOFFSymbol(const SymbolRef &Symbol) const;
553 const coff_relocation *getCOFFRelocation(const RelocationRef &Reloc) const;
555 uint8_t getBytesInAddress() const override;
556 StringRef getFileFormatName() const override;
557 unsigned getArch() const override;
559 import_directory_iterator import_directory_begin() const;
560 import_directory_iterator import_directory_end() const;
561 export_directory_iterator export_directory_begin() const;
562 export_directory_iterator export_directory_end() const;
564 std::error_code getPE32Header(const pe32_header *&Res) const;
565 std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const;
566 std::error_code getDataDirectory(uint32_t index,
567 const data_directory *&Res) const;
568 std::error_code getSection(int32_t index, const coff_section *&Res) const;
569 template <typename coff_symbol_type>
570 std::error_code getSymbol(uint32_t Index,
571 const coff_symbol_type *&Res) const {
572 if (Index < getNumberOfSymbols())
573 Res = reinterpret_cast<coff_symbol_type *>(getSymbolTable()) + Index;
575 return object_error::parse_failed;
576 return object_error::success;
578 ErrorOr<COFFSymbolRef> getSymbol(uint32_t index) const {
580 const coff_symbol16 *Symb = nullptr;
581 if (std::error_code EC = getSymbol(index, Symb))
583 return COFFSymbolRef(Symb);
586 const coff_symbol32 *Symb = nullptr;
587 if (std::error_code EC = getSymbol(index, Symb))
589 return COFFSymbolRef(Symb);
591 llvm_unreachable("no symbol table pointer!");
593 template <typename T>
594 std::error_code getAuxSymbol(uint32_t index, const T *&Res) const {
595 ErrorOr<COFFSymbolRef> s = getSymbol(index);
596 if (std::error_code EC = s.getError())
598 Res = reinterpret_cast<const T *>(s->getRawPtr());
599 return object_error::success;
601 std::error_code getSymbolName(COFFSymbolRef Symbol, StringRef &Res) const;
603 ArrayRef<uint8_t> getSymbolAuxData(COFFSymbolRef Symbol) const;
605 size_t getSymbolTableEntrySize() const {
607 return sizeof(coff_symbol16);
608 if (COFFBigObjHeader)
609 return sizeof(coff_symbol32);
610 llvm_unreachable("null symbol table pointer!");
613 std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
614 std::error_code getSectionContents(const coff_section *Sec,
615 ArrayRef<uint8_t> &Res) const;
617 std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
618 std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
619 std::error_code getHintName(uint32_t Rva, uint16_t &Hint,
620 StringRef &Name) const;
622 bool isRelocatableObject() const override;
624 static inline bool classof(const Binary *v) { return v->isCOFF(); }
627 // The iterator for the import directory table.
628 class ImportDirectoryEntryRef {
630 ImportDirectoryEntryRef() : OwningObject(nullptr) {}
631 ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
632 const COFFObjectFile *Owner)
633 : ImportTable(Table), Index(I), OwningObject(Owner) {}
635 bool operator==(const ImportDirectoryEntryRef &Other) const;
637 std::error_code getName(StringRef &Result) const;
640 getImportTableEntry(const import_directory_table_entry *&Result) const;
643 getImportLookupEntry(const import_lookup_table_entry32 *&Result) const;
646 const import_directory_table_entry *ImportTable;
648 const COFFObjectFile *OwningObject;
651 // The iterator for the export directory table entry.
652 class ExportDirectoryEntryRef {
654 ExportDirectoryEntryRef() : OwningObject(nullptr) {}
655 ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
656 const COFFObjectFile *Owner)
657 : ExportTable(Table), Index(I), OwningObject(Owner) {}
659 bool operator==(const ExportDirectoryEntryRef &Other) const;
662 std::error_code getDllName(StringRef &Result) const;
663 std::error_code getOrdinalBase(uint32_t &Result) const;
664 std::error_code getOrdinal(uint32_t &Result) const;
665 std::error_code getExportRVA(uint32_t &Result) const;
666 std::error_code getSymbolName(StringRef &Result) const;
669 const export_directory_table_entry *ExportTable;
671 const COFFObjectFile *OwningObject;
673 } // end namespace object
674 } // end namespace llvm