forked from qualcomm/eld
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.h
More file actions
731 lines (572 loc) · 23.9 KB
/
Copy pathModule.h
File metadata and controls
731 lines (572 loc) · 23.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
//===- Module.h------------------------------------------------------------===//
// Part of the eld Project, under the BSD License
// See https://github.com/qualcomm/eld/LICENSE.txt for license information.
// SPDX-License-Identifier: BSD-3-Clause
//===----------------------------------------------------------------------===//
//
// The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Module contains the intermediate representation (LDIR) of MCLinker.
//
//===----------------------------------------------------------------------===//
#ifndef ELD_CORE_MODULE_H
#define ELD_CORE_MODULE_H
#include "eld/Config/GeneralOptions.h"
#include "eld/Core/Linker.h"
#include "eld/Core/LinkState.h"
#include "eld/Input/InputFile.h"
#include "eld/LayoutMap/LayoutInfo.h"
#include "eld/Plugin/PluginActivityLog.h"
#include "eld/Plugin/PluginManager.h"
#include "eld/PluginAPI/LinkerWrapper.h"
#include "eld/Script/StrToken.h"
#include "eld/Script/VersionScript.h"
#include "eld/Support/OutputTarWriter.h"
#include "eld/SymbolResolver/IRBuilder.h"
#include "eld/SymbolResolver/NamePool.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include <array>
#include <climits>
#include <mutex>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace llvm {
class StringSaver;
} // namespace llvm
namespace eld {
class BitcodeFile;
class CommonELFSection;
class Input;
class Section;
class LinkerScript;
class ELFSection;
class EhFrameHdrSection;
class LDSymbol;
class Linker;
class Plugin;
class PluginData;
class TextLayoutPrinter;
class YamlLayoutPrinter;
class Relocation;
class ExternCmd;
class ScriptSymbol;
/** \class Module
* \brief Module provides the intermediate representation for linking.
*/
class Module {
public:
typedef enum {
Attributes,
BitcodeSections,
Common,
CopyRelocSymbols,
DynamicExports,
DynamicList,
DynamicSections,
EhFrameFiller,
EhFrameHdr,
Exception,
ExternList,
Guard,
LinkerVersion,
OutputSectData,
Plugin,
Script,
Sections,
SectionRelocMap,
SmallData,
TableJump,
Timing,
TLSStub,
Trampoline,
GlobalDataSymbols,
GNUBuildID,
SFrameHdr,
#ifdef ELD_ENABLE_SYMBOL_VERSIONING
SymbolVersioning,
#endif
MAX
} InternalInputType;
typedef std::vector<InputFile *> ObjectList;
typedef ObjectList::iterator obj_iterator;
typedef ObjectList::const_iterator const_obj_iterator;
typedef std::vector<InputFile *> LibraryList;
typedef LibraryList::iterator lib_iterator;
typedef LibraryList::const_iterator const_lib_iterator;
typedef std::vector<ELFSection *> SectionTable;
typedef SectionTable::iterator iterator;
typedef SectionTable::const_iterator const_iterator;
typedef std::vector<StrToken *> ListSyms;
typedef ListSyms::iterator ListSyms_iterator;
typedef ListSyms::const_iterator const_ListSyms_iterator;
typedef std::array<InputFile *, MAX> InternalInputArray;
typedef std::vector<const VersionScriptNode *> VersionScriptNodes;
typedef llvm::StringMap<ObjectReader::GroupSignatureInfo *> GroupSignatureMap;
typedef std::unordered_map<std::string, size_t> NoCrossRefSet;
typedef std::vector<std::pair<FragmentRef *, MemoryArea *>>
ReplaceFragsVectorT;
typedef std::unordered_map<std::string, std::vector<PluginData *>>
PluginDataMapT;
typedef std::unordered_map<const Section *, std::vector<ResolveInfo *>>
ReferencedSymbols;
typedef std::vector<ScriptSymbol *> ScriptSymbolList;
typedef std::pair<uint64_t, uint64_t> DynamicListStartEndIndexPair;
public:
explicit Module(LinkerScript &CurScript, LinkerConfig &Config,
LayoutInfo *LayoutInfo);
~Module();
LinkerScript &getScript() const { return UserLinkerScript; }
LinkerConfig &getConfig() const { return ThisConfig; }
const LinkerScript &getLinkerScript() const { return UserLinkerScript; }
LinkerScript &getLinkerScript() { return UserLinkerScript; }
// ----- link-in objects ----- //
std::vector<InputFile *> &getObjectList() { return InputObjectList; }
const std::vector<InputFile *> &getObjectList() const {
return InputObjectList;
}
obj_iterator objBegin() { return InputObjectList.begin(); }
obj_iterator objEnd() { return InputObjectList.end(); }
void insertLTOObjects(obj_iterator Iter, std::vector<InputFile *> &Inp) {
InputObjectList.insert(Iter, Inp.begin(), Inp.end());
}
// ----- link-in libraries ----- //
LibraryList &getDynLibraryList() { return DynLibraryList; }
LibraryList &getArchiveLibraryList() { return ArchiveLibraryList; }
/// @}
/// @name Section Accessors
/// @{
// ----- sections ----- //
const SectionTable &getSectionTable() const { return OutputSectionTable; }
SectionTable &getSectionTable() { return OutputSectionTable; }
void clearOutputSections() {
OutputSectionTable.clear();
OutputSectionTableMap.clear();
}
void addOutputSectionToTable(ELFSection *S) {
OutputSectionTableMap[S->name()] = S;
}
void addOutputSection(ELFSection *S) {
OutputSectionTable.push_back(S);
OutputSectionTableMap[S->name()] = S;
}
iterator begin() { return OutputSectionTable.begin(); }
const_iterator begin() const { return OutputSectionTable.begin(); }
iterator end() { return OutputSectionTable.end(); }
const_iterator end() const { return OutputSectionTable.end(); }
ELFSection *front() { return OutputSectionTable.front(); }
const ELFSection *front() const { return OutputSectionTable.front(); }
ELFSection *back() { return OutputSectionTable.back(); }
const ELFSection *back() const { return OutputSectionTable.back(); }
size_t size() const { return OutputSectionTable.size(); }
bool empty() const { return OutputSectionTable.empty(); }
ELFSection *getSection(const std::string &Name) const;
/// @}
/// @name Symbol Accessors
/// @{
const NamePool &getNamePool() const { return SymbolNamePool; }
NamePool &getNamePool() { return SymbolNamePool; }
// ------ Dynamic List symbols ----//
ScriptSymbolList &dynListSyms() { return DynamicListSymbols; }
VersionScriptNodes &getVersionScriptNodes() {
return LinkerVersionScriptNodes;
}
void addVersionScriptNode(const VersionScriptNode *N) {
LinkerVersionScriptNodes.push_back(N);
}
void clear();
void addToCopyFarCallSet(llvm::StringRef Sym) {
DuplicateFarCalls.insert(Sym);
}
bool findInCopyFarCallSet(llvm::StringRef Sym) const {
if (DuplicateFarCalls.find(Sym) != DuplicateFarCalls.end())
return true;
return false;
}
void removeFromCopyFarCallSet(llvm::StringRef Sym) {
DuplicateFarCalls.erase(DuplicateFarCalls.find(Sym));
}
void addToNoReuseOfTrampolines(llvm::StringRef Sym) {
NoReuseTrampolines.insert(Sym);
}
bool findCanReuseTrampolinesForSymbol(llvm::StringRef Sym) const {
if (NoReuseTrampolines.find(Sym) != NoReuseTrampolines.end())
return true;
return false;
}
// Find the common symbol recorded previously.
InputFile *findCommon(std::string Name) const {
auto It = CommonMap.find(Name);
if (It == CommonMap.end())
return nullptr;
return It->getValue();
}
// Record commons as we dont have a section for them.
void recordCommon(std::string Name, InputFile *I) { CommonMap[Name] = I; }
void setDotSymbol(LDSymbol *S) { DotSymbol = S; }
LDSymbol *getDotSymbol() const { return DotSymbol; }
eld::IRBuilder *getIRBuilder() const;
void setFailure(bool Fails = false);
bool linkFail() const { return Failure; }
Linker *getLinker() const { return L; }
void setLinker(Linker *linker) { L = linker; }
bool createInternalInputs();
InputFile *createInternalInputFile(Input *I, bool CreateElfObjectFile);
InputFile *getInternalInput(InternalInputType Type) const {
return InternalFiles[Type];
}
InternalInputArray &getInternalFiles() { return InternalFiles; }
InternalInputArray::iterator beginInternalFiles() {
return std::begin(InternalFiles);
}
InternalInputArray::iterator endInternalFiles() {
return std::end(InternalFiles);
}
ELFSection *createOutputSection(const std::string &Name,
LDFileFormat::Kind PKind, uint32_t Type,
uint32_t PFlag, uint32_t PAlign);
ELFSection *createInternalSection(InputFile &I, LDFileFormat::Kind K,
std::string Name, uint32_t Type,
uint32_t PFlag, uint32_t PAlign,
uint32_t EntSize = 0);
ELFSection *createInternalSection(InternalInputType Type,
LDFileFormat::Kind K, std::string Name,
uint32_t SectionType, uint32_t Flag,
uint32_t Align, uint32_t EntSize = 0) {
return createInternalSection(*InternalFiles[Type], K, Name, SectionType,
Flag, Align, EntSize);
}
EhFrameHdrSection *createEhFrameHdrSection(InternalInputType IType,
std::string Name, uint32_t Type,
uint32_t PFlag, uint32_t PAlign);
LayoutInfo *getLayoutInfo() { return ThisLayoutInfo; }
// Section symbols and all other symbols that live in the output.
void recordSectionSymbol(ELFSection *S, ResolveInfo *R) {
SectionSymbol[S] = R;
}
ResolveInfo *getSectionSymbol(ELFSection *S) {
auto Iter = SectionSymbol.find(S);
if (Iter == SectionSymbol.end())
return nullptr;
return Iter->second;
}
void addSymbol(ResolveInfo *R);
LDSymbol *addSymbolFromBitCode(BitcodeFile &CurInput, const std::string &Name,
ResolveInfo::Type Type, ResolveInfo::Desc Desc,
ResolveInfo::Binding Binding,
ResolveInfo::SizeType Size,
ResolveInfo::Visibility Visibility,
unsigned int PIdx);
const std::vector<ResolveInfo *> &getSymbols() const { return Symbols; }
std::vector<ResolveInfo *> &getSymbols() { return Symbols; }
// Common symbols.
void addCommonSymbol(ResolveInfo *R) { CommonSymbols.push_back(R); }
std::vector<ResolveInfo *> &getCommonSymbols() { return CommonSymbols; }
bool sortCommonSymbols();
bool sortSymbols();
GroupSignatureMap &signatureMap() { return SectionGroupSignatureMap; }
// ------------------Plugin Support-----------------------------------
bool readPluginConfig();
bool updateOutputSectionsWithPlugins();
// -------------------Linker script symbol and GC support ----------
void addAssignment(llvm::StringRef SymName, const Assignment *A) {
AssignmentsLive[SymName] = A;
}
const Assignment *getAssignmentForSymbol(llvm::StringRef Sym) {
auto AssignExpr = AssignmentsLive.find(Sym);
if (AssignExpr == AssignmentsLive.end())
return nullptr;
return AssignExpr->getValue();
}
// Save the binding info for symbols taking part in --wrap
void saveWrapSymBinding(llvm::StringRef Name, uint32_t Binding) {
WrapBindings[Name] = Binding;
}
uint32_t getWrapSymBinding(llvm::StringRef Name) const {
assert(WrapBindings.count(Name) != 0);
auto Entry = WrapBindings.find(Name);
if (Entry != WrapBindings.end())
return Entry->second;
return ResolveInfo::NoneBinding;
}
void saveWrapReference(llvm::StringRef Name) {
WrappedReferences.insert(Name);
}
bool hasWrapReference(llvm::StringRef Name) const {
return WrappedReferences.count(Name);
}
NoCrossRefSet &getNonRefSections() { return NonRefSections; }
/* Add support for symbols that need to be selected from archive, if the
* symbol remains to be undefined */
void addNeededSymbol(llvm::StringRef S) { NeededSymbols.insert(S); }
bool hasSymbolInNeededSet(llvm::StringRef S) {
return (NeededSymbols.find(S) != NeededSymbols.end());
}
/// ------------- LTO-related functions ------------------
/// A flag that is used to check if LTO is really needed.
bool needLTOToBeInvoked() const { return UsesLto; }
void setLTONeeded() { UsesLto = true; }
bool isPostLTOPhase() const;
/// Set linker state.
/// On updating the state, this function also checks linker invariants for
/// the state. It returns true if all the invariants are true; Otherwise it
/// returns false.
bool setLinkState(LinkState S);
LinkState getState() const { return State; }
llvm::StringRef getStateStr() const;
void addSymbolCreatedByPluginToFragment(Fragment *F, std::string Name,
uint64_t Val,
const eld::Plugin *Plugin);
// Create a Plugin Fragment.
Fragment *createPluginFillFragment(std::string PluginName, uint32_t Alignment,
uint32_t PaddingSize);
// Create a Code Fragment
Fragment *createPluginCodeFragment(std::string PluginName, std::string Name,
uint32_t Alignment, const char *Buf,
size_t Sz);
// Create a Data fragment
Fragment *createPluginDataFragment(std::string PluginName, std::string Name,
uint32_t Alignment, const char *Buf,
size_t Sz);
// Create a Data fragment wtih custom section name
Fragment *
createPluginDataFragmentWithCustomName(const std::string &PluginName,
std::string Name, uint32_t Alignment,
const char *Buf, size_t Size);
// Create a .bss fragment
Fragment *createPluginBSSFragment(std::string PluginName, std::string Name,
uint32_t Alignment, size_t Sz);
// Create a Note fragment wtih custom section name
Fragment *createPluginFragmentWithCustomName(std::string Name,
size_t SectType,
size_t SectFlags,
uint32_t Alignment,
const char *Buf, size_t Size);
// Get backend
GNULDBackend &getBackend() const;
void replaceFragment(FragmentRef *F, const uint8_t *Data, size_t Sz);
ReplaceFragsVectorT &getReplaceFrags() { return ReplaceFrags; }
void addPluginFrag(Fragment *);
/// ------------- Record Plugin Data functionality ------------------
void recordPluginData(std::string PluginName, uint32_t Key, void *Data,
std::string Annotation);
std::vector<eld::PluginData *> getPluginData(std::string PluginName);
/// OutputTarWriter get/set
eld::OutputTarWriter *getOutputTarWriter() { return OutputTar; }
void createOutputTarWriter();
DiagnosticPrinter *getPrinter() { return Printer; }
/// ------------------ Linker Caching Feature --------------------
void addIntoRuleContainerMap(uint64_t RuleHash, RuleContainer *R) {
RuleContainerMap[RuleHash] = R;
}
RuleContainer *getRuleContainer(uint64_t RuleHash) const {
auto It = RuleContainerMap.find(RuleHash);
if (It != RuleContainerMap.end())
return It->second;
return nullptr;
}
OutputSectionEntry *getOutputSectionEntry(uint64_t OutSectionHash) const {
auto It = OutputSectionIndexMap.find(OutSectionHash);
if (It != OutputSectionIndexMap.end())
return It->second;
return nullptr;
}
void setOutputSectionEntry(uint64_t OutSectionId, OutputSectionEntry *Out) {
OutputSectionIndexMap[OutSectionId] = Out;
}
// -----------------------------Saver support ------------------------------
llvm::StringRef saveString(std::string S);
llvm::StringRef saveString(llvm::StringRef S);
// ----------------------------LayoutPrinters ------------------------------
TextLayoutPrinter *getTextMapPrinter() const { return TextMapPrinter; }
YamlLayoutPrinter *getYAMLMapPrinter() const { return YamlMapPrinter; }
bool createLayoutPrintersForMapStyle(llvm::StringRef);
bool checkAndRaiseLayoutPrinterDiagEntry(eld::Expected<void> E) const;
// --------------------------Plugin Memory Buffer Support -----------------
char *getUninitBuffer(size_t Sz);
// ---------------------------resetSymbol support -------------------------
bool resetSymbol(ResolveInfo *, Fragment *F);
// ---------------------------ImageLayoutChecksum support------------------
uint64_t getImageLayoutChecksum() const;
void addVisitedAssignment(std::string S) { VisitedAssignments.insert(S); }
bool isVisitedAssignment(std::string S) {
return VisitedAssignments.count(S) > 0;
}
// -------------------------Writable Chunks -------------------------------
bool makeChunkWritable(eld::Fragment *F);
// ------------------- Relocation data set by plugins ---------------------
void setRelocationData(const eld::Relocation *, uint64_t);
bool getRelocationData(const eld::Relocation *, uint64_t &);
bool getRelocationDataForSync(const eld::Relocation *, uint64_t &);
void addReferencedSymbol(Section &, ResolveInfo &);
const ReferencedSymbols &getBitcodeReferencedSymbols() const {
return BitcodeReferencedSymbols;
}
// ---------------------------Central Thread Pool ------------------------
llvm::ThreadPoolInterface *getThreadPool();
// ---------------Internal Input Files ------------------------------
/// Returns the common internal input file.
InputFile *getCommonInternalInput() const {
return InternalFiles[InternalInputType::Common];
}
/// Create a common section. Common section is an internal input section. Each
/// common section contains one common symbol.
CommonELFSection *createCommonELFSection(const std::string &SectionName,
uint32_t Align,
InputFile *OriginatingInputFile);
MergeableString *getMergedNonAllocString(const MergeableString *S) const {
ASSERT(!S->isAlloc(), "string is alloc!");
auto Str = UniqueNonAllocStrings.find(S->String);
if (Str == UniqueNonAllocStrings.end())
return nullptr;
MergeableString *MergedString = Str->second;
if (MergedString == S)
return nullptr;
return MergedString;
}
llvm::SmallVectorImpl<MergeableString *> &getNonAllocStrings() {
return AllNonAllocStrings;
}
void addNonAllocString(MergeableString *S) {
ASSERT(!S->isAlloc(), "string is alloc!");
AllNonAllocStrings.push_back(S);
UniqueNonAllocStrings.insert({S->String, S});
}
void addScriptSymbolForDynamicListFile(InputFile *DynamicListFile,
ScriptSymbol *Sym) {
DynamicListFileToScriptSymbolsMap[DynamicListFile].push_back(Sym);
}
const llvm::DenseMap<InputFile *, ScriptSymbolList> &
getDynamicListFileToScriptSymbolsMap() const {
return DynamicListFileToScriptSymbolsMap;
}
void addToOutputSectionDescNameSet(llvm::StringRef Name) {
OutputSectDescNameSet.insert(Name);
}
bool findInOutputSectionDescNameSet(llvm::StringRef Name) {
return OutputSectDescNameSet.find(Name) != OutputSectDescNameSet.end();
}
void addVersionScript(const VersionScript *VerScr) {
VersionScripts.push_back(VerScr);
}
const llvm::SmallVectorImpl<const VersionScript *> &
getVersionScripts() const {
return VersionScripts;
}
bool isLinkStateBeforeLayout() const {
return getState() == LinkState::BeforeLayout;
}
bool isLinkStateCreatingSections() const {
return getState() == LinkState::CreatingSections;
}
bool isLinkStateCreatingSegments() const {
return getState() == LinkState::CreatingSegments;
}
bool isLinkStateAfterLayout() const {
return getState() == LinkState::AfterLayout;
}
void setFragmentPaddingValue(Fragment *F, uint64_t V);
std::optional<uint64_t> getFragmentPaddingValue(const Fragment *F) const;
PluginManager &getPluginManager() { return PM; }
Section *createBitcodeSection(const std::string &Section, BitcodeFile &File,
bool Internal = false);
bool isBackendInitialized() const;
void createPluginActivityLog() {
PluginActLog.emplace(ThisConfig.options(), UserLinkerScript.getPlugins());
}
std::optional<PluginActivityLog> &getPluginActivityLog() {
return PluginActLog;
}
private:
void initThreading();
/// Verifies invariants of 'CreatingSections' linker state.
/// Invariants here means the conditions and rules that 'CreatingSections'
/// state expects to be true.
/// 'CreatingSections' invariants consists of:
/// - There should be pending section overrides.
bool verifyInvariantsForCreatingSectionsState() const;
// Read one plugin config file
bool readOnePluginConfig(llvm::StringRef Cfg, bool IsDefaultConfig);
private:
LinkerScript &UserLinkerScript;
ObjectList InputObjectList;
InternalInputArray InternalFiles;
LibraryList ArchiveLibraryList;
LibraryList DynLibraryList;
SectionTable OutputSectionTable;
llvm::StringMap<ELFSection *> OutputSectionTableMap;
std::unordered_map<Fragment *, std::vector<LDSymbol *>>
PluginFragmentToSymbols;
LinkerConfig &ThisConfig;
ScriptSymbolList DynamicListSymbols;
llvm::StringSet<> DuplicateFarCalls;
llvm::StringSet<> NoReuseTrampolines;
std::vector<ResolveInfo *> Symbols;
std::vector<ResolveInfo *> CommonSymbols;
llvm::DenseMap<ELFSection *, ResolveInfo *> SectionSymbol;
llvm::StringMap<const Assignment *> AssignmentsLive;
VersionScriptNodes LinkerVersionScriptNodes;
llvm::StringMap<InputFile *> CommonMap;
GroupSignatureMap SectionGroupSignatureMap;
llvm::StringMap<uint32_t> WrapBindings;
llvm::StringSet<> WrappedReferences;
llvm::StringSet<> NeededSymbols;
NoCrossRefSet NonRefSections;
LDSymbol *DotSymbol = nullptr;
Linker *L = nullptr;
LayoutInfo *ThisLayoutInfo = nullptr;
bool Failure = false;
bool UsesLto = false;
LinkState State = LinkState::Unknown;
ReplaceFragsVectorT ReplaceFrags;
PluginDataMapT PluginDataMap;
eld::OutputTarWriter *OutputTar = nullptr;
eld::DiagnosticPrinter *Printer;
// -----------Linker Caching Feature -----------------------
std::unordered_map<uint64_t, RuleContainer *> RuleContainerMap;
std::unordered_map<uint64_t, OutputSectionEntry *> OutputSectionIndexMap;
// ------------------Plugin Fragment -----------------------------------
std::vector<Fragment *> PluginFragments;
// -------------- StringSaver Support -----------------------------
llvm::BumpPtrAllocator BAlloc;
llvm::StringSaver Saver;
// -----------------Multiple Map file generation support --------------
TextLayoutPrinter *TextMapPrinter = nullptr;
YamlLayoutPrinter *YamlMapPrinter = nullptr;
// ----------------- Use/Def support for linker script --------------
std::unordered_set<std::string> VisitedAssignments;
// ----------------- Relocation Data set by plugins ------------------
std::unordered_map<const eld::Relocation *, uint64_t> RelocationData;
// ----------------- Section references set by plugins --------------
ReferencedSymbols BitcodeReferencedSymbols;
// ----------------- Mutex guard -----------------------------------
std::mutex Mutex;
// ----------------- Central thread pool for Linker ---------------
llvm::ThreadPoolInterface *LinkerThreadPool = nullptr;
llvm::ThreadPoolStrategy ThreadingStrategy;
llvm::StringMap<MergeableString *> UniqueNonAllocStrings;
llvm::SmallVector<MergeableString *> AllNonAllocStrings;
llvm::DenseMap<InputFile *, ScriptSymbolList>
DynamicListFileToScriptSymbolsMap;
llvm::StringSet<> OutputSectDescNameSet;
llvm::SmallVector<const VersionScript *> VersionScripts;
llvm::DenseMap<Fragment *, uint64_t> FragmentPaddingValues;
PluginManager PM;
NamePool SymbolNamePool;
std::optional<PluginActivityLog> PluginActLog;
};
} // namespace eld
#endif