]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Config.h
Bring lld (release_39 branch, r279477) to contrib
[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/Support/ELF.h"
16
17 #include <vector>
18
19 namespace lld {
20 namespace elf {
21
22 class InputFile;
23 struct Symbol;
24
25 enum ELFKind {
26   ELFNoneKind,
27   ELF32LEKind,
28   ELF32BEKind,
29   ELF64LEKind,
30   ELF64BEKind
31 };
32
33 enum class BuildIdKind { None, Fnv1, Md5, Sha1, Hexstring };
34
35 enum class UnresolvedPolicy { NoUndef, Error, Warn, Ignore };
36
37 struct SymbolVersion {
38   llvm::StringRef Name;
39   bool IsExternCpp;
40 };
41
42 // This struct contains symbols version definition that
43 // can be found in version script if it is used for link.
44 struct VersionDefinition {
45   VersionDefinition(llvm::StringRef Name, size_t Id) : Name(Name), Id(Id) {}
46   llvm::StringRef Name;
47   size_t Id;
48   std::vector<SymbolVersion> Globals;
49   size_t NameOff; // Offset in string table.
50 };
51
52 // This struct contains the global configuration for the linker.
53 // Most fields are direct mapping from the command line options
54 // and such fields have the same name as the corresponding options.
55 // Most fields are initialized by the driver.
56 struct Configuration {
57   Symbol *EntrySym = nullptr;
58   InputFile *FirstElf = nullptr;
59   llvm::StringRef DynamicLinker;
60   llvm::StringRef Entry;
61   llvm::StringRef Emulation;
62   llvm::StringRef Fini;
63   llvm::StringRef Init;
64   llvm::StringRef LtoAAPipeline;
65   llvm::StringRef LtoNewPmPasses;
66   llvm::StringRef OutputFile;
67   llvm::StringRef SoName;
68   llvm::StringRef Sysroot;
69   std::string RPath;
70   std::vector<VersionDefinition> VersionDefinitions;
71   std::vector<llvm::StringRef> DynamicList;
72   std::vector<llvm::StringRef> SearchPaths;
73   std::vector<llvm::StringRef> Undefined;
74   std::vector<SymbolVersion> VersionScriptGlobals;
75   std::vector<uint8_t> BuildIdVector;
76   bool AllowMultipleDefinition;
77   bool AsNeeded = false;
78   bool Bsymbolic;
79   bool BsymbolicFunctions;
80   bool Demangle = true;
81   bool DisableVerify;
82   bool DiscardAll;
83   bool DiscardLocals;
84   bool DiscardNone;
85   bool EhFrameHdr;
86   bool EnableNewDtags;
87   bool ExportDynamic;
88   bool FatalWarnings;
89   bool GcSections;
90   bool GnuHash = false;
91   bool ICF;
92   bool Mips64EL = false;
93   bool NoGnuUnique;
94   bool NoUndefinedVersion;
95   bool Pic;
96   bool Pie;
97   bool PrintGcSections;
98   bool Rela;
99   bool Relocatable;
100   bool SaveTemps;
101   bool Shared;
102   bool Static = false;
103   bool StripAll;
104   bool StripDebug;
105   bool SysvHash = true;
106   bool Threads;
107   bool Trace;
108   bool Verbose;
109   bool WarnCommon;
110   bool ZCombreloc;
111   bool ZExecStack;
112   bool ZNodelete;
113   bool ZNow;
114   bool ZOrigin;
115   bool ZRelro;
116   UnresolvedPolicy UnresolvedSymbols;
117   BuildIdKind BuildId = BuildIdKind::None;
118   ELFKind EKind = ELFNoneKind;
119   uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
120   uint16_t EMachine = llvm::ELF::EM_NONE;
121   uint64_t EntryAddr = -1;
122   uint64_t ImageBase;
123   unsigned LtoJobs;
124   unsigned LtoO;
125   unsigned Optimize;
126 };
127
128 // The only instance of Configuration struct.
129 extern Configuration *Config;
130
131 } // namespace elf
132 } // namespace lld
133
134 #endif