/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/COFF/Config.h
Line | Count | Source |
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/StringRef.h" |
14 | | #include "llvm/Object/COFF.h" |
15 | | #include "llvm/Support/CachePruning.h" |
16 | | #include <cstdint> |
17 | | #include <map> |
18 | | #include <set> |
19 | | #include <string> |
20 | | |
21 | | namespace lld { |
22 | | namespace coff { |
23 | | |
24 | | using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; |
25 | | using llvm::COFF::WindowsSubsystem; |
26 | | using llvm::StringRef; |
27 | | class DefinedAbsolute; |
28 | | class DefinedRelative; |
29 | | class StringChunk; |
30 | | struct Symbol; |
31 | | class SymbolBody; |
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 | | SymbolBody *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 | 7 | bool operator==(const Export &E) { |
62 | 7 | return (Name == E.Name && ExtName == E.ExtName && |
63 | 7 | Ordinal == E.Ordinal7 && Noname == E.Noname5 && |
64 | 7 | Data == E.Data5 && Private == E.Private5 ); |
65 | 7 | } |
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 | | // Global configuration. |
76 | | struct Configuration { |
77 | | enum ManifestKind { SideBySide, Embed, No }; |
78 | 2.25k | bool is64() { return Machine == AMD64 || 2.25k Machine == ARM64490 ; } |
79 | | |
80 | | llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN; |
81 | | bool Verbose = false; |
82 | | WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; |
83 | | SymbolBody *Entry = nullptr; |
84 | | bool NoEntry = false; |
85 | | std::string OutputFile; |
86 | | std::string ImportName; |
87 | | bool ColorDiagnostics; |
88 | | bool DoGC = true; |
89 | | bool DoICF = true; |
90 | | uint64_t ErrorLimit = 20; |
91 | | bool Relocatable = true; |
92 | | bool Force = false; |
93 | | bool Debug = false; |
94 | | bool WriteSymtab = true; |
95 | | unsigned DebugTypes = static_cast<unsigned>(DebugType::None); |
96 | | llvm::SmallString<128> PDBPath; |
97 | | std::vector<llvm::StringRef> Argv; |
98 | | |
99 | | // Symbols in this set are considered as live by the garbage collector. |
100 | | std::set<SymbolBody *> GCRoot; |
101 | | |
102 | | std::set<StringRef> NoDefaultLibs; |
103 | | bool NoDefaultLibAll = false; |
104 | | |
105 | | // True if we are creating a DLL. |
106 | | bool DLL = false; |
107 | | StringRef Implib; |
108 | | std::vector<Export> Exports; |
109 | | std::set<std::string> DelayLoads; |
110 | | std::map<std::string, int> DLLOrder; |
111 | | SymbolBody *DelayLoadHelper = nullptr; |
112 | | |
113 | | bool SaveTemps = false; |
114 | | |
115 | | // Used for SafeSEH. |
116 | | Symbol *SEHTable = nullptr; |
117 | | Symbol *SEHCount = nullptr; |
118 | | |
119 | | // Used for /opt:lldlto=N |
120 | | unsigned LTOOptLevel = 2; |
121 | | |
122 | | // Used for /opt:lldltojobs=N |
123 | | unsigned LTOJobs = 0; |
124 | | // Used for /opt:lldltopartitions=N |
125 | | unsigned LTOPartitions = 1; |
126 | | |
127 | | // Used for /opt:lldltocache=path |
128 | | StringRef LTOCache; |
129 | | // Used for /opt:lldltocachepolicy=policy |
130 | | llvm::CachePruningPolicy LTOCachePolicy; |
131 | | |
132 | | // Used for /merge:from=to (e.g. /merge:.rdata=.text) |
133 | | std::map<StringRef, StringRef> Merge; |
134 | | |
135 | | // Used for /section=.name,{DEKPRSW} to set section attributes. |
136 | | std::map<StringRef, uint32_t> Section; |
137 | | |
138 | | // Options for manifest files. |
139 | | ManifestKind Manifest = No; |
140 | | int ManifestID = 1; |
141 | | StringRef ManifestDependency; |
142 | | bool ManifestUAC = true; |
143 | | std::vector<std::string> ManifestInput; |
144 | | StringRef ManifestLevel = "'asInvoker'"; |
145 | | StringRef ManifestUIAccess = "'false'"; |
146 | | StringRef ManifestFile; |
147 | | |
148 | | // Used for /aligncomm. |
149 | | std::map<std::string, int> AlignComm; |
150 | | |
151 | | // Used for /failifmismatch. |
152 | | std::map<StringRef, StringRef> MustMatch; |
153 | | |
154 | | // Used for /alternatename. |
155 | | std::map<StringRef, StringRef> AlternateNames; |
156 | | |
157 | | // Used for /lldmap. |
158 | | std::string MapFile; |
159 | | |
160 | | uint64_t ImageBase = -1; |
161 | | uint64_t StackReserve = 1024 * 1024; |
162 | | uint64_t StackCommit = 4096; |
163 | | uint64_t HeapReserve = 1024 * 1024; |
164 | | uint64_t HeapCommit = 4096; |
165 | | uint32_t MajorImageVersion = 0; |
166 | | uint32_t MinorImageVersion = 0; |
167 | | uint32_t MajorOSVersion = 6; |
168 | | uint32_t MinorOSVersion = 0; |
169 | | bool DynamicBase = true; |
170 | | bool AllowBind = true; |
171 | | bool NxCompat = true; |
172 | | bool AllowIsolation = true; |
173 | | bool TerminalServerAware = true; |
174 | | bool LargeAddressAware = false; |
175 | | bool HighEntropyVA = false; |
176 | | bool AppContainer = false; |
177 | | bool MinGW = false; |
178 | | }; |
179 | | |
180 | | extern Configuration *Config; |
181 | | |
182 | | } // namespace coff |
183 | | } // namespace lld |
184 | | |
185 | | #endif |