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"
23 using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
24 using llvm::COFF::WindowsSubsystem;
25 using llvm::StringRef;
26 class DefinedAbsolute;
27 class DefinedRelative;
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;
37 // Represents an /export option.
39 StringRef Name; // N in /export:N or /export:E=N
40 StringRef ExtName; // E in /export:E=N
41 SymbolBody *Sym = nullptr;
46 bool Constant = false;
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.
52 StringChunk *ForwardChunk = nullptr;
54 // True if this /export option was in .drectves section.
55 bool Directives = false;
57 StringRef ExportName; // Name in DLL
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);
66 enum class DebugType {
68 CV = 0x1, /// CodeView
69 PData = 0x2, /// Procedure Data
70 Fixup = 0x4, /// Relocation Table
73 // Global configuration.
74 struct Configuration {
75 enum ManifestKind { SideBySide, Embed, No };
76 bool is64() { return Machine == AMD64; }
78 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
80 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
81 SymbolBody *Entry = nullptr;
83 std::string OutputFile;
84 bool ColorDiagnostics;
87 uint64_t ErrorLimit = 20;
88 bool Relocatable = true;
91 bool WriteSymtab = true;
92 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
93 llvm::SmallString<128> PDBPath;
95 // Symbols in this set are considered as live by the garbage collector.
96 std::set<SymbolBody *> GCRoot;
98 std::set<StringRef> NoDefaultLibs;
99 bool NoDefaultLibAll = false;
101 // True if we are creating a DLL.
104 std::vector<Export> Exports;
105 std::set<std::string> DelayLoads;
106 std::map<std::string, int> DLLOrder;
107 SymbolBody *DelayLoadHelper = nullptr;
109 bool SaveTemps = false;
112 Symbol *SEHTable = nullptr;
113 Symbol *SEHCount = nullptr;
115 // Used for /opt:lldlto=N
116 unsigned LTOOptLevel = 2;
118 // Used for /opt:lldltojobs=N
119 unsigned LTOJobs = 0;
120 // Used for /opt:lldltopartitions=N
121 unsigned LTOPartitions = 1;
123 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
124 std::map<StringRef, StringRef> Merge;
126 // Used for /section=.name,{DEKPRSW} to set section attributes.
127 std::map<StringRef, uint32_t> Section;
129 // Options for manifest files.
130 ManifestKind Manifest = SideBySide;
132 StringRef ManifestDependency;
133 bool ManifestUAC = true;
134 std::vector<std::string> ManifestInput;
135 StringRef ManifestLevel = "'asInvoker'";
136 StringRef ManifestUIAccess = "'false'";
137 StringRef ManifestFile;
139 // Used for /failifmismatch.
140 std::map<StringRef, StringRef> MustMatch;
142 // Used for /alternatename.
143 std::map<StringRef, StringRef> AlternateNames;
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;
166 // This is for debugging.
167 bool DebugPdb = false;
168 bool DumpPdb = false;
171 extern Configuration *Config;