Coverage Report

Created: 2019-01-21 03:01

/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
32
// Short aliases.
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;
37
38
// Represents an /export option.
39
struct Export {
40
  StringRef Name;       // N in /export:N or /export:E=N
41
  StringRef ExtName;    // E in /export:E=N
42
  Symbol *Sym = nullptr;
43
  uint16_t Ordinal = 0;
44
  bool Noname = false;
45
  bool Data = false;
46
  bool Private = false;
47
  bool Constant = false;
48
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.
52
  StringRef ForwardTo;
53
  StringChunk *ForwardChunk = nullptr;
54
55
  // True if this /export option was in .drectves section.
56
  bool Directives = false;
57
  StringRef SymbolName;
58
  StringRef ExportName; // Name in DLL
59
60
8
  bool operator==(const Export &E) {
61
8
    return (Name == E.Name && ExtName == E.ExtName &&
62
8
            Ordinal == E.Ordinal && 
Noname == E.Noname6
&&
63
8
            
Data == E.Data6
&&
Private == E.Private6
);
64
8
  }
65
};
66
67
enum class DebugType {
68
  None  = 0x0,
69
  CV    = 0x1,  /// CodeView
70
  PData = 0x2,  /// Procedure Data
71
  Fixup = 0x4,  /// Relocation Table
72
};
73
74
enum class GuardCFLevel {
75
  Off,
76
  NoLongJmp, // Emit gfids but no longjmp tables
77
  Full,      // Enable all protections.
78
};
79
80
// Global configuration.
81
struct Configuration {
82
  enum ManifestKind { SideBySide, Embed, No };
83
4.28k
  bool is64() { return Machine == AMD64 || 
Machine == ARM641.01k
; }
84
85
  llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
86
  size_t Wordsize;
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 TailMerge;
96
  bool Relocatable = true;
97
  bool ForceMultiple = false;
98
  bool ForceUnresolved = false;
99
  bool Debug = false;
100
  bool DebugDwarf = false;
101
  bool DebugGHashes = false;
102
  bool DebugSymtab = false;
103
  bool ShowTiming = false;
104
  unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
105
  std::vector<std::string> NatvisFiles;
106
  llvm::SmallString<128> PDBAltPath;
107
  llvm::SmallString<128> PDBPath;
108
  llvm::SmallString<128> PDBSourcePath;
109
  std::vector<llvm::StringRef> Argv;
110
111
  // Symbols in this set are considered as live by the garbage collector.
112
  std::vector<Symbol *> GCRoot;
113
114
  std::set<StringRef> NoDefaultLibs;
115
  bool NoDefaultLibAll = false;
116
117
  // True if we are creating a DLL.
118
  bool DLL = false;
119
  StringRef Implib;
120
  std::vector<Export> Exports;
121
  std::set<std::string> DelayLoads;
122
  std::map<std::string, int> DLLOrder;
123
  Symbol *DelayLoadHelper = nullptr;
124
125
  bool SaveTemps = false;
126
127
  // /guard:cf
128
  GuardCFLevel GuardCF = GuardCFLevel::Off;
129
130
  // Used for SafeSEH.
131
  Symbol *SEHTable = nullptr;
132
  Symbol *SEHCount = nullptr;
133
134
  // Used for /opt:lldlto=N
135
  unsigned LTOO = 2;
136
137
  // Used for /opt:lldltojobs=N
138
  unsigned ThinLTOJobs = 0;
139
  // Used for /opt:lldltopartitions=N
140
  unsigned LTOPartitions = 1;
141
142
  // Used for /opt:lldltocache=path
143
  StringRef LTOCache;
144
  // Used for /opt:lldltocachepolicy=policy
145
  llvm::CachePruningPolicy LTOCachePolicy;
146
147
  // Used for /merge:from=to (e.g. /merge:.rdata=.text)
148
  std::map<StringRef, StringRef> Merge;
149
150
  // Used for /section=.name,{DEKPRSW} to set section attributes.
151
  std::map<StringRef, uint32_t> Section;
152
153
  // Options for manifest files.
154
  ManifestKind Manifest = No;
155
  int ManifestID = 1;
156
  StringRef ManifestDependency;
157
  bool ManifestUAC = true;
158
  std::vector<std::string> ManifestInput;
159
  StringRef ManifestLevel = "'asInvoker'";
160
  StringRef ManifestUIAccess = "'false'";
161
  StringRef ManifestFile;
162
163
  // Used for /aligncomm.
164
  std::map<std::string, int> AlignComm;
165
166
  // Used for /failifmismatch.
167
  std::map<StringRef, StringRef> MustMatch;
168
169
  // Used for /alternatename.
170
  std::map<StringRef, StringRef> AlternateNames;
171
172
  // Used for /order.
173
  llvm::StringMap<int> Order;
174
175
  // Used for /lldmap.
176
  std::string MapFile;
177
178
  uint64_t ImageBase = -1;
179
  uint64_t StackReserve = 1024 * 1024;
180
  uint64_t StackCommit = 4096;
181
  uint64_t HeapReserve = 1024 * 1024;
182
  uint64_t HeapCommit = 4096;
183
  uint32_t MajorImageVersion = 0;
184
  uint32_t MinorImageVersion = 0;
185
  uint32_t MajorOSVersion = 6;
186
  uint32_t MinorOSVersion = 0;
187
  uint32_t Timestamp = 0;
188
  bool DynamicBase = true;
189
  bool AllowBind = true;
190
  bool NxCompat = true;
191
  bool AllowIsolation = true;
192
  bool TerminalServerAware = true;
193
  bool LargeAddressAware = false;
194
  bool HighEntropyVA = false;
195
  bool AppContainer = false;
196
  bool MinGW = false;
197
  bool WarnMissingOrderSymbol = true;
198
  bool WarnLocallyDefinedImported = true;
199
  bool WarnDebugInfoUnusable = true;
200
  bool Incremental = true;
201
  bool IntegrityCheck = false;
202
  bool KillAt = false;
203
  bool Repro = false;
204
};
205
206
extern Configuration *Config;
207
208
} // namespace coff
209
} // namespace lld
210
211
#endif