1 //===- DLL.h ----------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 #define LLD_COFF_DLL_H
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.
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
;
39 // DelayLoadContents creates all chunks for the delay-load DLL import table.
40 class DelayLoadContents
{
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();
58 Chunk
*newThunkChunk(DefinedImportData
*s
, Chunk
*tailMerge
);
59 Chunk
*newTailMergeChunk(Chunk
*dir
);
60 Chunk
*newTailMergePDataChunk(Chunk
*tm
, Chunk
*unwind
);
61 Chunk
*newTailMergeUnwindInfoChunk();
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
;
81 // EdataContents creates all chunks for the DLL export table.
84 EdataContents(COFFLinkerContext
&ctx
);
85 std::vector
<Chunk
*> chunks
;
87 uint64_t getRVA() { return chunks
[0]->getRVA(); }
89 return chunks
.back()->getRVA() + chunks
.back()->getSize() - getRVA();
92 COFFLinkerContext
&ctx
;
95 } // namespace lld::coff