2015-05-29 03:09:30 +08:00
|
|
|
//===- Config.h -----------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_COFF_CONFIG_H
|
|
|
|
#define LLD_COFF_CONFIG_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2015-05-30 00:06:00 +08:00
|
|
|
#include "llvm/Object/COFF.h"
|
2015-05-29 03:09:30 +08:00
|
|
|
#include <cstdint>
|
2015-06-05 03:21:24 +08:00
|
|
|
#include <map>
|
2015-05-29 03:09:30 +08:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace coff {
|
|
|
|
|
2015-07-09 02:14:51 +08:00
|
|
|
using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
|
2015-05-30 00:34:31 +08:00
|
|
|
using llvm::COFF::WindowsSubsystem;
|
2015-06-01 03:17:14 +08:00
|
|
|
using llvm::StringRef;
|
2015-07-25 07:51:14 +08:00
|
|
|
class DefinedAbsolute;
|
|
|
|
class DefinedRelative;
|
2015-07-02 08:04:14 +08:00
|
|
|
class Undefined;
|
2015-05-30 00:34:31 +08:00
|
|
|
|
2015-07-25 08:20:06 +08:00
|
|
|
// Short aliases.
|
|
|
|
static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
|
2015-07-25 10:25:14 +08:00
|
|
|
static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
|
2015-07-25 08:20:06 +08:00
|
|
|
static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
|
|
|
|
|
2015-06-17 08:16:33 +08:00
|
|
|
// Represents an /export option.
|
|
|
|
struct Export {
|
2015-07-29 06:34:24 +08:00
|
|
|
StringRef Name; // N in /export:N or /export:E=N
|
|
|
|
StringRef ExtName; // E in /export:E=N
|
|
|
|
StringRef ExtDLLName; // Symbol name written to a DLL export table
|
|
|
|
StringRef ExtLibName; // Symbol name written to a import library
|
2015-07-02 08:04:14 +08:00
|
|
|
Undefined *Sym = nullptr;
|
2015-06-17 08:16:33 +08:00
|
|
|
uint16_t Ordinal = 0;
|
|
|
|
bool Noname = false;
|
|
|
|
bool Data = false;
|
|
|
|
bool Private = false;
|
2015-07-04 07:23:29 +08:00
|
|
|
|
|
|
|
bool operator==(const Export &E) {
|
|
|
|
return (Name == E.Name && ExtName == E.ExtName &&
|
|
|
|
Ordinal == E.Ordinal && Noname == E.Noname &&
|
|
|
|
Data == E.Data && Private == E.Private);
|
|
|
|
}
|
2015-06-17 08:16:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Global configuration.
|
|
|
|
struct Configuration {
|
2015-06-18 08:12:42 +08:00
|
|
|
enum ManifestKind { SideBySide, Embed, No };
|
2015-07-26 05:54:50 +08:00
|
|
|
bool is64() { return Machine == AMD64; }
|
2015-06-18 08:12:42 +08:00
|
|
|
|
2015-07-26 05:54:50 +08:00
|
|
|
llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
|
2015-05-29 03:09:30 +08:00
|
|
|
bool Verbose = false;
|
2015-05-31 11:55:46 +08:00
|
|
|
WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
|
2015-07-02 08:04:14 +08:00
|
|
|
Undefined *Entry = nullptr;
|
2015-06-29 03:56:30 +08:00
|
|
|
bool NoEntry = false;
|
2015-06-07 08:20:32 +08:00
|
|
|
std::string OutputFile;
|
2015-06-07 11:17:42 +08:00
|
|
|
bool DoGC = true;
|
2015-06-15 09:23:58 +08:00
|
|
|
bool Relocatable = true;
|
2015-06-29 03:35:15 +08:00
|
|
|
bool Force = false;
|
2015-07-05 07:37:32 +08:00
|
|
|
bool Debug = false;
|
2015-06-04 10:12:16 +08:00
|
|
|
|
|
|
|
// Symbols in this set are considered as live by the garbage collector.
|
2015-07-02 08:21:08 +08:00
|
|
|
std::set<Undefined *> GCRoot;
|
2015-05-30 00:21:11 +08:00
|
|
|
|
2015-06-01 03:17:14 +08:00
|
|
|
std::set<StringRef> NoDefaultLibs;
|
|
|
|
bool NoDefaultLibAll = false;
|
|
|
|
|
2015-06-17 08:16:33 +08:00
|
|
|
// True if we are creating a DLL.
|
|
|
|
bool DLL = false;
|
2015-06-19 04:27:09 +08:00
|
|
|
StringRef Implib;
|
2015-06-17 08:16:33 +08:00
|
|
|
std::vector<Export> Exports;
|
2015-07-03 09:40:14 +08:00
|
|
|
std::set<std::string> DelayLoads;
|
2015-07-14 06:31:45 +08:00
|
|
|
Undefined *DelayLoadHelper = nullptr;
|
2015-06-17 08:16:33 +08:00
|
|
|
|
2015-07-25 07:51:14 +08:00
|
|
|
// Used for SafeSEH.
|
|
|
|
DefinedRelative *SEHTable = nullptr;
|
|
|
|
DefinedAbsolute *SEHCount = nullptr;
|
|
|
|
|
2015-06-24 12:36:52 +08:00
|
|
|
// Used for /opt:icf
|
|
|
|
bool ICF = false;
|
|
|
|
|
2015-08-14 12:47:07 +08:00
|
|
|
// Used for /opt:lldlto=N
|
|
|
|
unsigned LTOOptLevel = 2;
|
|
|
|
|
2015-07-05 07:37:32 +08:00
|
|
|
// Used for /merge:from=to (e.g. /merge:.rdata=.text)
|
|
|
|
std::map<StringRef, StringRef> Merge;
|
|
|
|
|
2015-06-18 08:12:42 +08:00
|
|
|
// Options for manifest files.
|
|
|
|
ManifestKind Manifest = SideBySide;
|
|
|
|
int ManifestID = 1;
|
|
|
|
StringRef ManifestDependency;
|
|
|
|
bool ManifestUAC = true;
|
|
|
|
StringRef ManifestLevel = "'asInvoker'";
|
|
|
|
StringRef ManifestUIAccess = "'false'";
|
|
|
|
StringRef ManifestFile;
|
|
|
|
|
2015-06-19 03:09:30 +08:00
|
|
|
// Used for /failifmismatch.
|
2015-06-05 03:21:24 +08:00
|
|
|
std::map<StringRef, StringRef> MustMatch;
|
|
|
|
|
2015-06-19 03:09:30 +08:00
|
|
|
// Used for /alternatename.
|
2015-06-19 07:04:26 +08:00
|
|
|
std::map<StringRef, StringRef> AlternateNames;
|
2015-06-19 03:09:30 +08:00
|
|
|
|
2015-07-26 05:42:33 +08:00
|
|
|
uint64_t ImageBase = -1;
|
2015-05-30 00:21:11 +08:00
|
|
|
uint64_t StackReserve = 1024 * 1024;
|
|
|
|
uint64_t StackCommit = 4096;
|
2015-05-30 00:23:40 +08:00
|
|
|
uint64_t HeapReserve = 1024 * 1024;
|
|
|
|
uint64_t HeapCommit = 4096;
|
2015-05-30 00:28:29 +08:00
|
|
|
uint32_t MajorImageVersion = 0;
|
|
|
|
uint32_t MinorImageVersion = 0;
|
2015-05-30 00:34:31 +08:00
|
|
|
uint32_t MajorOSVersion = 6;
|
|
|
|
uint32_t MinorOSVersion = 0;
|
2015-06-17 07:13:00 +08:00
|
|
|
bool DynamicBase = true;
|
|
|
|
bool AllowBind = true;
|
|
|
|
bool NxCompat = true;
|
|
|
|
bool AllowIsolation = true;
|
|
|
|
bool TerminalServerAware = true;
|
2015-07-28 11:12:00 +08:00
|
|
|
bool LargeAddressAware = false;
|
2015-07-28 11:15:57 +08:00
|
|
|
bool HighEntropyVA = false;
|
2015-05-29 03:09:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Configuration *Config;
|
|
|
|
|
|
|
|
} // namespace coff
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|