1 //===- Config.h -------------------------------------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_ELF_CONFIG_H
11 #define LLD_ELF_CONFIG_H
13 #include "llvm/ADT/MapVector.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/StringSet.h"
16 #include "llvm/Support/ELF.h"
35 enum class BuildIdKind { None, Fast, Md5, Sha1, Hexstring, Uuid };
37 // For --discard-{all,locals,none} and --retain-symbols-file.
38 enum class DiscardPolicy { Default, All, Locals, RetainFile, None };
40 // For --strip-{all,debug}.
41 enum class StripPolicy { None, All, Debug };
43 // For --unresolved-symbols.
44 enum class UnresolvedPolicy { NoUndef, ReportError, Warn, Ignore };
46 // For --sort-section and linkerscript sorting rules.
47 enum class SortSectionPolicy { Default, None, Alignment, Name, Priority };
50 enum class Target2Policy { Abs, Rel, GotRel };
52 struct SymbolVersion {
58 // This struct contains symbols version definition that
59 // can be found in version script if it is used for link.
60 struct VersionDefinition {
61 VersionDefinition(llvm::StringRef Name, uint16_t Id) : Name(Name), Id(Id) {}
64 std::vector<SymbolVersion> Globals;
65 size_t NameOff; // Offset in string table.
68 // This struct contains the global configuration for the linker.
69 // Most fields are direct mapping from the command line options
70 // and such fields have the same name as the corresponding options.
71 // Most fields are initialized by the driver.
72 struct Configuration {
73 InputFile *FirstElf = nullptr;
75 llvm::StringMap<uint64_t> SectionStartMap;
76 llvm::StringRef DynamicLinker;
77 llvm::StringRef Entry;
78 llvm::StringRef Emulation;
81 llvm::StringRef LTOAAPipeline;
82 llvm::StringRef LTONewPmPasses;
83 llvm::StringRef OutputFile;
84 llvm::StringRef SoName;
85 llvm::StringRef Sysroot;
86 llvm::StringSet<> RetainSymbolsFile;
88 std::vector<VersionDefinition> VersionDefinitions;
89 std::vector<llvm::StringRef> AuxiliaryList;
90 std::vector<llvm::StringRef> SearchPaths;
91 std::vector<llvm::StringRef> SymbolOrderingFile;
92 std::vector<llvm::StringRef> Undefined;
93 std::vector<SymbolVersion> VersionScriptGlobals;
94 std::vector<SymbolVersion> VersionScriptLocals;
95 std::vector<uint8_t> BuildIdVector;
96 bool AllowMultipleDefinition;
97 bool AsNeeded = false;
99 bool BsymbolicFunctions;
100 bool ColorDiagnostics = false;
102 bool Demangle = true;
110 bool GnuHash = false;
112 bool Mips64EL = false;
113 bool MipsN32Abi = false;
115 bool NoUndefinedVersion;
121 bool PrintGcSections;
128 bool SysvHash = true;
134 bool WarnMissingEntry;
143 DiscardPolicy Discard;
144 SortSectionPolicy SortSection;
145 StripPolicy Strip = StripPolicy::None;
146 UnresolvedPolicy UnresolvedSymbols;
147 Target2Policy Target2 = Target2Policy::GotRel;
148 BuildIdKind BuildId = BuildIdKind::None;
149 ELFKind EKind = ELFNoneKind;
150 uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
151 uint16_t EMachine = llvm::ELF::EM_NONE;
152 uint64_t ErrorLimit = 20;
154 uint64_t MaxPageSize;
156 unsigned LTOPartitions;
159 unsigned ThinLTOJobs;
162 // The only instance of Configuration struct.
163 extern Configuration *Config;