File: | tools/lld/COFF/Config.h |
Warning: | line 82, column 8 Excessive padding in 'struct lld::coff::Configuration' (41 padding bytes, where 1 is optimal). Optimal fields order: Entry, DelayLoadHelper, SEHTable, SEHCount, ImageBase, StackReserve, StackCommit, HeapReserve, HeapCommit, Implib, LTOCache, ManifestDependency, ManifestLevel, ManifestUIAccess, ManifestFile, NatvisFiles, Argv, GCRoot, Exports, ManifestInput, OutputFile, ImportName, Order, MapFile, NoDefaultLibs, DelayLoads, DLLOrder, LTOCachePolicy, Merge, Section, AlignComm, MustMatch, AlternateNames, PDBPath, Machine, Subsystem, DebugTypes, GuardCF, LTOOptLevel, LTOJobs, LTOPartitions, Manifest, ManifestID, MajorImageVersion, MinorImageVersion, MajorOSVersion, MinorOSVersion, Verbose, NoEntry, DoGC, DoICF, Relocatable, Force, Debug, DebugDwarf, DebugGHashes, ShowTiming, NoDefaultLibAll, DLL, SaveTemps, ManifestUAC, DynamicBase, AllowBind, NxCompat, AllowIsolation, TerminalServerAware, LargeAddressAware, HighEntropyVA, AppContainer, MinGW, WarnMissingOrderSymbol, WarnLocallyDefinedImported, Incremental, KillAt, consider reordering the fields or adding explicit padding members |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | //===- Config.h -------------------------------------------------*- C++ -*-===// |
2 | // |
3 | // The LLVM Linker |
4 | // |
5 | // This file is distributed under the University of Illinois Open Source |
6 | // License. See LICENSE.TXT for details. |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef LLD_COFF_CONFIG_H |
11 | #define LLD_COFF_CONFIG_H |
12 | |
13 | #include "llvm/ADT/StringMap.h" |
14 | #include "llvm/ADT/StringRef.h" |
15 | #include "llvm/Object/COFF.h" |
16 | #include "llvm/Support/CachePruning.h" |
17 | #include <cstdint> |
18 | #include <map> |
19 | #include <set> |
20 | #include <string> |
21 | |
22 | namespace lld { |
23 | namespace coff { |
24 | |
25 | using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; |
26 | using llvm::COFF::WindowsSubsystem; |
27 | using llvm::StringRef; |
28 | class DefinedAbsolute; |
29 | class DefinedRelative; |
30 | class StringChunk; |
31 | class Symbol; |
32 | |
33 | // Short aliases. |
34 | static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64; |
35 | static const auto ARM64 = llvm::COFF::IMAGE_FILE_MACHINE_ARM64; |
36 | static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT; |
37 | static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386; |
38 | |
39 | // Represents an /export option. |
40 | struct Export { |
41 | StringRef Name; // N in /export:N or /export:E=N |
42 | StringRef ExtName; // E in /export:E=N |
43 | Symbol *Sym = nullptr; |
44 | uint16_t Ordinal = 0; |
45 | bool Noname = false; |
46 | bool Data = false; |
47 | bool Private = false; |
48 | bool Constant = false; |
49 | |
50 | // If an export is a form of /export:foo=dllname.bar, that means |
51 | // that foo should be exported as an alias to bar in the DLL. |
52 | // ForwardTo is set to "dllname.bar" part. Usually empty. |
53 | StringRef ForwardTo; |
54 | StringChunk *ForwardChunk = nullptr; |
55 | |
56 | // True if this /export option was in .drectves section. |
57 | bool Directives = false; |
58 | StringRef SymbolName; |
59 | StringRef ExportName; // Name in DLL |
60 | |
61 | bool operator==(const Export &E) { |
62 | return (Name == E.Name && ExtName == E.ExtName && |
63 | Ordinal == E.Ordinal && Noname == E.Noname && |
64 | Data == E.Data && Private == E.Private); |
65 | } |
66 | }; |
67 | |
68 | enum class DebugType { |
69 | None = 0x0, |
70 | CV = 0x1, /// CodeView |
71 | PData = 0x2, /// Procedure Data |
72 | Fixup = 0x4, /// Relocation Table |
73 | }; |
74 | |
75 | enum class GuardCFLevel { |
76 | Off, |
77 | NoLongJmp, // Emit gfids but no longjmp tables |
78 | Full, // Enable all protections. |
79 | }; |
80 | |
81 | // Global configuration. |
82 | struct Configuration { |
Excessive padding in 'struct lld::coff::Configuration' (41 padding bytes, where 1 is optimal).
Optimal fields order:
Entry,
DelayLoadHelper,
SEHTable,
SEHCount,
ImageBase,
StackReserve,
StackCommit,
HeapReserve,
HeapCommit,
Implib,
LTOCache,
ManifestDependency,
ManifestLevel,
ManifestUIAccess,
ManifestFile,
NatvisFiles,
Argv,
GCRoot,
Exports,
ManifestInput,
OutputFile,
ImportName,
Order,
MapFile,
NoDefaultLibs,
DelayLoads,
DLLOrder,
LTOCachePolicy,
Merge,
Section,
AlignComm,
MustMatch,
AlternateNames,
PDBPath,
Machine,
Subsystem,
DebugTypes,
GuardCF,
LTOOptLevel,
LTOJobs,
LTOPartitions,
Manifest,
ManifestID,
MajorImageVersion,
MinorImageVersion,
MajorOSVersion,
MinorOSVersion,
Verbose,
NoEntry,
DoGC,
DoICF,
Relocatable,
Force,
Debug,
DebugDwarf,
DebugGHashes,
ShowTiming,
NoDefaultLibAll,
DLL,
SaveTemps,
ManifestUAC,
DynamicBase,
AllowBind,
NxCompat,
AllowIsolation,
TerminalServerAware,
LargeAddressAware,
HighEntropyVA,
AppContainer,
MinGW,
WarnMissingOrderSymbol,
WarnLocallyDefinedImported,
Incremental,
KillAt,
consider reordering the fields or adding explicit padding members | |
83 | enum ManifestKind { SideBySide, Embed, No }; |
84 | bool is64() { return Machine == AMD64 || Machine == ARM64; } |
85 | |
86 | llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN; |
87 | bool Verbose = false; |
88 | WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; |
89 | Symbol *Entry = nullptr; |
90 | bool NoEntry = false; |
91 | std::string OutputFile; |
92 | std::string ImportName; |
93 | bool DoGC = true; |
94 | bool DoICF = true; |
95 | bool Relocatable = true; |
96 | bool Force = false; |
97 | bool Debug = false; |
98 | bool DebugDwarf = false; |
99 | bool DebugGHashes = false; |
100 | bool ShowTiming = false; |
101 | unsigned DebugTypes = static_cast<unsigned>(DebugType::None); |
102 | std::vector<std::string> NatvisFiles; |
103 | llvm::SmallString<128> PDBPath; |
104 | std::vector<llvm::StringRef> Argv; |
105 | |
106 | // Symbols in this set are considered as live by the garbage collector. |
107 | std::vector<Symbol *> GCRoot; |
108 | |
109 | std::set<StringRef> NoDefaultLibs; |
110 | bool NoDefaultLibAll = false; |
111 | |
112 | // True if we are creating a DLL. |
113 | bool DLL = false; |
114 | StringRef Implib; |
115 | std::vector<Export> Exports; |
116 | std::set<std::string> DelayLoads; |
117 | std::map<std::string, int> DLLOrder; |
118 | Symbol *DelayLoadHelper = nullptr; |
119 | |
120 | bool SaveTemps = false; |
121 | |
122 | // /guard:cf |
123 | GuardCFLevel GuardCF = GuardCFLevel::Off; |
124 | |
125 | // Used for SafeSEH. |
126 | Symbol *SEHTable = nullptr; |
127 | Symbol *SEHCount = nullptr; |
128 | |
129 | // Used for /opt:lldlto=N |
130 | unsigned LTOOptLevel = 2; |
131 | |
132 | // Used for /opt:lldltojobs=N |
133 | unsigned LTOJobs = 0; |
134 | // Used for /opt:lldltopartitions=N |
135 | unsigned LTOPartitions = 1; |
136 | |
137 | // Used for /opt:lldltocache=path |
138 | StringRef LTOCache; |
139 | // Used for /opt:lldltocachepolicy=policy |
140 | llvm::CachePruningPolicy LTOCachePolicy; |
141 | |
142 | // Used for /merge:from=to (e.g. /merge:.rdata=.text) |
143 | std::map<StringRef, StringRef> Merge; |
144 | |
145 | // Used for /section=.name,{DEKPRSW} to set section attributes. |
146 | std::map<StringRef, uint32_t> Section; |
147 | |
148 | // Options for manifest files. |
149 | ManifestKind Manifest = No; |
150 | int ManifestID = 1; |
151 | StringRef ManifestDependency; |
152 | bool ManifestUAC = true; |
153 | std::vector<std::string> ManifestInput; |
154 | StringRef ManifestLevel = "'asInvoker'"; |
155 | StringRef ManifestUIAccess = "'false'"; |
156 | StringRef ManifestFile; |
157 | |
158 | // Used for /aligncomm. |
159 | std::map<std::string, int> AlignComm; |
160 | |
161 | // Used for /failifmismatch. |
162 | std::map<StringRef, StringRef> MustMatch; |
163 | |
164 | // Used for /alternatename. |
165 | std::map<StringRef, StringRef> AlternateNames; |
166 | |
167 | // Used for /order. |
168 | llvm::StringMap<int> Order; |
169 | |
170 | // Used for /lldmap. |
171 | std::string MapFile; |
172 | |
173 | uint64_t ImageBase = -1; |
174 | uint64_t StackReserve = 1024 * 1024; |
175 | uint64_t StackCommit = 4096; |
176 | uint64_t HeapReserve = 1024 * 1024; |
177 | uint64_t HeapCommit = 4096; |
178 | uint32_t MajorImageVersion = 0; |
179 | uint32_t MinorImageVersion = 0; |
180 | uint32_t MajorOSVersion = 6; |
181 | uint32_t MinorOSVersion = 0; |
182 | bool DynamicBase = true; |
183 | bool AllowBind = true; |
184 | bool NxCompat = true; |
185 | bool AllowIsolation = true; |
186 | bool TerminalServerAware = true; |
187 | bool LargeAddressAware = false; |
188 | bool HighEntropyVA = false; |
189 | bool AppContainer = false; |
190 | bool MinGW = false; |
191 | bool WarnMissingOrderSymbol = true; |
192 | bool WarnLocallyDefinedImported = true; |
193 | bool Incremental = true; |
194 | bool KillAt = false; |
195 | }; |
196 | |
197 | extern Configuration *Config; |
198 | |
199 | } // namespace coff |
200 | } // namespace lld |
201 | |
202 | #endif |