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;
32 static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
33 static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
34 static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
36 // Represents an /export option.
38 StringRef Name; // N in /export:N or /export:E=N
39 StringRef ExtName; // E in /export:E=N
40 Undefined *Sym = nullptr;
46 // If an export is a form of /export:foo=dllname.bar, that means
47 // that foo should be exported as an alias to bar in the DLL.
48 // ForwardTo is set to "dllname.bar" part. Usually empty.
50 StringChunk *ForwardChunk = nullptr;
52 // True if this /export option was in .drectves section.
53 bool Directives = false;
55 StringRef ExportName; // Name in DLL
57 bool operator==(const Export &E) {
58 return (Name == E.Name && ExtName == E.ExtName &&
59 Ordinal == E.Ordinal && Noname == E.Noname &&
60 Data == E.Data && Private == E.Private);
64 // Global configuration.
65 struct Configuration {
66 enum ManifestKind { SideBySide, Embed, No };
67 bool is64() { return Machine == AMD64; }
69 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
71 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
72 Undefined *Entry = nullptr;
74 std::string OutputFile;
77 bool Relocatable = true;
80 bool WriteSymtab = true;
82 // Symbols in this set are considered as live by the garbage collector.
83 std::set<Undefined *> GCRoot;
85 std::set<StringRef> NoDefaultLibs;
86 bool NoDefaultLibAll = false;
88 // True if we are creating a DLL.
91 std::vector<Export> Exports;
92 std::set<std::string> DelayLoads;
93 std::map<std::string, int> DLLOrder;
94 Undefined *DelayLoadHelper = nullptr;
97 DefinedRelative *SEHTable = nullptr;
98 DefinedAbsolute *SEHCount = nullptr;
100 // Used for /opt:lldlto=N
101 unsigned LTOOptLevel = 2;
103 // Used for /opt:lldltojobs=N
104 unsigned LTOJobs = 1;
106 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
107 std::map<StringRef, StringRef> Merge;
109 // Used for /section=.name,{DEKPRSW} to set section attributes.
110 std::map<StringRef, uint32_t> Section;
112 // Options for manifest files.
113 ManifestKind Manifest = SideBySide;
115 StringRef ManifestDependency;
116 bool ManifestUAC = true;
117 std::vector<std::string> ManifestInput;
118 StringRef ManifestLevel = "'asInvoker'";
119 StringRef ManifestUIAccess = "'false'";
120 StringRef ManifestFile;
122 // Used for /failifmismatch.
123 std::map<StringRef, StringRef> MustMatch;
125 // Used for /alternatename.
126 std::map<StringRef, StringRef> AlternateNames;
128 uint64_t ImageBase = -1;
129 uint64_t StackReserve = 1024 * 1024;
130 uint64_t StackCommit = 4096;
131 uint64_t HeapReserve = 1024 * 1024;
132 uint64_t HeapCommit = 4096;
133 uint32_t MajorImageVersion = 0;
134 uint32_t MinorImageVersion = 0;
135 uint32_t MajorOSVersion = 6;
136 uint32_t MinorOSVersion = 0;
137 bool DynamicBase = true;
138 bool AllowBind = true;
139 bool NxCompat = true;
140 bool AllowIsolation = true;
141 bool TerminalServerAware = true;
142 bool LargeAddressAware = false;
143 bool HighEntropyVA = false;
146 extern Configuration *Config;