1 //===- DLL.h ----------------------------------------------------*- 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 #ifndef LLD_COFF_DLL_H 10 #define LLD_COFF_DLL_H 11 12 #include "Chunks.h" 13 #include "Symbols.h" 14 15 namespace lld { 16 namespace coff { 17 18 // Windows-specific. 19 // IdataContents creates all chunks for the DLL import table. 20 // You are supposed to call add() to add symbols and then 21 // call create() to populate the chunk vectors. 22 class IdataContents { 23 public: add(DefinedImportData * sym)24 void add(DefinedImportData *sym) { imports.push_back(sym); } empty()25 bool empty() { return imports.empty(); } 26 27 void create(); 28 29 std::vector<DefinedImportData *> imports; 30 std::vector<Chunk *> dirs; 31 std::vector<Chunk *> lookups; 32 std::vector<Chunk *> addresses; 33 std::vector<Chunk *> hints; 34 std::vector<Chunk *> dllNames; 35 }; 36 37 // Windows-specific. 38 // DelayLoadContents creates all chunks for the delay-load DLL import table. 39 class DelayLoadContents { 40 public: add(DefinedImportData * sym)41 void add(DefinedImportData *sym) { imports.push_back(sym); } empty()42 bool empty() { return imports.empty(); } 43 void create(Defined *helper); 44 std::vector<Chunk *> getChunks(); 45 std::vector<Chunk *> getDataChunks(); getCodeChunks()46 ArrayRef<Chunk *> getCodeChunks() { return thunks; } 47 getDirRVA()48 uint64_t getDirRVA() { return dirs[0]->getRVA(); } 49 uint64_t getDirSize(); 50 51 private: 52 Chunk *newThunkChunk(DefinedImportData *s, Chunk *tailMerge); 53 Chunk *newTailMergeChunk(Chunk *dir); 54 55 Defined *helper; 56 std::vector<DefinedImportData *> imports; 57 std::vector<Chunk *> dirs; 58 std::vector<Chunk *> moduleHandles; 59 std::vector<Chunk *> addresses; 60 std::vector<Chunk *> names; 61 std::vector<Chunk *> hintNames; 62 std::vector<Chunk *> thunks; 63 std::vector<Chunk *> dllNames; 64 }; 65 66 // Windows-specific. 67 // EdataContents creates all chunks for the DLL export table. 68 class EdataContents { 69 public: 70 EdataContents(); 71 std::vector<Chunk *> chunks; 72 getRVA()73 uint64_t getRVA() { return chunks[0]->getRVA(); } getSize()74 uint64_t getSize() { 75 return chunks.back()->getRVA() + chunks.back()->getSize() - getRVA(); 76 } 77 }; 78 79 } // namespace coff 80 } // namespace lld 81 82 #endif 83