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;
85 bool Relocatable = true;
88 bool WriteSymtab = true;
89 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
92 // Symbols in this set are considered as live by the garbage collector.
93 std::set<SymbolBody *> GCRoot;
95 std::set<StringRef> NoDefaultLibs;
96 bool NoDefaultLibAll = false;
98 // True if we are creating a DLL.
101 std::vector<Export> Exports;
102 std::set<std::string> DelayLoads;
103 std::map<std::string, int> DLLOrder;
104 SymbolBody *DelayLoadHelper = nullptr;
107 Symbol *SEHTable = nullptr;
108 Symbol *SEHCount = nullptr;
110 // Used for /opt:lldlto=N
111 unsigned LTOOptLevel = 2;
113 // Used for /opt:lldltojobs=N
114 unsigned LTOJobs = 1;
116 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
117 std::map<StringRef, StringRef> Merge;
119 // Used for /section=.name,{DEKPRSW} to set section attributes.
120 std::map<StringRef, uint32_t> Section;
122 // Options for manifest files.
123 ManifestKind Manifest = SideBySide;
125 StringRef ManifestDependency;
126 bool ManifestUAC = true;
127 std::vector<std::string> ManifestInput;
128 StringRef ManifestLevel = "'asInvoker'";
129 StringRef ManifestUIAccess = "'false'";
130 StringRef ManifestFile;
132 // Used for /failifmismatch.
133 std::map<StringRef, StringRef> MustMatch;
135 // Used for /alternatename.
136 std::map<StringRef, StringRef> AlternateNames;
138 uint64_t ImageBase = -1;
139 uint64_t StackReserve = 1024 * 1024;
140 uint64_t StackCommit = 4096;
141 uint64_t HeapReserve = 1024 * 1024;
142 uint64_t HeapCommit = 4096;
143 uint32_t MajorImageVersion = 0;
144 uint32_t MinorImageVersion = 0;
145 uint32_t MajorOSVersion = 6;
146 uint32_t MinorOSVersion = 0;
147 bool DynamicBase = true;
148 bool AllowBind = true;
149 bool NxCompat = true;
150 bool AllowIsolation = true;
151 bool TerminalServerAware = true;
152 bool LargeAddressAware = false;
153 bool HighEntropyVA = false;
155 // This is for debugging.
156 bool DebugPdb = false;
157 bool DumpPdb = false;
160 extern Configuration *Config;