blob: ae718d3f70323e9cffae22c5e45227780dedbed6 [file] [log] [blame]
Rui Ueyama411c63602015-05-28 19:09:30 +00001//===- Config.h -----------------------------------------------------------===//
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"
Rui Ueyama3d3e6fb2015-05-29 16:06:00 +000014#include "llvm/Object/COFF.h"
Rui Ueyama411c63602015-05-28 19:09:30 +000015#include <cstdint>
Rui Ueyama8854d8a2015-06-04 19:21:24 +000016#include <map>
Rui Ueyama411c63602015-05-28 19:09:30 +000017#include <set>
18#include <string>
19
20namespace lld {
21namespace coff {
22
Rui Ueyama25522f52015-07-09 00:45:50 +000023using llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
Rui Ueyama35ccb0f2015-07-25 00:20:06 +000024using llvm::COFF::IMAGE_FILE_MACHINE_I386;
Rui Ueyamae16a75d52015-07-08 18:14:51 +000025using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
Rui Ueyama15cc47e2015-05-29 16:34:31 +000026using llvm::COFF::WindowsSubsystem;
Rui Ueyamad21b00b2015-05-31 19:17:14 +000027using llvm::StringRef;
Rui Ueyamacd3f99b2015-07-24 23:51:14 +000028class DefinedAbsolute;
29class DefinedRelative;
Rui Ueyama6bf638e2015-07-02 00:04:14 +000030class Undefined;
Rui Ueyama15cc47e2015-05-29 16:34:31 +000031
Rui Ueyama35ccb0f2015-07-25 00:20:06 +000032// Short aliases.
33static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
Rui Ueyamaa265b012015-07-25 02:25:14 +000034static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
Rui Ueyama35ccb0f2015-07-25 00:20:06 +000035static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
36
Rui Ueyama97dff9e2015-06-17 00:16:33 +000037// Represents an /export option.
38struct Export {
39 StringRef Name;
40 StringRef ExtName;
Rui Ueyama6bf638e2015-07-02 00:04:14 +000041 Undefined *Sym = nullptr;
Rui Ueyama97dff9e2015-06-17 00:16:33 +000042 uint16_t Ordinal = 0;
43 bool Noname = false;
44 bool Data = false;
45 bool Private = false;
Rui Ueyama4b8cdd22015-07-03 23:23:29 +000046
47 bool operator==(const Export &E) {
48 return (Name == E.Name && ExtName == E.ExtName &&
49 Ordinal == E.Ordinal && Noname == E.Noname &&
50 Data == E.Data && Private == E.Private);
51 }
Rui Ueyama97dff9e2015-06-17 00:16:33 +000052};
53
54// Global configuration.
55struct Configuration {
Rui Ueyama24c5fd02015-06-18 00:12:42 +000056 enum ManifestKind { SideBySide, Embed, No };
Rui Ueyama25522f52015-07-09 00:45:50 +000057 bool is64() { return MachineType == IMAGE_FILE_MACHINE_AMD64; }
Rui Ueyama24c5fd02015-06-18 00:12:42 +000058
Rui Ueyamae16a75d52015-07-08 18:14:51 +000059 llvm::COFF::MachineTypes MachineType = IMAGE_FILE_MACHINE_UNKNOWN;
Rui Ueyama411c63602015-05-28 19:09:30 +000060 bool Verbose = false;
Rui Ueyama3ee0fe42015-05-31 03:55:46 +000061 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
Rui Ueyama6bf638e2015-07-02 00:04:14 +000062 Undefined *Entry = nullptr;
Rui Ueyamaa8b60452015-06-28 19:56:30 +000063 bool NoEntry = false;
Rui Ueyamaad660982015-06-07 00:20:32 +000064 std::string OutputFile;
Rui Ueyamae2cbfea2015-06-07 03:17:42 +000065 bool DoGC = true;
Rui Ueyama588e8322015-06-15 01:23:58 +000066 bool Relocatable = true;
Rui Ueyama95925fd2015-06-28 19:35:15 +000067 bool Force = false;
Rui Ueyama6600eb12015-07-04 23:37:32 +000068 bool Debug = false;
Rui Ueyamaeb262ce2015-06-04 02:12:16 +000069
70 // Symbols in this set are considered as live by the garbage collector.
Rui Ueyama18f8d2c2015-07-02 00:21:08 +000071 std::set<Undefined *> GCRoot;
Rui Ueyamab41b7e52015-05-29 16:21:11 +000072
Rui Ueyamad21b00b2015-05-31 19:17:14 +000073 std::set<StringRef> NoDefaultLibs;
74 bool NoDefaultLibAll = false;
75
Rui Ueyama97dff9e2015-06-17 00:16:33 +000076 // True if we are creating a DLL.
77 bool DLL = false;
Rui Ueyamab95188c2015-06-18 20:27:09 +000078 StringRef Implib;
Rui Ueyama97dff9e2015-06-17 00:16:33 +000079 std::vector<Export> Exports;
Rui Ueyama7a247ee2015-07-03 01:40:14 +000080 std::set<std::string> DelayLoads;
Rui Ueyama6d249082015-07-13 22:31:45 +000081 Undefined *DelayLoadHelper = nullptr;
Rui Ueyama97dff9e2015-06-17 00:16:33 +000082
Rui Ueyamacd3f99b2015-07-24 23:51:14 +000083 // Used for SafeSEH.
84 DefinedRelative *SEHTable = nullptr;
85 DefinedAbsolute *SEHCount = nullptr;
86
Rui Ueyamaddf71fc2015-06-24 04:36:52 +000087 // Used for /opt:icf
88 bool ICF = false;
89
Rui Ueyama6600eb12015-07-04 23:37:32 +000090 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
91 std::map<StringRef, StringRef> Merge;
92
Rui Ueyama24c5fd02015-06-18 00:12:42 +000093 // Options for manifest files.
94 ManifestKind Manifest = SideBySide;
95 int ManifestID = 1;
96 StringRef ManifestDependency;
97 bool ManifestUAC = true;
98 StringRef ManifestLevel = "'asInvoker'";
99 StringRef ManifestUIAccess = "'false'";
100 StringRef ManifestFile;
101
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000102 // Used for /failifmismatch.
Rui Ueyama8854d8a2015-06-04 19:21:24 +0000103 std::map<StringRef, StringRef> MustMatch;
104
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000105 // Used for /alternatename.
Rui Ueyamae8d56b52015-06-18 23:04:26 +0000106 std::map<StringRef, StringRef> AlternateNames;
Rui Ueyama2edb35a2015-06-18 19:09:30 +0000107
Rui Ueyama49d6cd32015-07-03 00:02:19 +0000108 uint64_t ImageBase = 0x140000000U;
Rui Ueyamab41b7e52015-05-29 16:21:11 +0000109 uint64_t StackReserve = 1024 * 1024;
110 uint64_t StackCommit = 4096;
Rui Ueyamac377e9a2015-05-29 16:23:40 +0000111 uint64_t HeapReserve = 1024 * 1024;
112 uint64_t HeapCommit = 4096;
Rui Ueyamab9dcdb52015-05-29 16:28:29 +0000113 uint32_t MajorImageVersion = 0;
114 uint32_t MinorImageVersion = 0;
Rui Ueyama15cc47e2015-05-29 16:34:31 +0000115 uint32_t MajorOSVersion = 6;
116 uint32_t MinorOSVersion = 0;
Rui Ueyama6592ff82015-06-16 23:13:00 +0000117 bool DynamicBase = true;
118 bool HighEntropyVA = true;
119 bool AllowBind = true;
120 bool NxCompat = true;
121 bool AllowIsolation = true;
122 bool TerminalServerAware = true;
Rui Ueyama411c63602015-05-28 19:09:30 +0000123};
124
125extern Configuration *Config;
126
127} // namespace coff
128} // namespace lld
129
130#endif