[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / lld / COFF / DLL.h
blobf7d2b57a20a02096f80944e448cae9b41200cf5c
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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_COFF_DLL_H
10 #define LLD_COFF_DLL_H
12 #include "Chunks.h"
13 #include "Symbols.h"
15 namespace lld::coff {
17 // Windows-specific.
18 // IdataContents creates all chunks for the DLL import table.
19 // You are supposed to call add() to add symbols and then
20 // call create() to populate the chunk vectors.
21 class IdataContents {
22 public:
23 void add(DefinedImportData *sym) { imports.push_back(sym); }
24 bool empty() { return imports.empty(); }
26 void create(COFFLinkerContext &ctx);
28 std::vector<DefinedImportData *> imports;
29 std::vector<Chunk *> dirs;
30 std::vector<Chunk *> lookups;
31 std::vector<Chunk *> addresses;
32 std::vector<Chunk *> hints;
33 std::vector<Chunk *> dllNames;
34 std::vector<Chunk *> auxIat;
35 std::vector<Chunk *> auxIatCopy;
38 // Windows-specific.
39 // DelayLoadContents creates all chunks for the delay-load DLL import table.
40 class DelayLoadContents {
41 public:
42 DelayLoadContents(COFFLinkerContext &ctx) : ctx(ctx) {}
43 void add(DefinedImportData *sym) { imports.push_back(sym); }
44 bool empty() { return imports.empty(); }
45 void create(Defined *helper);
46 std::vector<Chunk *> getChunks();
47 std::vector<Chunk *> getDataChunks();
48 ArrayRef<Chunk *> getCodeChunks() { return thunks; }
49 ArrayRef<Chunk *> getCodePData() { return pdata; }
50 ArrayRef<Chunk *> getCodeUnwindInfo() { return unwindinfo; }
51 ArrayRef<Chunk *> getAuxIat() { return auxIat; }
52 ArrayRef<Chunk *> getAuxIatCopy() { return auxIatCopy; }
54 uint64_t getDirRVA() { return dirs[0]->getRVA(); }
55 uint64_t getDirSize();
57 private:
58 Chunk *newThunkChunk(DefinedImportData *s, Chunk *tailMerge);
59 Chunk *newTailMergeChunk(Chunk *dir);
60 Chunk *newTailMergePDataChunk(Chunk *tm, Chunk *unwind);
61 Chunk *newTailMergeUnwindInfoChunk();
63 Defined *helper;
64 std::vector<DefinedImportData *> imports;
65 std::vector<Chunk *> dirs;
66 std::vector<Chunk *> moduleHandles;
67 std::vector<Chunk *> addresses;
68 std::vector<Chunk *> names;
69 std::vector<Chunk *> hintNames;
70 std::vector<Chunk *> thunks;
71 std::vector<Chunk *> pdata;
72 std::vector<Chunk *> unwindinfo;
73 std::vector<Chunk *> dllNames;
74 std::vector<Chunk *> auxIat;
75 std::vector<Chunk *> auxIatCopy;
77 COFFLinkerContext &ctx;
80 // Windows-specific.
81 // EdataContents creates all chunks for the DLL export table.
82 class EdataContents {
83 public:
84 EdataContents(COFFLinkerContext &ctx);
85 std::vector<Chunk *> chunks;
87 uint64_t getRVA() { return chunks[0]->getRVA(); }
88 uint64_t getSize() {
89 return chunks.back()->getRVA() + chunks.back()->getSize() - getRVA();
92 COFFLinkerContext &ctx;
95 } // namespace lld::coff
97 #endif