2015-08-14 22:12:54 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_CONFIG_H
|
|
|
|
#define LLD_ELF_CONFIG_H
|
|
|
|
|
2015-11-12 17:52:08 +08:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-06-23 15:00:17 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2015-10-07 17:13:03 +08:00
|
|
|
#include "llvm/Support/ELF.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-09-28 21:11:36 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-10-12 09:55:32 +08:00
|
|
|
class InputFile;
|
2016-04-15 22:41:56 +08:00
|
|
|
struct Symbol;
|
2015-10-10 05:12:40 +08:00
|
|
|
|
2015-10-07 17:13:03 +08:00
|
|
|
enum ELFKind {
|
|
|
|
ELFNoneKind,
|
|
|
|
ELF32LEKind,
|
|
|
|
ELF32BEKind,
|
|
|
|
ELF64LEKind,
|
|
|
|
ELF64BEKind
|
|
|
|
};
|
|
|
|
|
2016-05-14 05:55:56 +08:00
|
|
|
enum class BuildIdKind { None, Fnv1, Md5, Sha1, Hexstring };
|
2016-04-08 06:49:21 +08:00
|
|
|
|
2016-06-20 19:55:12 +08:00
|
|
|
// This struct contains symbols version definition that
|
|
|
|
// can be found in version script if it is used for link.
|
|
|
|
struct Version {
|
|
|
|
Version(llvm::StringRef Name) : Name(Name) {}
|
|
|
|
llvm::StringRef Name;
|
2016-06-22 22:40:45 +08:00
|
|
|
llvm::StringRef Parent;
|
2016-06-20 19:55:12 +08:00
|
|
|
std::vector<llvm::StringRef> Globals;
|
|
|
|
size_t NameOff; // Offset in string table.
|
|
|
|
};
|
|
|
|
|
2016-01-06 01:55:05 +08:00
|
|
|
// This struct contains the global configuration for the linker.
|
|
|
|
// Most fields are direct mapping from the command line options
|
|
|
|
// and such fields have the same name as the corresponding options.
|
|
|
|
// Most fields are initialized by the driver.
|
2015-07-25 05:03:07 +08:00
|
|
|
struct Configuration {
|
2016-04-15 22:41:56 +08:00
|
|
|
Symbol *EntrySym = nullptr;
|
2015-10-12 09:55:32 +08:00
|
|
|
InputFile *FirstElf = nullptr;
|
2015-09-12 02:49:42 +08:00
|
|
|
llvm::StringRef DynamicLinker;
|
2015-09-30 06:33:21 +08:00
|
|
|
llvm::StringRef Entry;
|
2015-10-11 11:36:49 +08:00
|
|
|
llvm::StringRef Emulation;
|
2015-10-08 03:34:51 +08:00
|
|
|
llvm::StringRef Fini;
|
|
|
|
llvm::StringRef Init;
|
2016-06-03 06:58:11 +08:00
|
|
|
llvm::StringRef LtoAAPipeline;
|
2016-05-16 03:29:38 +08:00
|
|
|
llvm::StringRef LtoNewPmPasses;
|
2015-10-07 08:25:09 +08:00
|
|
|
llvm::StringRef OutputFile;
|
2015-10-02 03:36:04 +08:00
|
|
|
llvm::StringRef SoName;
|
2015-09-30 06:33:21 +08:00
|
|
|
llvm::StringRef Sysroot;
|
2016-06-23 15:00:17 +08:00
|
|
|
llvm::StringSet<> TraceSymbol;
|
2015-09-12 05:18:56 +08:00
|
|
|
std::string RPath;
|
2016-06-20 19:55:12 +08:00
|
|
|
std::vector<Version> SymbolVersions;
|
2016-04-14 02:51:11 +08:00
|
|
|
std::vector<llvm::StringRef> DynamicList;
|
2015-10-11 11:28:42 +08:00
|
|
|
std::vector<llvm::StringRef> SearchPaths;
|
2015-10-20 01:35:12 +08:00
|
|
|
std::vector<llvm::StringRef> Undefined;
|
2016-04-23 04:21:26 +08:00
|
|
|
std::vector<llvm::StringRef> VersionScriptGlobals;
|
2016-05-14 05:55:56 +08:00
|
|
|
std::vector<uint8_t> BuildIdVector;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool AllowMultipleDefinition;
|
2015-10-12 04:59:12 +08:00
|
|
|
bool AsNeeded = false;
|
2015-10-14 05:02:34 +08:00
|
|
|
bool Bsymbolic;
|
2016-02-02 17:28:53 +08:00
|
|
|
bool BsymbolicFunctions;
|
2016-01-14 02:55:39 +08:00
|
|
|
bool Demangle = true;
|
2016-04-03 11:39:09 +08:00
|
|
|
bool DisableVerify;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool DiscardAll;
|
|
|
|
bool DiscardLocals;
|
|
|
|
bool DiscardNone;
|
2016-01-15 21:34:52 +08:00
|
|
|
bool EhFrameHdr;
|
2015-10-07 04:02:15 +08:00
|
|
|
bool EnableNewDtags;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool ExportDynamic;
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
bool GcSections;
|
2015-10-22 16:21:35 +08:00
|
|
|
bool GnuHash = false;
|
2016-02-26 02:43:51 +08:00
|
|
|
bool ICF;
|
2015-10-17 06:51:43 +08:00
|
|
|
bool Mips64EL = false;
|
2016-04-08 04:41:41 +08:00
|
|
|
bool NoGnuUnique;
|
2015-10-02 04:14:45 +08:00
|
|
|
bool NoUndefined;
|
2016-03-08 12:06:29 +08:00
|
|
|
bool NoinhibitExec;
|
2016-03-17 13:57:33 +08:00
|
|
|
bool Pic;
|
|
|
|
bool Pie;
|
2015-12-10 17:12:18 +08:00
|
|
|
bool PrintGcSections;
|
2016-03-14 04:10:20 +08:00
|
|
|
bool Rela;
|
2016-02-25 16:23:37 +08:00
|
|
|
bool Relocatable;
|
2016-03-10 04:01:08 +08:00
|
|
|
bool SaveTemps;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool Shared;
|
2015-10-02 00:42:03 +08:00
|
|
|
bool Static = false;
|
2015-10-24 16:52:46 +08:00
|
|
|
bool StripAll;
|
2016-04-08 05:04:51 +08:00
|
|
|
bool StripDebug;
|
2015-10-22 16:21:35 +08:00
|
|
|
bool SysvHash = true;
|
2016-03-11 12:23:12 +08:00
|
|
|
bool Threads;
|
2016-03-29 16:45:40 +08:00
|
|
|
bool Trace;
|
2015-10-11 10:03:03 +08:00
|
|
|
bool Verbose;
|
2016-06-17 21:38:09 +08:00
|
|
|
bool VersionScriptGlobalByDefault = true;
|
2016-03-14 17:19:30 +08:00
|
|
|
bool WarnCommon;
|
2016-05-10 23:47:57 +08:00
|
|
|
bool ZCombreloc;
|
2016-05-11 21:48:41 +08:00
|
|
|
bool ZDefs;
|
2015-11-25 02:48:16 +08:00
|
|
|
bool ZExecStack;
|
2015-11-21 05:00:42 +08:00
|
|
|
bool ZNodelete;
|
|
|
|
bool ZNow;
|
|
|
|
bool ZOrigin;
|
2015-11-24 18:15:50 +08:00
|
|
|
bool ZRelro;
|
2016-04-08 06:49:21 +08:00
|
|
|
BuildIdKind BuildId = BuildIdKind::None;
|
2015-10-14 00:20:50 +08:00
|
|
|
ELFKind EKind = ELFNoneKind;
|
2015-10-07 17:13:03 +08:00
|
|
|
uint16_t EMachine = llvm::ELF::EM_NONE;
|
2015-10-15 06:20:57 +08:00
|
|
|
uint64_t EntryAddr = -1;
|
2016-04-16 06:38:10 +08:00
|
|
|
unsigned LtoJobs;
|
2016-04-01 05:15:31 +08:00
|
|
|
unsigned LtoO;
|
|
|
|
unsigned Optimize;
|
2015-07-25 05:03:07 +08:00
|
|
|
};
|
|
|
|
|
2016-01-06 01:55:05 +08:00
|
|
|
// The only instance of Configuration struct.
|
2015-07-25 05:03:07 +08:00
|
|
|
extern Configuration *Config;
|
|
|
|
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2015-07-25 05:03:07 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|