Coverage Report

Created: 2019-05-22 02:55

/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 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
5
  bool operator==(const Export &E) {
62
5
    return (Name == E.Name && ExtName == E.ExtName &&
63
5
            Ordinal == E.Ordinal && 
Noname == E.Noname4
&&
64
5
            
Data == E.Data4
&&
Private == E.Private4
);
65
5
  }
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
2.49k
  bool is64() { return Machine == AMD64 || 
Machine == ARM64583
; }
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<StringRef> 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
  Symbol *SEHTable = nullptr;
136
  Symbol *SEHCount = nullptr;
137
138
  // Used for /opt:lldlto=N
139
  unsigned LTOO = 2;
140
141
  // Used for /opt:lldltojobs=N
142
  unsigned ThinLTOJobs = 0;
143
  // Used for /opt:lldltopartitions=N
144
  unsigned LTOPartitions = 1;
145
146
  // Used for /opt:lldltocache=path
147
  StringRef LTOCache;
148
  // Used for /opt:lldltocachepolicy=policy
149
  llvm::CachePruningPolicy LTOCachePolicy;
150
151
  // Used for /merge:from=to (e.g. /merge:.rdata=.text)
152
  std::map<StringRef, StringRef> Merge;
153
154
  // Used for /section=.name,{DEKPRSW} to set section attributes.
155
  std::map<StringRef, uint32_t> Section;
156
157
  // Options for manifest files.
158
  ManifestKind Manifest = No;
159
  int ManifestID = 1;
160
  StringRef ManifestDependency;
161
  bool ManifestUAC = true;
162
  std::vector<std::string> ManifestInput;
163
  StringRef ManifestLevel = "'asInvoker'";
164
  StringRef ManifestUIAccess = "'false'";
165
  StringRef ManifestFile;
166
167
  // Used for /aligncomm.
168
  std::map<std::string, int> AlignComm;
169
170
  // Used for /failifmismatch.
171
  std::map<StringRef, std::pair<StringRef, InputFile *>> MustMatch;
172
173
  // Used for /alternatename.
174
  std::map<StringRef, StringRef> AlternateNames;
175
176
  // Used for /order.
177
  llvm::StringMap<int> Order;
178
179
  // Used for /lldmap.
180
  std::string MapFile;
181
182
  uint64_t ImageBase = -1;
183
  uint64_t StackReserve = 1024 * 1024;
184
  uint64_t StackCommit = 4096;
185
  uint64_t HeapReserve = 1024 * 1024;
186
  uint64_t HeapCommit = 4096;
187
  uint32_t MajorImageVersion = 0;
188
  uint32_t MinorImageVersion = 0;
189
  uint32_t MajorOSVersion = 6;
190
  uint32_t MinorOSVersion = 0;
191
  uint32_t Timestamp = 0;
192
  uint32_t FunctionPadMin = 0;
193
  bool DynamicBase = true;
194
  bool AllowBind = true;
195
  bool NxCompat = true;
196
  bool AllowIsolation = true;
197
  bool TerminalServerAware = true;
198
  bool LargeAddressAware = false;
199
  bool HighEntropyVA = false;
200
  bool AppContainer = false;
201
  bool MinGW = false;
202
  bool WarnMissingOrderSymbol = true;
203
  bool WarnLocallyDefinedImported = true;
204
  bool WarnDebugInfoUnusable = true;
205
  bool Incremental = true;
206
  bool IntegrityCheck = false;
207
  bool KillAt = false;
208
  bool Repro = false;
209
  bool SwaprunCD = false;
210
  bool SwaprunNet = false;
211
};
212
213
extern Configuration *Config;
214
215
} // namespace coff
216
} // namespace lld
217
218
#endif