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
;
37 // DelayLoadContents creates all chunks for the delay-load DLL import table.
38 class DelayLoadContents
{
40 DelayLoadContents(COFFLinkerContext
&ctx
) : ctx(ctx
) {}
41 void add(DefinedImportData
*sym
) { imports
.push_back(sym
); }
42 bool empty() { return imports
.empty(); }
43 void create(Defined
*helper
);
44 std::vector
<Chunk
*> getChunks();
45 std::vector
<Chunk
*> getDataChunks();
46 ArrayRef
<Chunk
*> getCodeChunks() { return thunks
; }
47 ArrayRef
<Chunk
*> getCodePData() { return pdata
; }
48 ArrayRef
<Chunk
*> getCodeUnwindInfo() { return unwindinfo
; }
50 uint64_t getDirRVA() { return dirs
[0]->getRVA(); }
51 uint64_t getDirSize();
54 Chunk
*newThunkChunk(DefinedImportData
*s
, Chunk
*tailMerge
);
55 Chunk
*newTailMergeChunk(Chunk
*dir
);
56 Chunk
*newTailMergePDataChunk(Chunk
*tm
, Chunk
*unwind
);
57 Chunk
*newTailMergeUnwindInfoChunk();
60 std::vector
<DefinedImportData
*> imports
;
61 std::vector
<Chunk
*> dirs
;
62 std::vector
<Chunk
*> moduleHandles
;
63 std::vector
<Chunk
*> addresses
;
64 std::vector
<Chunk
*> names
;
65 std::vector
<Chunk
*> hintNames
;
66 std::vector
<Chunk
*> thunks
;
67 std::vector
<Chunk
*> pdata
;
68 std::vector
<Chunk
*> unwindinfo
;
69 std::vector
<Chunk
*> dllNames
;
71 COFFLinkerContext
&ctx
;
75 // EdataContents creates all chunks for the DLL export table.
78 EdataContents(COFFLinkerContext
&ctx
);
79 std::vector
<Chunk
*> chunks
;
81 uint64_t getRVA() { return chunks
[0]->getRVA(); }
83 return chunks
.back()->getRVA() + chunks
.back()->getSize() - getRVA();
86 COFFLinkerContext
&ctx
;
89 } // namespace lld::coff