]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Config.h
Merge ^/head r313055 through r313300.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / Config.h
1 //===- Config.h -------------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_ELF_CONFIG_H
11 #define LLD_ELF_CONFIG_H
12
13 #include "llvm/ADT/MapVector.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/StringSet.h"
16 #include "llvm/Support/ELF.h"
17
18 #include <vector>
19
20 namespace lld {
21 namespace elf {
22
23 class InputFile;
24 struct Symbol;
25
26 enum ELFKind {
27   ELFNoneKind,
28   ELF32LEKind,
29   ELF32BEKind,
30   ELF64LEKind,
31   ELF64BEKind
32 };
33
34 // For --build-id.
35 enum class BuildIdKind { None, Fast, Md5, Sha1, Hexstring, Uuid };
36
37 // For --discard-{all,locals,none} and --retain-symbols-file.
38 enum class DiscardPolicy { Default, All, Locals, RetainFile, None };
39
40 // For --strip-{all,debug}.
41 enum class StripPolicy { None, All, Debug };
42
43 // For --unresolved-symbols.
44 enum class UnresolvedPolicy { NoUndef, ReportError, Warn, Ignore };
45
46 // For --sort-section and linkerscript sorting rules.
47 enum class SortSectionPolicy { Default, None, Alignment, Name, Priority };
48
49 // For --target2
50 enum class Target2Policy { Abs, Rel, GotRel };
51
52 struct SymbolVersion {
53   llvm::StringRef Name;
54   bool IsExternCpp;
55   bool HasWildcard;
56 };
57
58 // This struct contains symbols version definition that
59 // can be found in version script if it is used for link.
60 struct VersionDefinition {
61   VersionDefinition(llvm::StringRef Name, uint16_t Id) : Name(Name), Id(Id) {}
62   llvm::StringRef Name;
63   uint16_t Id;
64   std::vector<SymbolVersion> Globals;
65   size_t NameOff; // Offset in string table.
66 };
67
68 // This struct contains the global configuration for the linker.
69 // Most fields are direct mapping from the command line options
70 // and such fields have the same name as the corresponding options.
71 // Most fields are initialized by the driver.
72 struct Configuration {
73   InputFile *FirstElf = nullptr;
74   uint8_t OSABI = 0;
75   llvm::StringMap<uint64_t> SectionStartMap;
76   llvm::StringRef DynamicLinker;
77   llvm::StringRef Entry;
78   llvm::StringRef Emulation;
79   llvm::StringRef Fini;
80   llvm::StringRef Init;
81   llvm::StringRef LTOAAPipeline;
82   llvm::StringRef LTONewPmPasses;
83   llvm::StringRef OutputFile;
84   llvm::StringRef SoName;
85   llvm::StringRef Sysroot;
86   llvm::StringSet<> RetainSymbolsFile;
87   std::string RPath;
88   std::vector<VersionDefinition> VersionDefinitions;
89   std::vector<llvm::StringRef> AuxiliaryList;
90   std::vector<llvm::StringRef> SearchPaths;
91   std::vector<llvm::StringRef> SymbolOrderingFile;
92   std::vector<llvm::StringRef> Undefined;
93   std::vector<SymbolVersion> VersionScriptGlobals;
94   std::vector<SymbolVersion> VersionScriptLocals;
95   std::vector<uint8_t> BuildIdVector;
96   bool AllowMultipleDefinition;
97   bool AsNeeded = false;
98   bool Bsymbolic;
99   bool BsymbolicFunctions;
100   bool ColorDiagnostics = false;
101   bool DefineCommon;
102   bool Demangle = true;
103   bool DisableVerify;
104   bool EhFrameHdr;
105   bool EnableNewDtags;
106   bool ExportDynamic;
107   bool FatalWarnings;
108   bool GcSections;
109   bool GdbIndex;
110   bool GnuHash = false;
111   bool ICF;
112   bool Mips64EL = false;
113   bool MipsN32Abi = false;
114   bool NoGnuUnique;
115   bool NoUndefinedVersion;
116   bool Nostdlib;
117   bool OFormatBinary;
118   bool OMagic;
119   bool Pic;
120   bool Pie;
121   bool PrintGcSections;
122   bool Rela;
123   bool Relocatable;
124   bool SaveTemps;
125   bool SingleRoRx;
126   bool Shared;
127   bool Static = false;
128   bool SysvHash = true;
129   bool Target1Rel;
130   bool Threads;
131   bool Trace;
132   bool Verbose;
133   bool WarnCommon;
134   bool WarnMissingEntry;
135   bool ZCombreloc;
136   bool ZExecstack;
137   bool ZNodelete;
138   bool ZNow;
139   bool ZOrigin;
140   bool ZRelro;
141   bool ExitEarly;
142   bool ZWxneeded;
143   DiscardPolicy Discard;
144   SortSectionPolicy SortSection;
145   StripPolicy Strip = StripPolicy::None;
146   UnresolvedPolicy UnresolvedSymbols;
147   Target2Policy Target2 = Target2Policy::GotRel;
148   BuildIdKind BuildId = BuildIdKind::None;
149   ELFKind EKind = ELFNoneKind;
150   uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
151   uint16_t EMachine = llvm::ELF::EM_NONE;
152   uint64_t ErrorLimit = 20;
153   uint64_t ImageBase;
154   uint64_t MaxPageSize;
155   uint64_t ZStackSize;
156   unsigned LTOPartitions;
157   unsigned LTOO;
158   unsigned Optimize;
159   unsigned ThinLTOJobs;
160 };
161
162 // The only instance of Configuration struct.
163 extern Configuration *Config;
164
165 } // namespace elf
166 } // namespace lld
167
168 #endif