]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/Config.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r302418, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / COFF / 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_COFF_CONFIG_H
11 #define LLD_COFF_CONFIG_H
12
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Object/COFF.h"
15 #include <cstdint>
16 #include <map>
17 #include <set>
18 #include <string>
19
20 namespace lld {
21 namespace coff {
22
23 using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
24 using llvm::COFF::WindowsSubsystem;
25 using llvm::StringRef;
26 class DefinedAbsolute;
27 class DefinedRelative;
28 class StringChunk;
29 struct Symbol;
30 class SymbolBody;
31
32 // Short aliases.
33 static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
34 static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
35 static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
36
37 // Represents an /export option.
38 struct Export {
39   StringRef Name;       // N in /export:N or /export:E=N
40   StringRef ExtName;    // E in /export:E=N
41   SymbolBody *Sym = nullptr;
42   uint16_t Ordinal = 0;
43   bool Noname = false;
44   bool Data = false;
45   bool Private = false;
46   bool Constant = false;
47
48   // If an export is a form of /export:foo=dllname.bar, that means
49   // that foo should be exported as an alias to bar in the DLL.
50   // ForwardTo is set to "dllname.bar" part. Usually empty.
51   StringRef ForwardTo;
52   StringChunk *ForwardChunk = nullptr;
53
54   // True if this /export option was in .drectves section.
55   bool Directives = false;
56   StringRef SymbolName;
57   StringRef ExportName; // Name in DLL
58
59   bool operator==(const Export &E) {
60     return (Name == E.Name && ExtName == E.ExtName &&
61             Ordinal == E.Ordinal && Noname == E.Noname &&
62             Data == E.Data && Private == E.Private);
63   }
64 };
65
66 enum class DebugType {
67   None  = 0x0,
68   CV    = 0x1,  /// CodeView
69   PData = 0x2,  /// Procedure Data
70   Fixup = 0x4,  /// Relocation Table
71 };
72
73 // Global configuration.
74 struct Configuration {
75   enum ManifestKind { SideBySide, Embed, No };
76   bool is64() { return Machine == AMD64; }
77
78   llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
79   bool Verbose = false;
80   WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
81   SymbolBody *Entry = nullptr;
82   bool NoEntry = false;
83   std::string OutputFile;
84   bool ColorDiagnostics;
85   bool DoGC = true;
86   bool DoICF = true;
87   uint64_t ErrorLimit = 20;
88   bool Relocatable = true;
89   bool Force = false;
90   bool Debug = false;
91   bool WriteSymtab = true;
92   unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
93   llvm::SmallString<128> PDBPath;
94
95   // Symbols in this set are considered as live by the garbage collector.
96   std::set<SymbolBody *> GCRoot;
97
98   std::set<StringRef> NoDefaultLibs;
99   bool NoDefaultLibAll = false;
100
101   // True if we are creating a DLL.
102   bool DLL = false;
103   StringRef Implib;
104   std::vector<Export> Exports;
105   std::set<std::string> DelayLoads;
106   std::map<std::string, int> DLLOrder;
107   SymbolBody *DelayLoadHelper = nullptr;
108
109   bool SaveTemps = false;
110
111   // Used for SafeSEH.
112   Symbol *SEHTable = nullptr;
113   Symbol *SEHCount = nullptr;
114
115   // Used for /opt:lldlto=N
116   unsigned LTOOptLevel = 2;
117
118   // Used for /opt:lldltojobs=N
119   unsigned LTOJobs = 0;
120   // Used for /opt:lldltopartitions=N
121   unsigned LTOPartitions = 1;
122
123   // Used for /merge:from=to (e.g. /merge:.rdata=.text)
124   std::map<StringRef, StringRef> Merge;
125
126   // Used for /section=.name,{DEKPRSW} to set section attributes.
127   std::map<StringRef, uint32_t> Section;
128
129   // Options for manifest files.
130   ManifestKind Manifest = SideBySide;
131   int ManifestID = 1;
132   StringRef ManifestDependency;
133   bool ManifestUAC = true;
134   std::vector<std::string> ManifestInput;
135   StringRef ManifestLevel = "'asInvoker'";
136   StringRef ManifestUIAccess = "'false'";
137   StringRef ManifestFile;
138
139   // Used for /failifmismatch.
140   std::map<StringRef, StringRef> MustMatch;
141
142   // Used for /alternatename.
143   std::map<StringRef, StringRef> AlternateNames;
144
145   // Used for /lldmap.
146   std::string MapFile;
147
148   uint64_t ImageBase = -1;
149   uint64_t StackReserve = 1024 * 1024;
150   uint64_t StackCommit = 4096;
151   uint64_t HeapReserve = 1024 * 1024;
152   uint64_t HeapCommit = 4096;
153   uint32_t MajorImageVersion = 0;
154   uint32_t MinorImageVersion = 0;
155   uint32_t MajorOSVersion = 6;
156   uint32_t MinorOSVersion = 0;
157   bool DynamicBase = true;
158   bool AllowBind = true;
159   bool NxCompat = true;
160   bool AllowIsolation = true;
161   bool TerminalServerAware = true;
162   bool LargeAddressAware = false;
163   bool HighEntropyVA = false;
164   bool AppContainer = false;
165
166   // This is for debugging.
167   bool DebugPdb = false;
168   bool DumpPdb = false;
169 };
170
171 extern Configuration *Config;
172
173 } // namespace coff
174 } // namespace lld
175
176 #endif