blob: 847fb81559b30236620a2565799a4117f9acdd8b [file] [log] [blame]
Rafael Espindolabeee25e2015-08-14 14:12:54 +00001//===- Config.h -------------------------------------------------*- C++ -*-===//
Michael J. Spencer84487f12015-07-24 21:03:07 +00002//
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_ELF_CONFIG_H
11#define LLD_ELF_CONFIG_H
12
Denis Protivensky8e3b38a2015-11-12 09:52:08 +000013#include "llvm/ADT/MapVector.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000014#include "llvm/ADT/StringRef.h"
Denis Protivensky1ef7b3f2015-10-07 09:13:03 +000015#include "llvm/Support/ELF.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000016
Rafael Espindolaeb990af2015-09-28 13:11:36 +000017#include <vector>
18
Michael J. Spencer84487f12015-07-24 21:03:07 +000019namespace lld {
Rafael Espindolae0df00b2016-02-28 00:25:54 +000020namespace elf {
Michael J. Spencer84487f12015-07-24 21:03:07 +000021
Rafael Espindolaaf707642015-10-12 01:55:32 +000022class InputFile;
Rui Ueyamaff777682015-10-09 21:12:40 +000023class SymbolBody;
24
Denis Protivensky1ef7b3f2015-10-07 09:13:03 +000025enum ELFKind {
26 ELFNoneKind,
27 ELF32LEKind,
28 ELF32BEKind,
29 ELF64LEKind,
30 ELF64BEKind
31};
32
Rui Ueyamaddec22d2016-01-05 17:55:05 +000033// This struct contains the global configuration for the linker.
34// Most fields are direct mapping from the command line options
35// and such fields have the same name as the corresponding options.
36// Most fields are initialized by the driver.
Michael J. Spencer84487f12015-07-24 21:03:07 +000037struct Configuration {
Rui Ueyamaff777682015-10-09 21:12:40 +000038 SymbolBody *EntrySym = nullptr;
Simon Atanasyan09dae7c2015-12-16 14:45:09 +000039 SymbolBody *MipsGpDisp = nullptr;
Simon Atanasyan597df212016-02-04 12:09:49 +000040 SymbolBody *MipsLocalGp = nullptr;
Rafael Espindolaaf707642015-10-12 01:55:32 +000041 InputFile *FirstElf = nullptr;
Rafael Espindola70107762015-09-11 18:49:42 +000042 llvm::StringRef DynamicLinker;
Rui Ueyama4993d0e2015-09-29 22:33:21 +000043 llvm::StringRef Entry;
Rafael Espindola525914d2015-10-11 03:36:49 +000044 llvm::StringRef Emulation;
Rui Ueyama2cac5842015-10-07 19:34:51 +000045 llvm::StringRef Fini;
46 llvm::StringRef Init;
Rui Ueyamaee592822015-10-07 00:25:09 +000047 llvm::StringRef OutputFile;
Rui Ueyama7de3f372015-10-01 19:36:04 +000048 llvm::StringRef SoName;
Rui Ueyama4993d0e2015-09-29 22:33:21 +000049 llvm::StringRef Sysroot;
Rafael Espindola2e9eac12015-09-11 21:18:56 +000050 std::string RPath;
Rui Ueyama52a15092015-10-11 03:28:42 +000051 std::vector<llvm::StringRef> SearchPaths;
George Rimar83f406c2015-10-19 17:35:12 +000052 std::vector<llvm::StringRef> Undefined;
Rui Ueyama797115252015-09-30 17:26:13 +000053 bool AllowMultipleDefinition;
Rui Ueyama35da9b62015-10-11 20:59:12 +000054 bool AsNeeded = false;
Davide Italianocebb4492015-10-13 21:02:34 +000055 bool Bsymbolic;
George Rimar5c36e592016-02-02 09:28:53 +000056 bool BsymbolicFunctions;
Rui Ueyamaa4a628f2016-01-13 18:55:39 +000057 bool Demangle = true;
Rui Ueyama797115252015-09-30 17:26:13 +000058 bool DiscardAll;
59 bool DiscardLocals;
60 bool DiscardNone;
George Rimarf6bc65a2016-01-15 13:34:52 +000061 bool EhFrameHdr;
Davide Italianoaad44022015-10-06 20:02:15 +000062 bool EnableNewDtags;
Rui Ueyama797115252015-09-30 17:26:13 +000063 bool ExportDynamic;
Rui Ueyamac4aaed92015-10-22 18:49:53 +000064 bool GcSections;
Igor Kudrin1b0d7062015-10-22 08:21:35 +000065 bool GnuHash = false;
Rui Ueyama0b289522016-02-25 18:43:51 +000066 bool ICF;
Rui Ueyama64558522015-10-16 22:51:43 +000067 bool Mips64EL = false;
Rui Ueyama797115252015-09-30 17:26:13 +000068 bool NoInhibitExec;
George Rimar57e40de2015-10-01 20:14:45 +000069 bool NoUndefined;
George Rimara5fbebc2015-12-10 09:12:18 +000070 bool PrintGcSections;
George Rimar58941ee2016-02-25 08:23:37 +000071 bool Relocatable;
Rui Ueyama797115252015-09-30 17:26:13 +000072 bool Shared;
Igor Kudrind912ee92015-10-01 16:42:03 +000073 bool Static = false;
George Rimar5dad7c12015-10-24 08:52:46 +000074 bool StripAll;
Igor Kudrin1b0d7062015-10-22 08:21:35 +000075 bool SysvHash = true;
Rui Ueyamaa4672402015-10-11 02:03:03 +000076 bool Verbose;
Rui Ueyama7b19c342015-11-24 18:48:16 +000077 bool ZExecStack;
Rui Ueyama03bec872015-11-20 21:00:42 +000078 bool ZNodelete;
79 bool ZNow;
80 bool ZOrigin;
George Rimare3336c02015-11-24 10:15:50 +000081 bool ZRelro;
Rui Ueyamae717a712015-10-13 16:20:50 +000082 ELFKind EKind = ELFNoneKind;
Denis Protivensky1ef7b3f2015-10-07 09:13:03 +000083 uint16_t EMachine = llvm::ELF::EM_NONE;
Rui Ueyama2b675072015-10-14 22:20:57 +000084 uint64_t EntryAddr = -1;
Rafael Espindola2c1217d2015-10-23 19:02:19 +000085 unsigned Optimize = 0;
Michael J. Spencer84487f12015-07-24 21:03:07 +000086};
87
Rui Ueyamaddec22d2016-01-05 17:55:05 +000088// The only instance of Configuration struct.
Michael J. Spencer84487f12015-07-24 21:03:07 +000089extern Configuration *Config;
90
Rafael Espindolae0df00b2016-02-28 00:25:54 +000091} // namespace elf
Michael J. Spencer84487f12015-07-24 21:03:07 +000092} // namespace lld
93
94#endif