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;
47 // If an export is a form of /export:foo=dllname.bar, that means
48 // that foo should be exported as an alias to bar in the DLL.
49 // ForwardTo is set to "dllname.bar" part. Usually empty.
51 StringChunk *ForwardChunk = nullptr;
53 // True if this /export option was in .drectves section.
54 bool Directives = false;
56 StringRef ExportName; // Name in DLL
58 bool operator==(const Export &E) {
59 return (Name == E.Name && ExtName == E.ExtName &&
60 Ordinal == E.Ordinal && Noname == E.Noname &&
61 Data == E.Data && Private == E.Private);
65 enum class DebugType {
67 CV = 0x1, /// CodeView
68 PData = 0x2, /// Procedure Data
69 Fixup = 0x4, /// Relocation Table
72 // Global configuration.
73 struct Configuration {
74 enum ManifestKind { SideBySide, Embed, No };
75 bool is64() { return Machine == AMD64; }
77 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
79 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
80 SymbolBody *Entry = nullptr;
82 std::string OutputFile;
83 bool ColorDiagnostics;
86 uint64_t ErrorLimit = 20;
87 bool Relocatable = true;
90 bool WriteSymtab = true;
91 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
92 llvm::SmallString<128> PDBPath;
94 // Symbols in this set are considered as live by the garbage collector.
95 std::set<SymbolBody *> GCRoot;
97 std::set<StringRef> NoDefaultLibs;
98 bool NoDefaultLibAll = false;
100 // True if we are creating a DLL.
103 std::vector<Export> Exports;
104 std::set<std::string> DelayLoads;
105 std::map<std::string, int> DLLOrder;
106 SymbolBody *DelayLoadHelper = nullptr;
108 bool SaveTemps = false;
111 Symbol *SEHTable = nullptr;
112 Symbol *SEHCount = nullptr;
114 // Used for /opt:lldlto=N
115 unsigned LTOOptLevel = 2;
117 // Used for /opt:lldltojobs=N
118 unsigned LTOJobs = 0;
119 // Used for /opt:lldltopartitions=N
120 unsigned LTOPartitions = 1;
122 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
123 std::map<StringRef, StringRef> Merge;
125 // Used for /section=.name,{DEKPRSW} to set section attributes.
126 std::map<StringRef, uint32_t> Section;
128 // Options for manifest files.
129 ManifestKind Manifest = SideBySide;
131 StringRef ManifestDependency;
132 bool ManifestUAC = true;
133 std::vector<std::string> ManifestInput;
134 StringRef ManifestLevel = "'asInvoker'";
135 StringRef ManifestUIAccess = "'false'";
136 StringRef ManifestFile;
138 // Used for /failifmismatch.
139 std::map<StringRef, StringRef> MustMatch;
141 // Used for /alternatename.
142 std::map<StringRef, StringRef> AlternateNames;
147 uint64_t ImageBase = -1;
148 uint64_t StackReserve = 1024 * 1024;
149 uint64_t StackCommit = 4096;
150 uint64_t HeapReserve = 1024 * 1024;
151 uint64_t HeapCommit = 4096;
152 uint32_t MajorImageVersion = 0;
153 uint32_t MinorImageVersion = 0;
154 uint32_t MajorOSVersion = 6;
155 uint32_t MinorOSVersion = 0;
156 bool DynamicBase = true;
157 bool AllowBind = true;
158 bool NxCompat = true;
159 bool AllowIsolation = true;
160 bool TerminalServerAware = true;
161 bool LargeAddressAware = false;
162 bool HighEntropyVA = false;
163 bool AppContainer = false;
165 // This is for debugging.
166 bool DebugPdb = false;
167 bool DumpPdb = false;
170 extern Configuration *Config;