]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Config.h
Update ACPICA to 20181003.
[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 ZIfuncnoplt;
159   bool ZInterpose;
160   bool ZNocopyreloc;
161   bool ZNodelete;
162   bool ZNodlopen;
163   bool ZNow;
164   bool ZOrigin;
165   bool ZRelro;
166   bool ZRodynamic;
167   bool ZText;
168   bool ZRetpolineplt;
169   bool ExitEarly;
170   bool ZWxneeded;
171   DiscardPolicy Discard;
172   OrphanHandlingPolicy OrphanHandling;
173   SortSectionPolicy SortSection;
174   StripPolicy Strip;
175   UnresolvedPolicy UnresolvedSymbols;
176   Target2Policy Target2;
177   ARMVFPArgKind ARMVFPArgs = ARMVFPArgKind::Default;
178   BuildIdKind BuildId = BuildIdKind::None;
179   ELFKind EKind = ELFNoneKind;
180   uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
181   uint16_t EMachine = llvm::ELF::EM_NONE;
182   llvm::Optional<uint64_t> ImageBase;
183   uint64_t MaxPageSize;
184   uint64_t ZStackSize;
185   unsigned LTOPartitions;
186   unsigned LTOO;
187   unsigned Optimize;
188   unsigned ThinLTOJobs;
189
190   // The following config options do not directly correspond to any
191   // particualr command line options.
192
193   // True if we need to pass through relocations in input files to the
194   // output file. Usually false because we consume relocations.
195   bool CopyRelocs;
196
197   // True if the target is ELF64. False if ELF32.
198   bool Is64;
199
200   // True if the target is little-endian. False if big-endian.
201   bool IsLE;
202
203   // endianness::little if IsLE is true. endianness::big otherwise.
204   llvm::support::endianness Endianness;
205
206   // True if the target is the little-endian MIPS64.
207   //
208   // The reason why we have this variable only for the MIPS is because
209   // we use this often.  Some ELF headers for MIPS64EL are in a
210   // mixed-endian (which is horrible and I'd say that's a serious spec
211   // bug), and we need to know whether we are reading MIPS ELF files or
212   // not in various places.
213   //
214   // (Note that MIPS64EL is not a typo for MIPS64LE. This is the official
215   // name whatever that means. A fun hypothesis is that "EL" is short for
216   // little-endian written in the little-endian order, but I don't know
217   // if that's true.)
218   bool IsMips64EL;
219
220   // Holds set of ELF header flags for the target.
221   uint32_t EFlags = 0;
222
223   // The ELF spec defines two types of relocation table entries, RELA and
224   // REL. RELA is a triplet of (offset, info, addend) while REL is a
225   // tuple of (offset, info). Addends for REL are implicit and read from
226   // the location where the relocations are applied. So, REL is more
227   // compact than RELA but requires a bit of more work to process.
228   //
229   // (From the linker writer's view, this distinction is not necessary.
230   // If the ELF had chosen whichever and sticked with it, it would have
231   // been easier to write code to process relocations, but it's too late
232   // to change the spec.)
233   //
234   // Each ABI defines its relocation type. IsRela is true if target
235   // uses RELA. As far as we know, all 64-bit ABIs are using RELA. A
236   // few 32-bit ABIs are using RELA too.
237   bool IsRela;
238
239   // True if we are creating position-independent code.
240   bool Pic;
241
242   // 4 for ELF32, 8 for ELF64.
243   int Wordsize;
244 };
245
246 // The only instance of Configuration struct.
247 extern Configuration *Config;
248
249 } // namespace elf
250 } // namespace lld
251
252 #endif