]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/Config.h
Upgrade to OpenPAM Radula.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / COFF / Config.h
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 <cstdint>
16 #include <map>
17 #include <set>
18 #include <string>
19
20 namespace lld {
21 namespace coff {
22
23 using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
24 using llvm::COFF::WindowsSubsystem;
25 using llvm::StringRef;
26 class DefinedAbsolute;
27 class DefinedRelative;
28 class StringChunk;
29 class Undefined;
30
31 // Short aliases.
32 static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
33 static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
34 static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
35
36 // Represents an /export option.
37 struct Export {
38   StringRef Name;       // N in /export:N or /export:E=N
39   StringRef ExtName;    // E in /export:E=N
40   Undefined *Sym = nullptr;
41   uint16_t Ordinal = 0;
42   bool Noname = false;
43   bool Data = false;
44   bool Private = false;
45
46   // If an export is a form of /export:foo=dllname.bar, that means
47   // that foo should be exported as an alias to bar in the DLL.
48   // ForwardTo is set to "dllname.bar" part. Usually empty.
49   StringRef ForwardTo;
50   StringChunk *ForwardChunk = nullptr;
51
52   // True if this /export option was in .drectves section.
53   bool Directives = false;
54   StringRef SymbolName;
55   StringRef ExportName; // Name in DLL
56
57   bool operator==(const Export &E) {
58     return (Name == E.Name && ExtName == E.ExtName &&
59             Ordinal == E.Ordinal && Noname == E.Noname &&
60             Data == E.Data && Private == E.Private);
61   }
62 };
63
64 // Global configuration.
65 struct Configuration {
66   enum ManifestKind { SideBySide, Embed, No };
67   bool is64() { return Machine == AMD64; }
68
69   llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
70   bool Verbose = false;
71   WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
72   Undefined *Entry = nullptr;
73   bool NoEntry = false;
74   std::string OutputFile;
75   bool DoGC = true;
76   bool DoICF = true;
77   bool Relocatable = true;
78   bool Force = false;
79   bool Debug = false;
80   bool WriteSymtab = true;
81
82   // Symbols in this set are considered as live by the garbage collector.
83   std::set<Undefined *> GCRoot;
84
85   std::set<StringRef> NoDefaultLibs;
86   bool NoDefaultLibAll = false;
87
88   // True if we are creating a DLL.
89   bool DLL = false;
90   StringRef Implib;
91   std::vector<Export> Exports;
92   std::set<std::string> DelayLoads;
93   std::map<std::string, int> DLLOrder;
94   Undefined *DelayLoadHelper = nullptr;
95
96   // Used for SafeSEH.
97   DefinedRelative *SEHTable = nullptr;
98   DefinedAbsolute *SEHCount = nullptr;
99
100   // Used for /opt:lldlto=N
101   unsigned LTOOptLevel = 2;
102
103   // Used for /opt:lldltojobs=N
104   unsigned LTOJobs = 1;
105
106   // Used for /merge:from=to (e.g. /merge:.rdata=.text)
107   std::map<StringRef, StringRef> Merge;
108
109   // Used for /section=.name,{DEKPRSW} to set section attributes.
110   std::map<StringRef, uint32_t> Section;
111
112   // Options for manifest files.
113   ManifestKind Manifest = SideBySide;
114   int ManifestID = 1;
115   StringRef ManifestDependency;
116   bool ManifestUAC = true;
117   std::vector<std::string> ManifestInput;
118   StringRef ManifestLevel = "'asInvoker'";
119   StringRef ManifestUIAccess = "'false'";
120   StringRef ManifestFile;
121
122   // Used for /failifmismatch.
123   std::map<StringRef, StringRef> MustMatch;
124
125   // Used for /alternatename.
126   std::map<StringRef, StringRef> AlternateNames;
127
128   uint64_t ImageBase = -1;
129   uint64_t StackReserve = 1024 * 1024;
130   uint64_t StackCommit = 4096;
131   uint64_t HeapReserve = 1024 * 1024;
132   uint64_t HeapCommit = 4096;
133   uint32_t MajorImageVersion = 0;
134   uint32_t MinorImageVersion = 0;
135   uint32_t MajorOSVersion = 6;
136   uint32_t MinorOSVersion = 0;
137   bool DynamicBase = true;
138   bool AllowBind = true;
139   bool NxCompat = true;
140   bool AllowIsolation = true;
141   bool TerminalServerAware = true;
142   bool LargeAddressAware = false;
143   bool HighEntropyVA = false;
144 };
145
146 extern Configuration *Config;
147
148 } // namespace coff
149 } // namespace lld
150
151 #endif