2016-02-12 05:17:59 +08:00
|
|
|
//===- LinkerScript.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_LINKER_SCRIPT_H
|
|
|
|
#define LLD_ELF_LINKER_SCRIPT_H
|
|
|
|
|
2016-09-17 04:21:55 +08:00
|
|
|
#include "Config.h"
|
2016-09-03 05:17:20 +08:00
|
|
|
#include "Strings.h"
|
2016-07-19 17:25:43 +08:00
|
|
|
#include "Writer.h"
|
2016-02-12 05:17:59 +08:00
|
|
|
#include "lld/Core/LLVM.h"
|
2016-11-05 09:00:56 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2016-09-16 23:10:23 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2016-11-05 09:00:56 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-02-12 05:38:55 +08:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2016-11-05 09:00:56 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2016-11-06 06:37:59 +08:00
|
|
|
#include <functional>
|
2016-11-05 09:00:56 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2016-02-12 05:17:59 +08:00
|
|
|
|
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-08-31 21:28:33 +08:00
|
|
|
class DefinedCommon;
|
2016-08-18 21:00:49 +08:00
|
|
|
class ScriptParser;
|
2016-07-29 13:48:39 +08:00
|
|
|
class SymbolBody;
|
2016-07-20 22:43:20 +08:00
|
|
|
template <class ELFT> class InputSectionBase;
|
2016-09-16 23:10:23 +08:00
|
|
|
template <class ELFT> class InputSection;
|
2016-11-10 07:23:45 +08:00
|
|
|
class OutputSectionBase;
|
2016-07-20 22:43:20 +08:00
|
|
|
template <class ELFT> class OutputSectionFactory;
|
2016-09-01 17:55:57 +08:00
|
|
|
class InputSectionData;
|
2016-02-12 05:17:59 +08:00
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// This represents an expression in the linker script.
|
|
|
|
// ScriptParser::readExpr reads an expression and returns an Expr.
|
|
|
|
// Later, we evaluate the expression by calling the function
|
|
|
|
// with the value of special context variable ".".
|
2016-11-01 01:43:38 +08:00
|
|
|
struct Expr {
|
|
|
|
std::function<uint64_t(uint64_t)> Val;
|
2016-11-01 03:56:37 +08:00
|
|
|
std::function<bool()> IsAbsolute;
|
2016-11-16 17:49:39 +08:00
|
|
|
|
|
|
|
// If expression is section-relative the function below is used
|
|
|
|
// to get the output section pointer.
|
|
|
|
std::function<const OutputSectionBase *()> Section;
|
|
|
|
|
2016-11-01 01:43:38 +08:00
|
|
|
uint64_t operator()(uint64_t Dot) const { return Val(Dot); }
|
|
|
|
operator bool() const { return (bool)Val; }
|
|
|
|
|
2016-11-16 17:49:39 +08:00
|
|
|
Expr(std::function<uint64_t(uint64_t)> Val, std::function<bool()> IsAbsolute,
|
|
|
|
std::function<const OutputSectionBase *()> Section)
|
|
|
|
: Val(Val), IsAbsolute(IsAbsolute), Section(Section) {}
|
|
|
|
template <typename T>
|
2016-11-18 14:49:09 +08:00
|
|
|
Expr(T V) : Expr(V, [] { return true; }, [] { return nullptr; }) {}
|
2016-11-01 01:43:38 +08:00
|
|
|
Expr() : Expr(nullptr) {}
|
|
|
|
};
|
Make readExpr return an Expr object instead of a vector of tokens.
Previously, we handled an expression as a vector of tokens. In other
words, an expression was a vector of uncooked raw StringRefs.
When we need a value of an expression, we used ExprParser to run
the expression.
The separation was needed essentially because parse time is too
early to evaluate an expression. In order to evaluate an expression,
we need to finalize section sizes. Because linker script parsing
is done at very early stage of the linking process, we can't
evaluate expressions while parsing.
The above mechanism worked fairly well, but there were a few
drawbacks.
One thing is that we sometimes have to parse the same expression
more than once in order to find the end of the expression.
In some contexts, linker script expressions have no clear end marker.
So, we needed to recognize balanced expressions and ternary operators.
The other is poor error reporting. Since expressions are parsed
basically twice, and some information that is available at the first
stage is lost in the second stage, it was hard to print out
apprpriate error messages.
This patch fixes the issues with a new approach.
Now the expression parsing is integrated into ScriptParser.
ExprParser class is removed. Expressions are represented as lambdas
instead of vectors of tokens. Lambdas captures information they
need to run themselves when they are created.
In this way, ends of expressions are naturally detected, and
errors are handled in the usual way. This patch also reduces
the amount of code.
Differential Revision: https://reviews.llvm.org/D22728
llvm-svn: 276574
2016-07-25 02:19:40 +08:00
|
|
|
|
2016-04-21 04:13:41 +08:00
|
|
|
// Parses a linker script. Calling this function updates
|
|
|
|
// Config and ScriptConfig.
|
|
|
|
void readLinkerScript(MemoryBufferRef MB);
|
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// Parses a version script.
|
2016-08-31 17:08:26 +08:00
|
|
|
void readVersionScript(MemoryBufferRef MB);
|
|
|
|
|
2016-12-09 01:54:26 +08:00
|
|
|
void readDynamicList(MemoryBufferRef MB);
|
|
|
|
|
2016-07-21 22:26:59 +08:00
|
|
|
// This enum is used to implement linker script SECTIONS command.
|
|
|
|
// https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS
|
|
|
|
enum SectionsCommandKind {
|
2016-09-27 03:22:50 +08:00
|
|
|
AssignmentKind, // . = expr or <sym> = expr
|
2016-07-21 22:26:59 +08:00
|
|
|
OutputSectionKind,
|
2016-08-04 17:29:31 +08:00
|
|
|
InputSectionKind,
|
2016-09-27 03:22:50 +08:00
|
|
|
AssertKind, // ASSERT(expr)
|
|
|
|
BytesDataKind // BYTE(expr), SHORT(expr), LONG(expr) or QUAD(expr)
|
2016-02-13 05:47:28 +08:00
|
|
|
};
|
|
|
|
|
2016-07-21 14:43:01 +08:00
|
|
|
struct BaseCommand {
|
|
|
|
BaseCommand(int K) : Kind(K) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
|
|
|
virtual ~BaseCommand() = default;
|
|
|
|
|
2016-07-21 14:43:01 +08:00
|
|
|
int Kind;
|
|
|
|
};
|
2016-04-16 18:10:32 +08:00
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// This represents ". = <expr>" or "<symbol> = <expr>".
|
2016-07-21 14:43:01 +08:00
|
|
|
struct SymbolAssignment : BaseCommand {
|
2016-11-01 01:43:38 +08:00
|
|
|
SymbolAssignment(StringRef Name, Expr E)
|
|
|
|
: BaseCommand(AssignmentKind), Name(Name), Expression(E) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-07-21 14:43:01 +08:00
|
|
|
static bool classof(const BaseCommand *C);
|
2016-07-29 13:52:33 +08:00
|
|
|
|
|
|
|
// The LHS of an expression. Name is either a symbol name or ".".
|
2016-07-21 14:43:01 +08:00
|
|
|
StringRef Name;
|
2016-07-29 13:52:33 +08:00
|
|
|
SymbolBody *Sym = nullptr;
|
|
|
|
|
|
|
|
// The RHS of an expression.
|
Make readExpr return an Expr object instead of a vector of tokens.
Previously, we handled an expression as a vector of tokens. In other
words, an expression was a vector of uncooked raw StringRefs.
When we need a value of an expression, we used ExprParser to run
the expression.
The separation was needed essentially because parse time is too
early to evaluate an expression. In order to evaluate an expression,
we need to finalize section sizes. Because linker script parsing
is done at very early stage of the linking process, we can't
evaluate expressions while parsing.
The above mechanism worked fairly well, but there were a few
drawbacks.
One thing is that we sometimes have to parse the same expression
more than once in order to find the end of the expression.
In some contexts, linker script expressions have no clear end marker.
So, we needed to recognize balanced expressions and ternary operators.
The other is poor error reporting. Since expressions are parsed
basically twice, and some information that is available at the first
stage is lost in the second stage, it was hard to print out
apprpriate error messages.
This patch fixes the issues with a new approach.
Now the expression parsing is integrated into ScriptParser.
ExprParser class is removed. Expressions are represented as lambdas
instead of vectors of tokens. Lambdas captures information they
need to run themselves when they are created.
In this way, ends of expressions are naturally detected, and
errors are handled in the usual way. This patch also reduces
the amount of code.
Differential Revision: https://reviews.llvm.org/D22728
llvm-svn: 276574
2016-07-25 02:19:40 +08:00
|
|
|
Expr Expression;
|
2016-07-29 13:52:33 +08:00
|
|
|
|
|
|
|
// Command attributes for PROVIDE, HIDDEN and PROVIDE_HIDDEN.
|
2016-07-22 15:38:40 +08:00
|
|
|
bool Provide = false;
|
|
|
|
bool Hidden = false;
|
2016-07-21 14:43:01 +08:00
|
|
|
};
|
|
|
|
|
2016-07-22 11:36:24 +08:00
|
|
|
// Linker scripts allow additional constraints to be put on ouput sections.
|
2016-10-14 07:08:33 +08:00
|
|
|
// If an output section is marked as ONLY_IF_RO, the section is created
|
|
|
|
// only if its input sections are read-only. Likewise, an output section
|
|
|
|
// with ONLY_IF_RW is created if all input sections are RW.
|
2016-07-26 06:00:10 +08:00
|
|
|
enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite };
|
2016-07-22 11:36:24 +08:00
|
|
|
|
2016-07-21 14:43:01 +08:00
|
|
|
struct OutputSectionCommand : BaseCommand {
|
|
|
|
OutputSectionCommand(StringRef Name)
|
|
|
|
: BaseCommand(OutputSectionKind), Name(Name) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-07-21 14:43:01 +08:00
|
|
|
static bool classof(const BaseCommand *C);
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-07-12 14:39:48 +08:00
|
|
|
StringRef Name;
|
2016-07-25 16:29:46 +08:00
|
|
|
Expr AddrExpr;
|
2016-07-27 02:06:29 +08:00
|
|
|
Expr AlignExpr;
|
2016-10-06 17:39:28 +08:00
|
|
|
Expr LMAExpr;
|
2016-08-19 23:18:23 +08:00
|
|
|
Expr SubalignExpr;
|
2016-07-21 22:26:59 +08:00
|
|
|
std::vector<std::unique_ptr<BaseCommand>> Commands;
|
2016-07-19 17:25:43 +08:00
|
|
|
std::vector<StringRef> Phdrs;
|
2016-11-20 02:05:56 +08:00
|
|
|
uint32_t Filler = 0;
|
2016-07-26 06:00:10 +08:00
|
|
|
ConstraintKind Constraint = ConstraintKind::NoConstraint;
|
2016-12-06 00:38:32 +08:00
|
|
|
std::string Location;
|
2016-07-19 17:25:43 +08:00
|
|
|
};
|
|
|
|
|
2016-09-17 15:31:49 +08:00
|
|
|
// This struct represents one section match pattern in SECTIONS() command.
|
2016-09-17 10:23:40 +08:00
|
|
|
// It can optionally have negative match pattern for EXCLUDED_FILE command.
|
2016-09-21 23:56:44 +08:00
|
|
|
// Also it may be surrounded with SORT() command, so contains sorting rules.
|
2016-09-17 10:23:40 +08:00
|
|
|
struct SectionPattern {
|
2016-11-04 01:57:38 +08:00
|
|
|
SectionPattern(StringMatcher &&Pat1, StringMatcher &&Pat2)
|
|
|
|
: ExcludedFilePat(Pat1), SectionPat(Pat2) {}
|
|
|
|
|
|
|
|
StringMatcher ExcludedFilePat;
|
|
|
|
StringMatcher SectionPat;
|
2016-09-21 23:56:44 +08:00
|
|
|
SortSectionPolicy SortOuter;
|
|
|
|
SortSectionPolicy SortInner;
|
2016-09-17 10:23:40 +08:00
|
|
|
};
|
|
|
|
|
2016-07-21 22:26:59 +08:00
|
|
|
struct InputSectionDescription : BaseCommand {
|
2016-09-03 05:17:20 +08:00
|
|
|
InputSectionDescription(StringRef FilePattern)
|
2016-12-21 10:27:14 +08:00
|
|
|
: BaseCommand(InputSectionKind), FilePat(FilePattern) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-07-21 22:26:59 +08:00
|
|
|
static bool classof(const BaseCommand *C);
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-11-04 01:57:38 +08:00
|
|
|
StringMatcher FilePat;
|
2016-09-17 10:23:40 +08:00
|
|
|
|
2016-09-17 15:31:49 +08:00
|
|
|
// Input sections that matches at least one of SectionPatterns
|
2016-09-17 10:34:50 +08:00
|
|
|
// will be associated with this InputSectionDescription.
|
2016-09-20 08:02:06 +08:00
|
|
|
std::vector<SectionPattern> SectionPatterns;
|
2016-09-17 10:23:40 +08:00
|
|
|
|
2016-09-16 23:10:23 +08:00
|
|
|
std::vector<InputSectionData *> Sections;
|
2016-07-21 22:26:59 +08:00
|
|
|
};
|
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// Represents an ASSERT().
|
2016-08-04 17:29:31 +08:00
|
|
|
struct AssertCommand : BaseCommand {
|
|
|
|
AssertCommand(Expr E) : BaseCommand(AssertKind), Expression(E) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-08-04 17:29:31 +08:00
|
|
|
static bool classof(const BaseCommand *C);
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-08-04 17:29:31 +08:00
|
|
|
Expr Expression;
|
|
|
|
};
|
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// Represents BYTE(), SHORT(), LONG(), or QUAD().
|
2016-09-27 03:22:50 +08:00
|
|
|
struct BytesDataCommand : BaseCommand {
|
2016-12-09 07:21:30 +08:00
|
|
|
BytesDataCommand(Expr E, unsigned Size)
|
|
|
|
: BaseCommand(BytesDataKind), Expression(E), Size(Size) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-09-27 03:22:50 +08:00
|
|
|
static bool classof(const BaseCommand *C);
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-12-09 07:21:30 +08:00
|
|
|
Expr Expression;
|
2016-09-27 03:22:50 +08:00
|
|
|
unsigned Offset;
|
|
|
|
unsigned Size;
|
|
|
|
};
|
|
|
|
|
2016-07-19 17:25:43 +08:00
|
|
|
struct PhdrsCommand {
|
|
|
|
StringRef Name;
|
|
|
|
unsigned Type;
|
|
|
|
bool HasFilehdr;
|
|
|
|
bool HasPhdrs;
|
2016-07-21 18:43:25 +08:00
|
|
|
unsigned Flags;
|
2016-09-09 17:46:16 +08:00
|
|
|
Expr LMAExpr;
|
2016-04-16 18:10:32 +08:00
|
|
|
};
|
|
|
|
|
2016-09-08 16:19:13 +08:00
|
|
|
class LinkerScriptBase {
|
2016-09-08 22:11:08 +08:00
|
|
|
protected:
|
|
|
|
~LinkerScriptBase() = default;
|
|
|
|
|
2016-09-08 16:19:13 +08:00
|
|
|
public:
|
|
|
|
virtual uint64_t getHeaderSize() = 0;
|
2016-12-22 21:13:12 +08:00
|
|
|
virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0;
|
2016-09-23 21:17:23 +08:00
|
|
|
virtual bool isDefined(StringRef S) = 0;
|
2016-11-01 03:56:37 +08:00
|
|
|
virtual bool isAbsolute(StringRef S) = 0;
|
2016-11-16 17:49:39 +08:00
|
|
|
virtual const OutputSectionBase *getSymbolSection(StringRef S) = 0;
|
2016-11-28 17:58:04 +08:00
|
|
|
virtual const OutputSectionBase *getOutputSection(const Twine &Loc,
|
|
|
|
StringRef S) = 0;
|
2016-11-18 04:27:10 +08:00
|
|
|
virtual uint64_t getOutputSectionSize(StringRef S) = 0;
|
2016-09-08 16:19:13 +08:00
|
|
|
};
|
|
|
|
|
2016-04-21 04:13:41 +08:00
|
|
|
// ScriptConfiguration holds linker script parse results.
|
|
|
|
struct ScriptConfiguration {
|
2016-04-16 18:10:32 +08:00
|
|
|
// Used to assign addresses to sections.
|
2016-07-21 14:43:01 +08:00
|
|
|
std::vector<std::unique_ptr<BaseCommand>> Commands;
|
2016-04-16 18:10:32 +08:00
|
|
|
|
2016-07-19 17:25:43 +08:00
|
|
|
// Used to assign sections to headers.
|
2016-07-20 23:09:10 +08:00
|
|
|
std::vector<PhdrsCommand> PhdrsCommands;
|
|
|
|
|
2016-09-14 16:32:36 +08:00
|
|
|
bool HasSections = false;
|
2016-04-21 04:13:41 +08:00
|
|
|
|
2016-04-22 06:00:51 +08:00
|
|
|
// List of section patterns specified with KEEP commands. They will
|
|
|
|
// be kept even if they are unused and --gc-sections is specified.
|
2016-10-05 17:36:59 +08:00
|
|
|
std::vector<InputSectionDescription *> KeptSections;
|
2016-02-12 05:17:59 +08:00
|
|
|
};
|
|
|
|
|
2016-04-21 04:13:41 +08:00
|
|
|
extern ScriptConfiguration *ScriptConfig;
|
|
|
|
|
|
|
|
// This is a runner of the linker script.
|
2016-09-08 16:19:13 +08:00
|
|
|
template <class ELFT> class LinkerScript final : public LinkerScriptBase {
|
2016-04-23 04:41:07 +08:00
|
|
|
typedef typename ELFT::uint uintX_t;
|
|
|
|
|
2016-04-21 04:13:41 +08:00
|
|
|
public:
|
2016-08-12 09:24:53 +08:00
|
|
|
LinkerScript();
|
|
|
|
~LinkerScript();
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2016-09-16 23:30:47 +08:00
|
|
|
void processCommands(OutputSectionFactory<ELFT> &Factory);
|
2016-11-21 10:11:05 +08:00
|
|
|
void addOrphanSections(OutputSectionFactory<ELFT> &Factory);
|
2016-11-14 22:23:35 +08:00
|
|
|
void removeEmptyCommands();
|
2016-09-22 22:40:50 +08:00
|
|
|
void adjustSectionsBeforeSorting();
|
2016-11-14 23:39:38 +08:00
|
|
|
void adjustSectionsAfterSorting();
|
2016-07-21 01:19:03 +08:00
|
|
|
|
2016-12-20 01:01:01 +08:00
|
|
|
std::vector<PhdrEntry> createPhdrs();
|
2016-08-16 14:40:58 +08:00
|
|
|
bool ignoreInterpSection();
|
2016-07-23 22:18:48 +08:00
|
|
|
|
2016-11-20 02:05:56 +08:00
|
|
|
uint32_t getFiller(StringRef Name);
|
2016-09-27 03:22:50 +08:00
|
|
|
void writeDataBytes(StringRef Name, uint8_t *Buf);
|
2016-10-06 17:39:28 +08:00
|
|
|
bool hasLMA(StringRef Name);
|
2016-04-21 04:13:41 +08:00
|
|
|
bool shouldKeep(InputSectionBase<ELFT> *S);
|
2016-09-16 23:10:23 +08:00
|
|
|
void assignOffsets(OutputSectionCommand *Cmd);
|
2016-11-14 22:13:32 +08:00
|
|
|
void placeOrphanSections();
|
2016-12-20 01:01:01 +08:00
|
|
|
void assignAddresses(std::vector<PhdrEntry> &Phdrs);
|
2016-07-19 17:25:43 +08:00
|
|
|
bool hasPhdrsCommands();
|
2016-09-08 16:19:13 +08:00
|
|
|
uint64_t getHeaderSize() override;
|
2016-12-22 21:13:12 +08:00
|
|
|
uint64_t getSymbolValue(const Twine &Loc, StringRef S) override;
|
2016-09-23 21:17:23 +08:00
|
|
|
bool isDefined(StringRef S) override;
|
2016-11-01 03:56:37 +08:00
|
|
|
bool isAbsolute(StringRef S) override;
|
2016-11-16 17:49:39 +08:00
|
|
|
const OutputSectionBase *getSymbolSection(StringRef S) override;
|
2016-11-28 17:58:04 +08:00
|
|
|
const OutputSectionBase *getOutputSection(const Twine &Loc,
|
|
|
|
StringRef S) override;
|
2016-11-18 04:27:10 +08:00
|
|
|
uint64_t getOutputSectionSize(StringRef S) override;
|
2016-04-21 04:13:41 +08:00
|
|
|
|
2016-11-10 07:23:45 +08:00
|
|
|
std::vector<OutputSectionBase *> *OutputSections;
|
2016-08-04 20:13:05 +08:00
|
|
|
|
2016-09-21 06:43:15 +08:00
|
|
|
int getSectionIndex(StringRef Name);
|
|
|
|
|
2016-04-21 04:13:41 +08:00
|
|
|
private:
|
2016-09-17 04:34:02 +08:00
|
|
|
void computeInputSections(InputSectionDescription *);
|
2016-07-26 06:51:07 +08:00
|
|
|
|
2016-09-16 23:30:47 +08:00
|
|
|
void addSection(OutputSectionFactory<ELFT> &Factory,
|
|
|
|
InputSectionBase<ELFT> *Sec, StringRef Name);
|
2016-09-13 00:05:16 +08:00
|
|
|
void discard(ArrayRef<InputSectionBase<ELFT> *> V);
|
2016-08-12 08:27:23 +08:00
|
|
|
|
2016-08-12 11:16:56 +08:00
|
|
|
std::vector<InputSectionBase<ELFT> *>
|
|
|
|
createInputSectionList(OutputSectionCommand &Cmd);
|
|
|
|
|
2016-04-22 08:03:13 +08:00
|
|
|
// "ScriptConfig" is a bit too long, so define a short name for it.
|
|
|
|
ScriptConfiguration &Opt = *ScriptConfig;
|
|
|
|
|
2016-07-25 07:47:31 +08:00
|
|
|
std::vector<size_t> getPhdrIndices(StringRef SectionName);
|
2016-12-06 00:38:32 +08:00
|
|
|
size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);
|
2016-04-21 04:13:41 +08:00
|
|
|
|
2016-04-23 04:41:07 +08:00
|
|
|
uintX_t Dot;
|
2016-10-06 17:39:28 +08:00
|
|
|
uintX_t LMAOffset = 0;
|
2016-11-10 07:23:45 +08:00
|
|
|
OutputSectionBase *CurOutSec = nullptr;
|
2016-09-16 23:10:23 +08:00
|
|
|
uintX_t ThreadBssOffset = 0;
|
2016-11-10 07:23:45 +08:00
|
|
|
void switchTo(OutputSectionBase *Sec);
|
2016-09-16 23:10:23 +08:00
|
|
|
void flush();
|
|
|
|
void output(InputSection<ELFT> *Sec);
|
|
|
|
void process(BaseCommand &Base);
|
2016-11-10 07:23:45 +08:00
|
|
|
llvm::DenseSet<OutputSectionBase *> AlreadyOutputOS;
|
2016-09-16 23:10:23 +08:00
|
|
|
llvm::DenseSet<InputSectionData *> AlreadyOutputIS;
|
2016-04-21 04:13:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Variable template is a C++14 feature, so we can't template
|
|
|
|
// a global variable. Use a struct to workaround.
|
|
|
|
template <class ELFT> struct Script { static LinkerScript<ELFT> *X; };
|
|
|
|
template <class ELFT> LinkerScript<ELFT> *Script<ELFT>::X;
|
2016-02-12 05:17:59 +08:00
|
|
|
|
2016-09-08 16:19:13 +08:00
|
|
|
extern LinkerScriptBase *ScriptBase;
|
|
|
|
|
2016-11-05 09:00:56 +08:00
|
|
|
} // end namespace elf
|
|
|
|
} // end namespace lld
|
2016-02-12 05:17:59 +08:00
|
|
|
|
2016-11-05 09:00:56 +08:00
|
|
|
#endif // LLD_ELF_LINKER_SCRIPT_H
|