blob: 5105b79f15d31aced3e3a3561304a3b4460d5941 [file] [log] [blame]
Rafael Espindolabeee25e2015-08-14 14:12:541//===- DLL.h ----------------------------------------------------*- C++ -*-===//
Rui Ueyama4b22fa72015-06-07 01:15:042//
Chandler Carruth2946cd72019-01-19 08:50:563// 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
Rui Ueyama4b22fa72015-06-07 01:15:046//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_COFF_DLL_H
10#define LLD_COFF_DLL_H
11
12#include "Chunks.h"
13#include "Symbols.h"
14
Nico Weber7c266412022-08-08 15:32:2615namespace lld::coff {
Rui Ueyama4b22fa72015-06-07 01:15:0416
17// Windows-specific.
Rui Ueyama97dff9e2015-06-17 00:16:3318// IdataContents creates all chunks for the DLL import table.
Rui Ueyama4b22fa72015-06-07 01:15:0419// You are supposed to call add() to add symbols and then
Martin Storsjo5f6d5272018-09-21 22:01:0620// call create() to populate the chunk vectors.
Rui Ueyama4b22fa72015-06-07 01:15:0421class IdataContents {
22public:
Rui Ueyama136d27a2019-07-11 05:40:3023 void add(DefinedImportData *sym) { imports.push_back(sym); }
24 bool empty() { return imports.empty(); }
Rui Ueyama4b22fa72015-06-07 01:15:0425
Amy Huang5a58b192023-01-10 04:37:2826 void create(COFFLinkerContext &ctx);
Rui Ueyama4b22fa72015-06-07 01:15:0427
Rui Ueyama136d27a2019-07-11 05:40:3028 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;
Jacek Caban82a36462024-09-12 20:20:5034 std::vector<Chunk *> auxIat;
Jacek Cabana17a2452024-09-17 12:40:2435 std::vector<Chunk *> auxIatCopy;
Rui Ueyama4b22fa72015-06-07 01:15:0436};
37
Rui Ueyama97dff9e2015-06-17 00:16:3338// Windows-specific.
Rui Ueyamaa77336b2015-06-21 22:31:5239// DelayLoadContents creates all chunks for the delay-load DLL import table.
40class DelayLoadContents {
41public:
Amy Huang5a58b192023-01-10 04:37:2842 DelayLoadContents(COFFLinkerContext &ctx) : ctx(ctx) {}
Rui Ueyama136d27a2019-07-11 05:40:3043 void add(DefinedImportData *sym) { imports.push_back(sym); }
44 bool empty() { return imports.empty(); }
Jacek Caban97aa56a2025-01-28 11:07:3545 void create();
Rui Ueyama382dc962015-06-26 21:40:1546 std::vector<Chunk *> getChunks();
47 std::vector<Chunk *> getDataChunks();
Rui Ueyama136d27a2019-07-11 05:40:3048 ArrayRef<Chunk *> getCodeChunks() { return thunks; }
serge-sans-paillec512eda2023-01-13 13:25:5449 ArrayRef<Chunk *> getCodePData() { return pdata; }
50 ArrayRef<Chunk *> getCodeUnwindInfo() { return unwindinfo; }
Jacek Caban18fa9fa2024-09-30 18:26:5551 ArrayRef<Chunk *> getAuxIat() { return auxIat; }
52 ArrayRef<Chunk *> getAuxIatCopy() { return auxIatCopy; }
Rui Ueyamaa77336b2015-06-21 22:31:5253
Rui Ueyama136d27a2019-07-11 05:40:3054 uint64_t getDirRVA() { return dirs[0]->getRVA(); }
Rui Ueyamaa77336b2015-06-21 22:31:5255 uint64_t getDirSize();
56
57private:
Martin Storsjo6bd26db2019-07-11 21:19:1158 Chunk *newThunkChunk(DefinedImportData *s, Chunk *tailMerge);
Jacek Caban97aa56a2025-01-28 11:07:3559 Chunk *newTailMergeChunk(SymbolTable &symtab, Chunk *dir);
60 Chunk *newTailMergePDataChunk(SymbolTable &symtab, Chunk *tm);
Rui Ueyama35ccb0f2015-07-25 00:20:0661
Rui Ueyama136d27a2019-07-11 05:40:3062 std::vector<DefinedImportData *> imports;
63 std::vector<Chunk *> dirs;
64 std::vector<Chunk *> moduleHandles;
65 std::vector<Chunk *> addresses;
66 std::vector<Chunk *> names;
67 std::vector<Chunk *> hintNames;
68 std::vector<Chunk *> thunks;
serge-sans-paillec512eda2023-01-13 13:25:5469 std::vector<Chunk *> pdata;
70 std::vector<Chunk *> unwindinfo;
Rui Ueyama136d27a2019-07-11 05:40:3071 std::vector<Chunk *> dllNames;
Jacek Caban18fa9fa2024-09-30 18:26:5572 std::vector<Chunk *> auxIat;
73 std::vector<Chunk *> auxIatCopy;
Amy Huang5a58b192023-01-10 04:37:2874
75 COFFLinkerContext &ctx;
Rui Ueyamaa77336b2015-06-21 22:31:5276};
77
Jacek Caban2cfddda2025-01-20 22:02:2678// Create all chunks for the DLL export table.
Jacek Caban455b3d62025-01-21 09:41:1579void createEdataChunks(SymbolTable &symtab, std::vector<Chunk *> &chunks);
Rui Ueyama97dff9e2015-06-17 00:16:3380
Nico Weber7c266412022-08-08 15:32:2681} // namespace lld::coff
Rui Ueyama4b22fa72015-06-07 01:15:0482
83#endif