]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/DLL.h
MFV r309299:
[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 getChunks() to get a list of chunks.
23 class IdataContents {
24 public:
25   void add(DefinedImportData *Sym) { Imports.push_back(Sym); }
26   bool empty() { return Imports.empty(); }
27   std::vector<Chunk *> getChunks();
28
29   uint64_t getDirRVA() { return Dirs[0]->getRVA(); }
30   uint64_t getDirSize();
31   uint64_t getIATRVA() { return Addresses[0]->getRVA(); }
32   uint64_t getIATSize();
33
34 private:
35   void create();
36
37   std::vector<DefinedImportData *> Imports;
38   std::vector<std::unique_ptr<Chunk>> Dirs;
39   std::vector<std::unique_ptr<Chunk>> Lookups;
40   std::vector<std::unique_ptr<Chunk>> Addresses;
41   std::vector<std::unique_ptr<Chunk>> Hints;
42   std::map<StringRef, std::unique_ptr<Chunk>> DLLNames;
43 };
44
45 // Windows-specific.
46 // DelayLoadContents creates all chunks for the delay-load DLL import table.
47 class DelayLoadContents {
48 public:
49   void add(DefinedImportData *Sym) { Imports.push_back(Sym); }
50   bool empty() { return Imports.empty(); }
51   void create(Defined *Helper);
52   std::vector<Chunk *> getChunks();
53   std::vector<Chunk *> getDataChunks();
54   std::vector<std::unique_ptr<Chunk>> &getCodeChunks() { return Thunks; }
55
56   uint64_t getDirRVA() { return Dirs[0]->getRVA(); }
57   uint64_t getDirSize();
58
59 private:
60   Chunk *newThunkChunk(DefinedImportData *S, Chunk *Dir);
61
62   Defined *Helper;
63   std::vector<DefinedImportData *> Imports;
64   std::vector<std::unique_ptr<Chunk>> Dirs;
65   std::vector<std::unique_ptr<Chunk>> ModuleHandles;
66   std::vector<std::unique_ptr<Chunk>> Addresses;
67   std::vector<std::unique_ptr<Chunk>> Names;
68   std::vector<std::unique_ptr<Chunk>> HintNames;
69   std::vector<std::unique_ptr<Chunk>> Thunks;
70   std::map<StringRef, std::unique_ptr<Chunk>> DLLNames;
71 };
72
73 // Windows-specific.
74 // EdataContents creates all chunks for the DLL export table.
75 class EdataContents {
76 public:
77   EdataContents();
78   std::vector<std::unique_ptr<Chunk>> Chunks;
79 };
80
81 } // namespace coff
82 } // namespace lld
83
84 #endif