]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Config.h
Import DTS files from Linux 4.18
[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/BinaryFormat/ELF.h"
17 #include "llvm/Support/CachePruning.h"
18 #include "llvm/Support/CodeGen.h"
19 #include "llvm/Support/Endian.h"
20
21 #include <vector>
22
23 namespace lld {
24 namespace elf {
25
26 class InputFile;
27
28 enum ELFKind {
29   ELFNoneKind,
30   ELF32LEKind,
31   ELF32BEKind,
32   ELF64LEKind,
33   ELF64BEKind
34 };
35
36 // For --build-id.
37 enum class BuildIdKind { None, Fast, Md5, Sha1, Hexstring, Uuid };
38
39 // For --discard-{all,locals,none}.
40 enum class DiscardPolicy { Default, All, Locals, None };
41
42 // For --strip-{all,debug}.
43 enum class StripPolicy { None, All, Debug };
44
45 // For --unresolved-symbols.
46 enum class UnresolvedPolicy { ReportError, Warn, Ignore, IgnoreAll };
47
48 // For --orphan-handling.
49 enum class OrphanHandlingPolicy { Place, Warn, Error };
50
51 // For --sort-section and linkerscript sorting rules.
52 enum class SortSectionPolicy { Default, None, Alignment, Name, Priority };
53
54 // For --target2
55 enum class Target2Policy { Abs, Rel, GotRel };
56
57 // For tracking ARM Float Argument PCS
58 enum class ARMVFPArgKind { Default, Base, VFP, ToolChain };
59
60 struct SymbolVersion {
61   llvm::StringRef Name;
62   bool IsExternCpp;
63   bool HasWildcard;
64 };
65
66 // This struct contains symbols version definition that
67 // can be found in version script if it is used for link.
68 struct VersionDefinition {
69   llvm::StringRef Name;
70   uint16_t Id = 0;
71   std::vector<SymbolVersion> Globals;
72   size_t NameOff = 0; // Offset in the string table
73 };
74
75 // This struct contains the global configuration for the linker.
76 // Most fields are direct mapping from the command line options
77 // and such fields have the same name as the corresponding options.
78 // Most fields are initialized by the driver.
79 struct Configuration {
80   uint8_t OSABI = 0;
81   llvm::CachePruningPolicy ThinLTOCachePolicy;
82   llvm::StringMap<uint64_t> SectionStartMap;
83   llvm::StringRef Chroot;
84   llvm::StringRef DynamicLinker;
85   llvm::StringRef Entry;
86   llvm::StringRef Emulation;
87   llvm::StringRef Fini;
88   llvm::StringRef Init;
89   llvm::StringRef LTOAAPipeline;
90   llvm::StringRef LTONewPmPasses;
91   llvm::StringRef MapFile;
92   llvm::StringRef OutputFile;
93   llvm::StringRef OptRemarksFilename;
94   llvm::StringRef SoName;
95   llvm::StringRef Sysroot;
96   llvm::StringRef ThinLTOCacheDir;
97   std::string Rpath;
98   std::vector<VersionDefinition> VersionDefinitions;
99   std::vector<llvm::StringRef> Argv;
100   std::vector<llvm::StringRef> AuxiliaryList;
101   std::vector<llvm::StringRef> FilterList;
102   std::vector<llvm::StringRef> SearchPaths;
103   std::vector<llvm::StringRef> SymbolOrderingFile;
104   std::vector<llvm::StringRef> Undefined;
105   std::vector<SymbolVersion> DynamicList;
106   std::vector<SymbolVersion> VersionScriptGlobals;
107   std::vector<SymbolVersion> VersionScriptLocals;
108   std::vector<uint8_t> BuildIdVector;
109   bool AllowMultipleDefinition;
110   bool AndroidPackDynRelocs = false;
111   bool ARMHasBlx = false;
112   bool ARMHasMovtMovw = false;
113   bool ARMJ1J2BranchEncoding = false;
114   bool AsNeeded = false;
115   bool Bsymbolic;
116   bool BsymbolicFunctions;
117   bool CompressDebugSections;
118   bool DefineCommon;
119   bool Demangle = true;
120   bool DisableVerify;
121   bool EhFrameHdr;
122   bool EmitRelocs;
123   bool EnableNewDtags;
124   bool ExportDynamic;
125   bool FixCortexA53Errata843419;
126   bool GcSections;
127   bool GdbIndex;
128   bool GnuHash = false;
129   bool HasDynamicList = false;
130   bool HasDynSymTab;
131   bool ICF;
132   bool ICFData;
133   bool MergeArmExidx;
134   bool MipsN32Abi = false;
135   bool NoGnuUnique;
136   bool NoUndefinedVersion;
137   bool NoinhibitExec;
138   bool Nostdlib;
139   bool OFormatBinary;
140   bool Omagic;
141   bool OptRemarksWithHotness;
142   bool Pie;
143   bool PrintGcSections;
144   bool Relocatable;
145   bool SaveTemps;
146   bool SingleRoRx;
147   bool Shared;
148   bool Static = false;
149   bool SysvHash = false;
150   bool Target1Rel;
151   bool Trace;
152   bool Verbose;
153   bool WarnCommon;
154   bool WarnMissingEntry;
155   bool ZCombreloc;
156   bool ZExecstack;
157   bool ZHazardplt;
158   bool ZNocopyreloc;
159   bool ZNodelete;
160   bool ZNodlopen;
161   bool ZNow;
162   bool ZOrigin;
163   bool ZRelro;
164   bool ZRodynamic;
165   bool ZText;
166   bool ZRetpolineplt;
167   bool ExitEarly;
168   bool ZWxneeded;
169   DiscardPolicy Discard;
170   OrphanHandlingPolicy OrphanHandling;
171   SortSectionPolicy SortSection;
172   StripPolicy Strip;
173   UnresolvedPolicy UnresolvedSymbols;
174   Target2Policy Target2;
175   ARMVFPArgKind ARMVFPArgs = ARMVFPArgKind::Default;
176   BuildIdKind BuildId = BuildIdKind::None;
177   ELFKind EKind = ELFNoneKind;
178   uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
179   uint16_t EMachine = llvm::ELF::EM_NONE;
180   llvm::Optional<uint64_t> ImageBase;
181   uint64_t MaxPageSize;
182   uint64_t ZStackSize;
183   unsigned LTOPartitions;
184   unsigned LTOO;
185   unsigned Optimize;
186   unsigned ThinLTOJobs;
187
188   // The following config options do not directly correspond to any
189   // particualr command line options.
190
191   // True if we need to pass through relocations in input files to the
192   // output file. Usually false because we consume relocations.
193   bool CopyRelocs;
194
195   // True if the target is ELF64. False if ELF32.
196   bool Is64;
197
198   // True if the target is little-endian. False if big-endian.
199   bool IsLE;
200
201   // endianness::little if IsLE is true. endianness::big otherwise.
202   llvm::support::endianness Endianness;
203
204   // True if the target is the little-endian MIPS64.
205   //
206   // The reason why we have this variable only for the MIPS is because
207   // we use this often.  Some ELF headers for MIPS64EL are in a
208   // mixed-endian (which is horrible and I'd say that's a serious spec
209   // bug), and we need to know whether we are reading MIPS ELF files or
210   // not in various places.
211   //
212   // (Note that MIPS64EL is not a typo for MIPS64LE. This is the official
213   // name whatever that means. A fun hypothesis is that "EL" is short for
214   // little-endian written in the little-endian order, but I don't know
215   // if that's true.)
216   bool IsMips64EL;
217
218   // Holds set of ELF header flags for the target.
219   uint32_t EFlags = 0;
220
221   // The ELF spec defines two types of relocation table entries, RELA and
222   // REL. RELA is a triplet of (offset, info, addend) while REL is a
223   // tuple of (offset, info). Addends for REL are implicit and read from
224   // the location where the relocations are applied. So, REL is more
225   // compact than RELA but requires a bit of more work to process.
226   //
227   // (From the linker writer's view, this distinction is not necessary.
228   // If the ELF had chosen whichever and sticked with it, it would have
229   // been easier to write code to process relocations, but it's too late
230   // to change the spec.)
231   //
232   // Each ABI defines its relocation type. IsRela is true if target
233   // uses RELA. As far as we know, all 64-bit ABIs are using RELA. A
234   // few 32-bit ABIs are using RELA too.
235   bool IsRela;
236
237   // True if we are creating position-independent code.
238   bool Pic;
239
240   // 4 for ELF32, 8 for ELF64.
241   int Wordsize;
242 };
243
244 // The only instance of Configuration struct.
245 extern Configuration *Config;
246
247 } // namespace elf
248 } // namespace lld
249
250 #endif