Coverage Report

Created: 2018-06-18 20:01

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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/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
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
&&
Private == E.Private6
);
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
3.25k
  bool is64() { return Machine == AMD64 || 
Machine == ARM64711
; }
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 TailMerge;
96
  bool Relocatable = true;
97
  bool Force = false;
98
  bool Debug = false;
99
  bool DebugDwarf = false;
100
  bool DebugGHashes = false;
101
  bool ShowTiming = false;
102
  unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
103
  std::vector<std::string> NatvisFiles;
104
  llvm::SmallString<128> PDBAltPath;
105
  llvm::SmallString<128> PDBPath;
106
  std::vector<llvm::StringRef> Argv;
107
108
  // Symbols in this set are considered as live by the garbage collector.
109
  std::vector<Symbol *> GCRoot;
110
111
  std::set<StringRef> NoDefaultLibs;
112
  bool NoDefaultLibAll = false;
113
114
  // True if we are creating a DLL.
115
  bool DLL = false;
116
  StringRef Implib;
117
  std::vector<Export> Exports;
118
  std::set<std::string> DelayLoads;
119
  std::map<std::string, int> DLLOrder;
120
  Symbol *DelayLoadHelper = nullptr;
121
122
  bool SaveTemps = false;
123
124
  // /guard:cf
125
  GuardCFLevel GuardCF = GuardCFLevel::Off;
126
127
  // Used for SafeSEH.
128
  Symbol *SEHTable = nullptr;
129
  Symbol *SEHCount = nullptr;
130
131
  // Used for /opt:lldlto=N
132
  unsigned LTOO = 2;
133
134
  // Used for /opt:lldltojobs=N
135
  unsigned ThinLTOJobs = 0;
136
  // Used for /opt:lldltopartitions=N
137
  unsigned LTOPartitions = 1;
138
139
  // Used for /opt:lldltocache=path
140
  StringRef LTOCache;
141
  // Used for /opt:lldltocachepolicy=policy
142
  llvm::CachePruningPolicy LTOCachePolicy;
143
144
  // Used for /merge:from=to (e.g. /merge:.rdata=.text)
145
  std::map<StringRef, StringRef> Merge;
146
147
  // Used for /section=.name,{DEKPRSW} to set section attributes.
148
  std::map<StringRef, uint32_t> Section;
149
150
  // Options for manifest files.
151
  ManifestKind Manifest = No;
152
  int ManifestID = 1;
153
  StringRef ManifestDependency;
154
  bool ManifestUAC = true;
155
  std::vector<std::string> ManifestInput;
156
  StringRef ManifestLevel = "'asInvoker'";
157
  StringRef ManifestUIAccess = "'false'";
158
  StringRef ManifestFile;
159
160
  // Used for /aligncomm.
161
  std::map<std::string, int> AlignComm;
162
163
  // Used for /failifmismatch.
164
  std::map<StringRef, StringRef> MustMatch;
165
166
  // Used for /alternatename.
167
  std::map<StringRef, StringRef> AlternateNames;
168
169
  // Used for /order.
170
  llvm::StringMap<int> Order;
171
172
  // Used for /lldmap.
173
  std::string MapFile;
174
175
  uint64_t ImageBase = -1;
176
  uint64_t StackReserve = 1024 * 1024;
177
  uint64_t StackCommit = 4096;
178
  uint64_t HeapReserve = 1024 * 1024;
179
  uint64_t HeapCommit = 4096;
180
  uint32_t MajorImageVersion = 0;
181
  uint32_t MinorImageVersion = 0;
182
  uint32_t MajorOSVersion = 6;
183
  uint32_t MinorOSVersion = 0;
184
  uint32_t Timestamp = 0;
185
  bool DynamicBase = true;
186
  bool AllowBind = true;
187
  bool NxCompat = true;
188
  bool AllowIsolation = true;
189
  bool TerminalServerAware = true;
190
  bool LargeAddressAware = false;
191
  bool HighEntropyVA = false;
192
  bool AppContainer = false;
193
  bool MinGW = false;
194
  bool WarnMissingOrderSymbol = true;
195
  bool WarnLocallyDefinedImported = true;
196
  bool Incremental = true;
197
  bool IntegrityCheck = false;
198
  bool KillAt = false;
199
  bool Repro = false;
200
};
201
202
extern Configuration *Config;
203
204
} // namespace coff
205
} // namespace lld
206
207
#endif