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 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 SymbolBody
*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 SymbolBody
*Entry
= nullptr;
84 std::string OutputFile
;
85 std::string ImportName
;
86 bool ColorDiagnostics
;
89 uint64_t ErrorLimit
= 20;
90 bool Relocatable
= true;
93 bool WriteSymtab
= true;
94 unsigned DebugTypes
= static_cast<unsigned>(DebugType::None
);
95 llvm::SmallString
<128> PDBPath
;
96 std::vector
<llvm::StringRef
> Argv
;
98 // Symbols in this set are considered as live by the garbage collector.
99 std::set
<SymbolBody
*> GCRoot
;
101 std::set
<StringRef
> NoDefaultLibs
;
102 bool NoDefaultLibAll
= false;
104 // True if we are creating a DLL.
107 std::vector
<Export
> Exports
;
108 std::set
<std::string
> DelayLoads
;
109 std::map
<std::string
, int> DLLOrder
;
110 SymbolBody
*DelayLoadHelper
= nullptr;
112 bool SaveTemps
= false;
115 Symbol
*SEHTable
= nullptr;
116 Symbol
*SEHCount
= nullptr;
118 // Used for /opt:lldlto=N
119 unsigned LTOOptLevel
= 2;
121 // Used for /opt:lldltojobs=N
122 unsigned LTOJobs
= 0;
123 // Used for /opt:lldltopartitions=N
124 unsigned LTOPartitions
= 1;
126 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
127 std::map
<StringRef
, StringRef
> Merge
;
129 // Used for /section=.name,{DEKPRSW} to set section attributes.
130 std::map
<StringRef
, uint32_t> Section
;
132 // Options for manifest files.
133 ManifestKind Manifest
= No
;
135 StringRef ManifestDependency
;
136 bool ManifestUAC
= true;
137 std::vector
<std::string
> ManifestInput
;
138 StringRef ManifestLevel
= "'asInvoker'";
139 StringRef ManifestUIAccess
= "'false'";
140 StringRef ManifestFile
;
142 // Used for /failifmismatch.
143 std::map
<StringRef
, StringRef
> MustMatch
;
145 // Used for /alternatename.
146 std::map
<StringRef
, StringRef
> AlternateNames
;
151 uint64_t ImageBase
= -1;
152 uint64_t StackReserve
= 1024 * 1024;
153 uint64_t StackCommit
= 4096;
154 uint64_t HeapReserve
= 1024 * 1024;
155 uint64_t HeapCommit
= 4096;
156 uint32_t MajorImageVersion
= 0;
157 uint32_t MinorImageVersion
= 0;
158 uint32_t MajorOSVersion
= 6;
159 uint32_t MinorOSVersion
= 0;
160 bool DynamicBase
= true;
161 bool NxCompat
= true;
162 bool AllowIsolation
= true;
163 bool TerminalServerAware
= true;
164 bool LargeAddressAware
= false;
165 bool HighEntropyVA
= false;
166 bool AppContainer
= false;
169 extern Configuration
*Config
;