1 //===- Config.h -------------------------------------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_COFF_CONFIG_H
11 #define LLD_COFF_CONFIG_H
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Object/COFF.h"
15 #include "llvm/Support/CachePruning.h"
24 using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
25 using llvm::COFF::WindowsSubsystem;
26 using llvm::StringRef;
27 class DefinedAbsolute;
28 class DefinedRelative;
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;
38 // Represents an /export option.
40 StringRef Name; // N in /export:N or /export:E=N
41 StringRef ExtName; // E in /export:E=N
42 Symbol *Sym = nullptr;
47 bool Constant = false;
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.
53 StringChunk *ForwardChunk = nullptr;
55 // True if this /export option was in .drectves section.
56 bool Directives = false;
58 StringRef ExportName; // Name in DLL
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);
67 enum class DebugType {
69 CV = 0x1, /// CodeView
70 PData = 0x2, /// Procedure Data
71 Fixup = 0x4, /// Relocation Table
74 // Global configuration.
75 struct Configuration {
76 enum ManifestKind { SideBySide, Embed, No };
77 bool is64() { return Machine == AMD64 || Machine == ARM64; }
79 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
81 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
82 Symbol *Entry = nullptr;
84 std::string OutputFile;
85 std::string ImportName;
88 bool Relocatable = true;
91 bool DebugDwarf = false;
92 bool DebugGHashes = false;
93 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
94 llvm::SmallString<128> PDBPath;
95 std::vector<llvm::StringRef> Argv;
97 // Symbols in this set are considered as live by the garbage collector.
98 std::vector<Symbol *> GCRoot;
100 std::set<StringRef> NoDefaultLibs;
101 bool NoDefaultLibAll = false;
103 // True if we are creating a DLL.
106 std::vector<Export> Exports;
107 std::set<std::string> DelayLoads;
108 std::map<std::string, int> DLLOrder;
109 Symbol *DelayLoadHelper = nullptr;
111 bool SaveTemps = false;
114 Symbol *SEHTable = nullptr;
115 Symbol *SEHCount = nullptr;
117 // Used for /opt:lldlto=N
118 unsigned LTOOptLevel = 2;
120 // Used for /opt:lldltojobs=N
121 unsigned LTOJobs = 0;
122 // Used for /opt:lldltopartitions=N
123 unsigned LTOPartitions = 1;
125 // Used for /opt:lldltocache=path
127 // Used for /opt:lldltocachepolicy=policy
128 llvm::CachePruningPolicy LTOCachePolicy;
130 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
131 std::map<StringRef, StringRef> Merge;
133 // Used for /section=.name,{DEKPRSW} to set section attributes.
134 std::map<StringRef, uint32_t> Section;
136 // Options for manifest files.
137 ManifestKind Manifest = No;
139 StringRef ManifestDependency;
140 bool ManifestUAC = true;
141 std::vector<std::string> ManifestInput;
142 StringRef ManifestLevel = "'asInvoker'";
143 StringRef ManifestUIAccess = "'false'";
144 StringRef ManifestFile;
146 // Used for /aligncomm.
147 std::map<std::string, int> AlignComm;
149 // Used for /failifmismatch.
150 std::map<StringRef, StringRef> MustMatch;
152 // Used for /alternatename.
153 std::map<StringRef, StringRef> AlternateNames;
158 uint64_t ImageBase = -1;
159 uint64_t StackReserve = 1024 * 1024;
160 uint64_t StackCommit = 4096;
161 uint64_t HeapReserve = 1024 * 1024;
162 uint64_t HeapCommit = 4096;
163 uint32_t MajorImageVersion = 0;
164 uint32_t MinorImageVersion = 0;
165 uint32_t MajorOSVersion = 6;
166 uint32_t MinorOSVersion = 0;
167 bool CanExitEarly = false;
168 bool DynamicBase = true;
169 bool AllowBind = true;
170 bool NxCompat = true;
171 bool AllowIsolation = true;
172 bool TerminalServerAware = true;
173 bool LargeAddressAware = false;
174 bool HighEntropyVA = false;
175 bool AppContainer = false;
177 bool WarnLocallyDefinedImported = true;
181 extern Configuration *Config;