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