1 //===- COFFLinkerContext.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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_COFF_COFFLINKERCONTEXT_H
10 #define LLD_COFF_COFFLINKERCONTEXT_H
14 #include "DebugTypes.h"
16 #include "InputFiles.h"
17 #include "SymbolTable.h"
19 #include "lld/Common/CommonLinkerContext.h"
20 #include "lld/Common/Timer.h"
24 class COFFLinkerContext
: public CommonLinkerContext
{
27 COFFLinkerContext(const COFFLinkerContext
&) = delete;
28 COFFLinkerContext
&operator=(const COFFLinkerContext
&) = delete;
29 ~COFFLinkerContext() = default;
33 COFFOptTable optTable
;
35 // A hybrid ARM64EC symbol table on ARM64X target.
36 std::optional
<SymbolTable
> hybridSymtab
;
38 // Pointer to the ARM64EC symbol table: either symtab for an ARM64EC target or
39 // hybridSymtab for an ARM64X target.
40 SymbolTable
*symtabEC
= nullptr;
42 // Returns the appropriate symbol table for the specified machine type.
43 SymbolTable
&getSymtab(llvm::COFF::MachineTypes machine
) {
44 if (hybridSymtab
&& (machine
== ARM64EC
|| machine
== AMD64
))
49 // Invoke the specified callback for each symbol table.
50 void forEachSymtab(std::function
<void(SymbolTable
&symtab
)> f
) {
56 std::vector
<ObjFile
*> objFileInstances
;
57 std::map
<std::string
, PDBInputFile
*> pdbInputFileInstances
;
58 std::vector
<ImportFile
*> importFileInstances
;
59 std::vector
<BitcodeFile
*> bitcodeFileInstances
;
61 MergeChunk
*mergeChunkInstances
[Log2MaxSectionAlignment
+ 1] = {};
63 /// All sources of type information in the program.
64 std::vector
<TpiSource
*> tpiSourceList
;
66 void addTpiSource(TpiSource
*tpi
) { tpiSourceList
.push_back(tpi
); }
68 std::map
<llvm::codeview::GUID
, TpiSource
*> typeServerSourceMappings
;
69 std::map
<uint32_t, TpiSource
*> precompSourceMappings
;
71 /// List of all output sections. After output sections are finalized, this
72 /// can be indexed by getOutputSection.
73 std::vector
<OutputSection
*> outputSections
;
75 OutputSection
*getOutputSection(const Chunk
*c
) const {
76 return c
->osidx
== 0 ? nullptr : outputSections
[c
->osidx
- 1];
79 // Fake sections for parsing bitcode files.
80 FakeSection ltoTextSection
;
81 FakeSection ltoDataSection
;
82 FakeSectionChunk ltoTextSectionChunk
;
83 FakeSectionChunk ltoDataSectionChunk
;
85 // All timers used in the COFF linker.
93 Timer codeLayoutTimer
;
94 Timer outputCommitTimer
;
96 Timer symbolGatherTimer
;
97 Timer symbolStringsTimer
;
101 Timer totalPdbLinkTimer
;
102 Timer addObjectsTimer
;
103 Timer typeMergingTimer
;
104 Timer loadGHashTimer
;
105 Timer mergeGHashTimer
;
106 Timer symbolMergingTimer
;
107 Timer publicsLayoutTimer
;
108 Timer tpiStreamLayoutTimer
;
109 Timer diskCommitTimer
;
111 Configuration config
;
113 DynamicRelocsChunk
*dynamicRelocs
= nullptr;
116 } // namespace lld::coff