blob: abbe8a9e134c7055e2ef559f8a78a1492273b4b3 [file] [log] [blame]
Rui Ueyama717677a2016-02-11 21:17:59 +00001//===- LinkerScript.h -------------------------------------------*- C++ -*-===//
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_ELF_LINKER_SCRIPT_H
11#define LLD_ELF_LINKER_SCRIPT_H
12
George Rimarbe394db2016-09-16 20:21:55 +000013#include "Config.h"
George Rimarc91930a2016-09-02 21:17:20 +000014#include "Strings.h"
Eugene Leviantbbe38602016-07-19 09:25:43 +000015#include "Writer.h"
Rui Ueyama717677a2016-02-11 21:17:59 +000016#include "lld/Core/LLVM.h"
Eugene Zelenko22886a22016-11-05 01:00:56 +000017#include "llvm/ADT/ArrayRef.h"
Meador Ingeb8897442017-01-24 02:34:00 +000018#include "llvm/ADT/DenseMap.h"
Rafael Espindolad3190792016-09-16 15:10:23 +000019#include "llvm/ADT/DenseSet.h"
Eugene Zelenko22886a22016-11-05 01:00:56 +000020#include "llvm/ADT/StringRef.h"
Rui Ueyamaf9de0d62016-02-11 21:38:55 +000021#include "llvm/Support/MemoryBuffer.h"
Eugene Zelenko22886a22016-11-05 01:00:56 +000022#include <cstddef>
23#include <cstdint>
Rui Ueyama8c6a5aa2016-11-05 22:37:59 +000024#include <functional>
Eugene Zelenko22886a22016-11-05 01:00:56 +000025#include <memory>
26#include <vector>
Rui Ueyama717677a2016-02-11 21:17:59 +000027
28namespace lld {
Rafael Espindolae0df00b2016-02-28 00:25:54 +000029namespace elf {
Eugene Zelenko22886a22016-11-05 01:00:56 +000030
Rafael Espindolae7553e42016-08-31 13:28:33 +000031class DefinedCommon;
George Rimardbb76db2016-08-18 13:00:49 +000032class ScriptParser;
Rui Ueyama8d083e62016-07-29 05:48:39 +000033class SymbolBody;
Rafael Espindolab4c9b812017-02-23 02:28:28 +000034class InputSectionBase;
Rafael Espindola774ea7d2017-02-23 16:49:07 +000035class InputSection;
Rafael Espindola24e6f362017-02-24 15:07:30 +000036class OutputSection;
Rui Ueyama02a036f2017-02-27 02:31:48 +000037class OutputSectionFactory;
Rafael Espindolac404d502017-02-23 02:32:18 +000038class InputSectionBase;
Rafael Espindola9bd45662017-03-10 00:47:33 +000039class SectionBase;
Rui Ueyama717677a2016-02-11 21:17:59 +000040
Rui Ueyamab04af132016-10-13 23:08:33 +000041// This represents an expression in the linker script.
42// ScriptParser::readExpr reads an expression and returns an Expr.
43// Later, we evaluate the expression by calling the function
44// with the value of special context variable ".".
Rafael Espindolaf6613932016-10-31 17:43:38 +000045struct Expr {
Rafael Espindola4595df92017-03-10 16:04:26 +000046 std::function<uint64_t()> Val;
Rafael Espindola2f831dc2016-10-31 19:56:37 +000047 std::function<bool()> IsAbsolute;
Eugene Leviantafaa9342016-11-16 09:49:39 +000048
49 // If expression is section-relative the function below is used
50 // to get the output section pointer.
Rafael Espindola9bd45662017-03-10 00:47:33 +000051 std::function<SectionBase *()> Section;
Eugene Leviantafaa9342016-11-16 09:49:39 +000052
Rafael Espindola4595df92017-03-10 16:04:26 +000053 uint64_t operator()() const { return Val(); }
Rafael Espindolaf6613932016-10-31 17:43:38 +000054 operator bool() const { return (bool)Val; }
55
Rafael Espindola4595df92017-03-10 16:04:26 +000056 Expr(std::function<uint64_t()> Val, std::function<bool()> IsAbsolute,
Rafael Espindola9bd45662017-03-10 00:47:33 +000057 std::function<SectionBase *()> Section)
Eugene Leviantafaa9342016-11-16 09:49:39 +000058 : Val(Val), IsAbsolute(IsAbsolute), Section(Section) {}
59 template <typename T>
Rui Ueyama009d1742016-11-18 06:49:09 +000060 Expr(T V) : Expr(V, [] { return true; }, [] { return nullptr; }) {}
Rafael Espindolaf6613932016-10-31 17:43:38 +000061 Expr() : Expr(nullptr) {}
62};
Rui Ueyama708019c2016-07-24 18:19:40 +000063
Rui Ueyama07320e42016-04-20 20:13:41 +000064// Parses a linker script. Calling this function updates
65// Config and ScriptConfig.
66void readLinkerScript(MemoryBufferRef MB);
67
Rui Ueyamab04af132016-10-13 23:08:33 +000068// Parses a version script.
George Rimar20b65982016-08-31 09:08:26 +000069void readVersionScript(MemoryBufferRef MB);
70
Rafael Espindolad0ebd842016-12-08 17:54:26 +000071void readDynamicList(MemoryBufferRef MB);
72
George Rimareea31142016-07-21 14:26:59 +000073// This enum is used to implement linker script SECTIONS command.
74// https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS
75enum SectionsCommandKind {
George Rimare38cbab2016-09-26 19:22:50 +000076 AssignmentKind, // . = expr or <sym> = expr
George Rimareea31142016-07-21 14:26:59 +000077 OutputSectionKind,
George Rimareefa7582016-08-04 09:29:31 +000078 InputSectionKind,
George Rimare38cbab2016-09-26 19:22:50 +000079 AssertKind, // ASSERT(expr)
80 BytesDataKind // BYTE(expr), SHORT(expr), LONG(expr) or QUAD(expr)
Rui Ueyama1ebc8ed2016-02-12 21:47:28 +000081};
82
George Rimar076fe152016-07-21 06:43:01 +000083struct BaseCommand {
84 BaseCommand(int K) : Kind(K) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +000085
86 virtual ~BaseCommand() = default;
87
George Rimar076fe152016-07-21 06:43:01 +000088 int Kind;
89};
90
Rui Ueyamab04af132016-10-13 23:08:33 +000091// This represents ". = <expr>" or "<symbol> = <expr>".
George Rimar076fe152016-07-21 06:43:01 +000092struct SymbolAssignment : BaseCommand {
George Rimara8d8dcf2017-02-22 09:13:04 +000093 SymbolAssignment(StringRef Name, Expr E, std::string Loc)
94 : BaseCommand(AssignmentKind), Name(Name), Expression(E), Location(Loc) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +000095
George Rimar076fe152016-07-21 06:43:01 +000096 static bool classof(const BaseCommand *C);
Rui Ueyama20204242016-07-29 05:52:33 +000097
98 // The LHS of an expression. Name is either a symbol name or ".".
George Rimar076fe152016-07-21 06:43:01 +000099 StringRef Name;
Rui Ueyama20204242016-07-29 05:52:33 +0000100 SymbolBody *Sym = nullptr;
101
102 // The RHS of an expression.
Rui Ueyama708019c2016-07-24 18:19:40 +0000103 Expr Expression;
Rui Ueyama20204242016-07-29 05:52:33 +0000104
105 // Command attributes for PROVIDE, HIDDEN and PROVIDE_HIDDEN.
Eugene Levianta31c91b2016-07-22 07:38:40 +0000106 bool Provide = false;
Eugene Levianta31c91b2016-07-22 07:38:40 +0000107 bool Hidden = false;
George Rimar2ee2d2d2017-02-21 14:50:38 +0000108
George Rimara8d8dcf2017-02-22 09:13:04 +0000109 // Holds file name and line number for error reporting.
George Rimar2ee2d2d2017-02-21 14:50:38 +0000110 std::string Location;
George Rimar076fe152016-07-21 06:43:01 +0000111};
112
Davide Italiano246f6812016-07-22 03:36:24 +0000113// Linker scripts allow additional constraints to be put on ouput sections.
Rui Ueyamab04af132016-10-13 23:08:33 +0000114// If an output section is marked as ONLY_IF_RO, the section is created
115// only if its input sections are read-only. Likewise, an output section
116// with ONLY_IF_RW is created if all input sections are RW.
Rui Ueyamaefc40662016-07-25 22:00:10 +0000117enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite };
Davide Italiano246f6812016-07-22 03:36:24 +0000118
George Rimar076fe152016-07-21 06:43:01 +0000119struct OutputSectionCommand : BaseCommand {
120 OutputSectionCommand(StringRef Name)
121 : BaseCommand(OutputSectionKind), Name(Name) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +0000122
George Rimar076fe152016-07-21 06:43:01 +0000123 static bool classof(const BaseCommand *C);
Eugene Zelenko22886a22016-11-05 01:00:56 +0000124
Eugene Levianteda81a12016-07-12 06:39:48 +0000125 StringRef Name;
George Rimar58e5c4d2016-07-25 08:29:46 +0000126 Expr AddrExpr;
George Rimar630c6172016-07-26 18:06:29 +0000127 Expr AlignExpr;
Eugene Leviantb71d6f72016-10-06 09:39:28 +0000128 Expr LMAExpr;
George Rimardb24d9c2016-08-19 15:18:23 +0000129 Expr SubalignExpr;
George Rimareea31142016-07-21 14:26:59 +0000130 std::vector<std::unique_ptr<BaseCommand>> Commands;
Eugene Leviantbbe38602016-07-19 09:25:43 +0000131 std::vector<StringRef> Phdrs;
Rui Ueyama16068ae2016-11-19 18:05:56 +0000132 uint32_t Filler = 0;
Rui Ueyamaefc40662016-07-25 22:00:10 +0000133 ConstraintKind Constraint = ConstraintKind::NoConstraint;
Eugene Leviant2a942c42016-12-05 16:38:32 +0000134 std::string Location;
Meador Ingeb8897442017-01-24 02:34:00 +0000135 std::string MemoryRegionName;
Eugene Leviantbbe38602016-07-19 09:25:43 +0000136};
137
George Rimar8034d492016-09-17 07:31:49 +0000138// This struct represents one section match pattern in SECTIONS() command.
Rui Ueyama4dc07be2016-09-17 02:23:40 +0000139// It can optionally have negative match pattern for EXCLUDED_FILE command.
George Rimar07171f22016-09-21 15:56:44 +0000140// Also it may be surrounded with SORT() command, so contains sorting rules.
Rui Ueyama4dc07be2016-09-17 02:23:40 +0000141struct SectionPattern {
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000142 SectionPattern(StringMatcher &&Pat1, StringMatcher &&Pat2)
143 : ExcludedFilePat(Pat1), SectionPat(Pat2) {}
Rui Ueyamad1d7cfc2016-09-20 00:02:06 +0000144
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000145 StringMatcher ExcludedFilePat;
146 StringMatcher SectionPat;
George Rimar07171f22016-09-21 15:56:44 +0000147 SortSectionPolicy SortOuter;
148 SortSectionPolicy SortInner;
Rui Ueyama4dc07be2016-09-17 02:23:40 +0000149};
150
George Rimareea31142016-07-21 14:26:59 +0000151struct InputSectionDescription : BaseCommand {
George Rimarc91930a2016-09-02 21:17:20 +0000152 InputSectionDescription(StringRef FilePattern)
Vitaly Buka0b7de062016-12-21 02:27:14 +0000153 : BaseCommand(InputSectionKind), FilePat(FilePattern) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +0000154
George Rimareea31142016-07-21 14:26:59 +0000155 static bool classof(const BaseCommand *C);
Eugene Zelenko22886a22016-11-05 01:00:56 +0000156
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000157 StringMatcher FilePat;
Rui Ueyama4dc07be2016-09-17 02:23:40 +0000158
George Rimar8034d492016-09-17 07:31:49 +0000159 // Input sections that matches at least one of SectionPatterns
Rui Ueyama70efa2f2016-09-17 02:34:50 +0000160 // will be associated with this InputSectionDescription.
Rui Ueyamad1d7cfc2016-09-20 00:02:06 +0000161 std::vector<SectionPattern> SectionPatterns;
Rui Ueyama4dc07be2016-09-17 02:23:40 +0000162
Rafael Espindolac404d502017-02-23 02:32:18 +0000163 std::vector<InputSectionBase *> Sections;
George Rimareea31142016-07-21 14:26:59 +0000164};
165
Rui Ueyamab04af132016-10-13 23:08:33 +0000166// Represents an ASSERT().
George Rimareefa7582016-08-04 09:29:31 +0000167struct AssertCommand : BaseCommand {
168 AssertCommand(Expr E) : BaseCommand(AssertKind), Expression(E) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +0000169
George Rimareefa7582016-08-04 09:29:31 +0000170 static bool classof(const BaseCommand *C);
Eugene Zelenko22886a22016-11-05 01:00:56 +0000171
George Rimareefa7582016-08-04 09:29:31 +0000172 Expr Expression;
173};
174
Rui Ueyamab04af132016-10-13 23:08:33 +0000175// Represents BYTE(), SHORT(), LONG(), or QUAD().
George Rimare38cbab2016-09-26 19:22:50 +0000176struct BytesDataCommand : BaseCommand {
Meador Inge95c7d8d2016-12-08 23:21:30 +0000177 BytesDataCommand(Expr E, unsigned Size)
178 : BaseCommand(BytesDataKind), Expression(E), Size(Size) {}
Eugene Zelenko22886a22016-11-05 01:00:56 +0000179
George Rimare38cbab2016-09-26 19:22:50 +0000180 static bool classof(const BaseCommand *C);
Eugene Zelenko22886a22016-11-05 01:00:56 +0000181
Meador Inge95c7d8d2016-12-08 23:21:30 +0000182 Expr Expression;
George Rimare38cbab2016-09-26 19:22:50 +0000183 unsigned Offset;
184 unsigned Size;
185};
186
Eugene Leviantbbe38602016-07-19 09:25:43 +0000187struct PhdrsCommand {
188 StringRef Name;
189 unsigned Type;
190 bool HasFilehdr;
191 bool HasPhdrs;
Eugene Leviant865bf862016-07-21 10:43:25 +0000192 unsigned Flags;
Eugene Leviant56b21c82016-09-09 09:46:16 +0000193 Expr LMAExpr;
George Rimar652852c2016-04-16 10:10:32 +0000194};
195
Meador Ingeb8897442017-01-24 02:34:00 +0000196// This struct is used to represent the location and size of regions of
197// target memory. Instances of the struct are created by parsing the
198// MEMORY command.
199struct MemoryRegion {
200 std::string Name;
201 uint64_t Origin;
202 uint64_t Length;
203 uint64_t Offset;
204 uint32_t Flags;
Rui Ueyama8a8a9532017-01-26 02:58:59 +0000205 uint32_t NegFlags;
Meador Ingeb8897442017-01-24 02:34:00 +0000206};
207
George Rimar884e7862016-09-08 08:19:13 +0000208class LinkerScriptBase {
Rafael Espindola4d1e4d72016-09-08 14:11:08 +0000209protected:
210 ~LinkerScriptBase() = default;
Rafael Espindola5616adf2017-03-08 22:36:28 +0000211 OutputSection *Aether;
Rafael Espindola4d1e4d72016-09-08 14:11:08 +0000212
George Rimar884e7862016-09-08 08:19:13 +0000213public:
George Rimar884e7862016-09-08 08:19:13 +0000214 virtual uint64_t getHeaderSize() = 0;
Eugene Leviantf6aeed32016-12-22 13:13:12 +0000215 virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0;
Rafael Espindola4595df92017-03-10 16:04:26 +0000216 uint64_t getDot() { return getSymbolValue("", "."); }
George Rimarf34f45f2016-09-23 13:17:23 +0000217 virtual bool isDefined(StringRef S) = 0;
Rafael Espindola2f831dc2016-10-31 19:56:37 +0000218 virtual bool isAbsolute(StringRef S) = 0;
Rafael Espindola5616adf2017-03-08 22:36:28 +0000219 virtual OutputSection *getSymbolSection(StringRef S) = 0;
220 virtual OutputSection *getOutputSection(const Twine &Loc, StringRef S) = 0;
Rui Ueyamaedf75e72016-11-17 20:27:10 +0000221 virtual uint64_t getOutputSectionSize(StringRef S) = 0;
George Rimar884e7862016-09-08 08:19:13 +0000222};
223
Rui Ueyama07320e42016-04-20 20:13:41 +0000224// ScriptConfiguration holds linker script parse results.
225struct ScriptConfiguration {
George Rimar652852c2016-04-16 10:10:32 +0000226 // Used to assign addresses to sections.
George Rimar076fe152016-07-21 06:43:01 +0000227 std::vector<std::unique_ptr<BaseCommand>> Commands;
George Rimar652852c2016-04-16 10:10:32 +0000228
Eugene Leviantbbe38602016-07-19 09:25:43 +0000229 // Used to assign sections to headers.
George Rimar70ce0a92016-07-20 15:09:10 +0000230 std::vector<PhdrsCommand> PhdrsCommands;
231
Eugene Leviante05336ff2016-09-14 08:32:36 +0000232 bool HasSections = false;
Rui Ueyama07320e42016-04-20 20:13:41 +0000233
Rui Ueyama8ec77e62016-04-21 22:00:51 +0000234 // List of section patterns specified with KEEP commands. They will
235 // be kept even if they are unused and --gc-sections is specified.
Eugene Leviantcf43f172016-10-05 09:36:59 +0000236 std::vector<InputSectionDescription *> KeptSections;
Meador Ingeb8897442017-01-24 02:34:00 +0000237
238 // A map from memory region name to a memory region descriptor.
239 llvm::DenseMap<llvm::StringRef, MemoryRegion> MemoryRegions;
Rui Ueyama717677a2016-02-11 21:17:59 +0000240};
241
Rui Ueyama07320e42016-04-20 20:13:41 +0000242extern ScriptConfiguration *ScriptConfig;
243
244// This is a runner of the linker script.
George Rimar884e7862016-09-08 08:19:13 +0000245template <class ELFT> class LinkerScript final : public LinkerScriptBase {
Rui Ueyama0b3868e2016-04-22 20:41:07 +0000246 typedef typename ELFT::uint uintX_t;
247
Rui Ueyama07320e42016-04-20 20:13:41 +0000248public:
Rui Ueyamaf34d0e02016-08-12 01:24:53 +0000249 LinkerScript();
250 ~LinkerScript();
Eugene Zelenko22886a22016-11-05 01:00:56 +0000251
Rui Ueyama02a036f2017-02-27 02:31:48 +0000252 void processCommands(OutputSectionFactory &Factory);
253 void addOrphanSections(OutputSectionFactory &Factory);
Rafael Espindola07fe6122016-11-14 14:23:35 +0000254 void removeEmptyCommands();
Rafael Espindola9546fff2016-09-22 14:40:50 +0000255 void adjustSectionsBeforeSorting();
Rafael Espindolaf7a17442016-11-14 15:39:38 +0000256 void adjustSectionsAfterSorting();
Rui Ueyamaa7f78842016-07-20 17:19:03 +0000257
Rafael Espindola17cb7c02016-12-19 17:01:01 +0000258 std::vector<PhdrEntry> createPhdrs();
Eugene Leviantf9bc3bd2016-08-16 06:40:58 +0000259 bool ignoreInterpSection();
Rui Ueyamaadca2452016-07-23 14:18:48 +0000260
Rui Ueyama16068ae2016-11-19 18:05:56 +0000261 uint32_t getFiller(StringRef Name);
George Rimare38cbab2016-09-26 19:22:50 +0000262 void writeDataBytes(StringRef Name, uint8_t *Buf);
Eugene Leviantb71d6f72016-10-06 09:39:28 +0000263 bool hasLMA(StringRef Name);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000264 bool shouldKeep(InputSectionBase *S);
Rafael Espindolad3190792016-09-16 15:10:23 +0000265 void assignOffsets(OutputSectionCommand *Cmd);
Rafael Espindola337f9032016-11-14 14:13:32 +0000266 void placeOrphanSections();
Rafael Espindola17cb7c02016-12-19 17:01:01 +0000267 void assignAddresses(std::vector<PhdrEntry> &Phdrs);
Eugene Leviantbbe38602016-07-19 09:25:43 +0000268 bool hasPhdrsCommands();
George Rimar884e7862016-09-08 08:19:13 +0000269 uint64_t getHeaderSize() override;
Eugene Leviantf6aeed32016-12-22 13:13:12 +0000270 uint64_t getSymbolValue(const Twine &Loc, StringRef S) override;
George Rimarf34f45f2016-09-23 13:17:23 +0000271 bool isDefined(StringRef S) override;
Rafael Espindola2f831dc2016-10-31 19:56:37 +0000272 bool isAbsolute(StringRef S) override;
Rafael Espindola5616adf2017-03-08 22:36:28 +0000273 OutputSection *getSymbolSection(StringRef S) override;
274 OutputSection *getOutputSection(const Twine &Loc, StringRef S) override;
Rui Ueyamaedf75e72016-11-17 20:27:10 +0000275 uint64_t getOutputSectionSize(StringRef S) override;
Rui Ueyama07320e42016-04-20 20:13:41 +0000276
Rafael Espindola24e6f362017-02-24 15:07:30 +0000277 std::vector<OutputSection *> *OutputSections;
Rafael Espindolaa4b41dc2016-08-04 12:13:05 +0000278
Rafael Espindolab6b8f6c2016-09-20 22:43:15 +0000279 int getSectionIndex(StringRef Name);
280
Rui Ueyama07320e42016-04-20 20:13:41 +0000281private:
Rafael Espindola4cd73522017-02-17 16:01:51 +0000282 void assignSymbol(SymbolAssignment *Cmd, bool InSec = false);
283 void addSymbol(SymbolAssignment *Cmd);
Rafael Espindolae71a3f8a2016-09-16 20:34:02 +0000284 void computeInputSections(InputSectionDescription *);
George Rimar2ee2d2d2017-02-21 14:50:38 +0000285 void setDot(Expr E, const Twine &Loc, bool InSec = false);
Rui Ueyama6b274812016-07-25 22:51:07 +0000286
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000287 void discard(ArrayRef<InputSectionBase *> V);
Rui Ueyama48c3f1c2016-08-12 00:27:23 +0000288
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000289 std::vector<InputSectionBase *>
Rui Ueyama0b9ce6a2016-08-12 03:16:56 +0000290 createInputSectionList(OutputSectionCommand &Cmd);
291
Rui Ueyamac998a8c2016-04-22 00:03:13 +0000292 // "ScriptConfig" is a bit too long, so define a short name for it.
293 ScriptConfiguration &Opt = *ScriptConfig;
294
Rui Ueyamaedebbdf2016-07-24 23:47:31 +0000295 std::vector<size_t> getPhdrIndices(StringRef SectionName);
Eugene Leviant2a942c42016-12-05 16:38:32 +0000296 size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);
Rui Ueyama07320e42016-04-20 20:13:41 +0000297
Rafael Espindola24e6f362017-02-24 15:07:30 +0000298 MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd, OutputSection *Sec);
Meador Ingeb8897442017-01-24 02:34:00 +0000299
Rui Ueyama0b3868e2016-04-22 20:41:07 +0000300 uintX_t Dot;
George Rimar21467872017-02-23 07:57:55 +0000301 std::function<uint64_t()> LMAOffset;
Rafael Espindola24e6f362017-02-24 15:07:30 +0000302 OutputSection *CurOutSec = nullptr;
Meador Ingeb8897442017-01-24 02:34:00 +0000303 MemoryRegion *CurMemRegion = nullptr;
Rafael Espindolad3190792016-09-16 15:10:23 +0000304 uintX_t ThreadBssOffset = 0;
Rafael Espindola24e6f362017-02-24 15:07:30 +0000305 void switchTo(OutputSection *Sec);
Rafael Espindolad3190792016-09-16 15:10:23 +0000306 void flush();
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000307 void output(InputSection *Sec);
Rafael Espindolad3190792016-09-16 15:10:23 +0000308 void process(BaseCommand &Base);
Rafael Espindola24e6f362017-02-24 15:07:30 +0000309 llvm::DenseSet<OutputSection *> AlreadyOutputOS;
Rafael Espindolac404d502017-02-23 02:32:18 +0000310 llvm::DenseSet<InputSectionBase *> AlreadyOutputIS;
Rui Ueyama07320e42016-04-20 20:13:41 +0000311};
312
313// Variable template is a C++14 feature, so we can't template
314// a global variable. Use a struct to workaround.
315template <class ELFT> struct Script { static LinkerScript<ELFT> *X; };
316template <class ELFT> LinkerScript<ELFT> *Script<ELFT>::X;
Rui Ueyama717677a2016-02-11 21:17:59 +0000317
George Rimar884e7862016-09-08 08:19:13 +0000318extern LinkerScriptBase *ScriptBase;
319
Eugene Zelenko22886a22016-11-05 01:00:56 +0000320} // end namespace elf
321} // end namespace lld
Rui Ueyama717677a2016-02-11 21:17:59 +0000322
Eugene Zelenko22886a22016-11-05 01:00:56 +0000323#endif // LLD_ELF_LINKER_SCRIPT_H