]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/DLL.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / COFF / DLL.h
1 //===- DLL.h ----------------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_COFF_DLL_H
11 #define LLD_COFF_DLL_H
12
13 #include "Chunks.h"
14 #include "Symbols.h"
15
16 namespace lld {
17 namespace coff {
18
19 // Windows-specific.
20 // IdataContents creates all chunks for the DLL import table.
21 // You are supposed to call add() to add symbols and then
22 // call create() to populate the chunk vectors.
23 class IdataContents {
24 public:
25   void add(DefinedImportData *Sym) { Imports.push_back(Sym); }
26   bool empty() { return Imports.empty(); }
27
28   void create();
29
30   std::vector<DefinedImportData *> Imports;
31   std::vector<Chunk *> Dirs;
32   std::vector<Chunk *> Lookups;
33   std::vector<Chunk *> Addresses;
34   std::vector<Chunk *> Hints;
35   std::vector<Chunk *> DLLNames;
36 };
37
38 // Windows-specific.
39 // DelayLoadContents creates all chunks for the delay-load DLL import table.
40 class DelayLoadContents {
41 public:
42   void add(DefinedImportData *Sym) { Imports.push_back(Sym); }
43   bool empty() { return Imports.empty(); }
44   void create(Defined *Helper);
45   std::vector<Chunk *> getChunks();
46   std::vector<Chunk *> getDataChunks();
47   ArrayRef<Chunk *> getCodeChunks() { return Thunks; }
48
49   uint64_t getDirRVA() { return Dirs[0]->getRVA(); }
50   uint64_t getDirSize();
51
52 private:
53   Chunk *newThunkChunk(DefinedImportData *S, 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
73   uint64_t getRVA() { return Chunks[0]->getRVA(); }
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