Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/Config.h
Line
Count
Source
1
//===- Config.h -------------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLD_COFF_CONFIG_H
10
#define LLD_COFF_CONFIG_H
11
12
#include "llvm/ADT/StringMap.h"
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
class Symbol;
31
class InputFile;
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 isPrivate = 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
8
  bool operator==(const Export &e) {
62
8
    return (name == e.name && extName == e.extName &&
63
8
            ordinal == e.ordinal && 
noname == e.noname6
&&
64
8
            
data == e.data6
&&
isPrivate == e.isPrivate6
);
65
8
  }
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 {
83
  enum ManifestKind { SideBySide, Embed, No };
84
5.20k
  bool is64() { return machine == AMD64 || 
machine == ARM641.21k
; }
85
86
  llvm::COFF::MachineTypes machine = IMAGE_FILE_MACHINE_UNKNOWN;
87
  size_t wordsize;
88
  bool verbose = false;
89
  WindowsSubsystem subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
90
  Symbol *entry = nullptr;
91
  bool noEntry = false;
92
  std::string outputFile;
93
  std::string importName;
94
  bool demangle = true;
95
  bool doGC = true;
96
  bool doICF = true;
97
  bool tailMerge;
98
  bool relocatable = true;
99
  bool forceMultiple = false;
100
  bool forceMultipleRes = false;
101
  bool forceUnresolved = false;
102
  bool debug = false;
103
  bool debugDwarf = false;
104
  bool debugGHashes = false;
105
  bool debugSymtab = false;
106
  bool showTiming = false;
107
  bool showSummary = false;
108
  unsigned debugTypes = static_cast<unsigned>(DebugType::None);
109
  std::vector<std::string> natvisFiles;
110
  llvm::SmallString<128> pdbAltPath;
111
  llvm::SmallString<128> pdbPath;
112
  llvm::SmallString<128> pdbSourcePath;
113
  std::vector<llvm::StringRef> argv;
114
115
  // Symbols in this set are considered as live by the garbage collector.
116
  std::vector<Symbol *> gcroot;
117
118
  std::set<std::string> noDefaultLibs;
119
  bool noDefaultLibAll = false;
120
121
  // True if we are creating a DLL.
122
  bool dll = false;
123
  StringRef implib;
124
  std::vector<Export> exports;
125
  std::set<std::string> delayLoads;
126
  std::map<std::string, int> dllOrder;
127
  Symbol *delayLoadHelper = nullptr;
128
129
  bool saveTemps = false;
130
131
  // /guard:cf
132
  GuardCFLevel guardCF = GuardCFLevel::Off;
133
134
  // Used for SafeSEH.
135
  bool safeSEH = false;
136
  Symbol *sehTable = nullptr;
137
  Symbol *sehCount = nullptr;
138
139
  // Used for /opt:lldlto=N
140
  unsigned ltoo = 2;
141
142
  // Used for /opt:lldltojobs=N
143
  unsigned thinLTOJobs = 0;
144
  // Used for /opt:lldltopartitions=N
145
  unsigned ltoPartitions = 1;
146
147
  // Used for /opt:lldltocache=path
148
  StringRef ltoCache;
149
  // Used for /opt:lldltocachepolicy=policy
150
  llvm::CachePruningPolicy ltoCachePolicy;
151
152
  // Used for /merge:from=to (e.g. /merge:.rdata=.text)
153
  std::map<StringRef, StringRef> merge;
154
155
  // Used for /section=.name,{DEKPRSW} to set section attributes.
156
  std::map<StringRef, uint32_t> section;
157
158
  // Options for manifest files.
159
  ManifestKind manifest = No;
160
  int manifestID = 1;
161
  StringRef manifestDependency;
162
  bool manifestUAC = true;
163
  std::vector<std::string> manifestInput;
164
  StringRef manifestLevel = "'asInvoker'";
165
  StringRef manifestUIAccess = "'false'";
166
  StringRef manifestFile;
167
168
  // Used for /aligncomm.
169
  std::map<std::string, int> alignComm;
170
171
  // Used for /failifmismatch.
172
  std::map<StringRef, std::pair<StringRef, InputFile *>> mustMatch;
173
174
  // Used for /alternatename.
175
  std::map<StringRef, StringRef> alternateNames;
176
177
  // Used for /order.
178
  llvm::StringMap<int> order;
179
180
  // Used for /lldmap.
181
  std::string mapFile;
182
183
  // Used for /thinlto-index-only:
184
  llvm::StringRef thinLTOIndexOnlyArg;
185
186
  // Used for /thinlto-object-prefix-replace:
187
  std::pair<llvm::StringRef, llvm::StringRef> thinLTOPrefixReplace;
188
189
  // Used for /thinlto-object-suffix-replace:
190
  std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
191
192
  uint64_t imageBase = -1;
193
  uint64_t fileAlign = 512;
194
  uint64_t stackReserve = 1024 * 1024;
195
  uint64_t stackCommit = 4096;
196
  uint64_t heapReserve = 1024 * 1024;
197
  uint64_t heapCommit = 4096;
198
  uint32_t majorImageVersion = 0;
199
  uint32_t minorImageVersion = 0;
200
  uint32_t majorOSVersion = 6;
201
  uint32_t minorOSVersion = 0;
202
  uint32_t timestamp = 0;
203
  uint32_t functionPadMin = 0;
204
  bool dynamicBase = true;
205
  bool allowBind = true;
206
  bool nxCompat = true;
207
  bool allowIsolation = true;
208
  bool terminalServerAware = true;
209
  bool largeAddressAware = false;
210
  bool highEntropyVA = false;
211
  bool appContainer = false;
212
  bool mingw = false;
213
  bool warnMissingOrderSymbol = true;
214
  bool warnLocallyDefinedImported = true;
215
  bool warnDebugInfoUnusable = true;
216
  bool incremental = true;
217
  bool integrityCheck = false;
218
  bool killAt = false;
219
  bool repro = false;
220
  bool swaprunCD = false;
221
  bool swaprunNet = false;
222
  bool thinLTOEmitImportsFiles;
223
  bool thinLTOIndexOnly;
224
};
225
226
extern Configuration *config;
227
228
} // namespace coff
229
} // namespace lld
230
231
#endif