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-07-19 17:25:43 +08:00
|
|
|
#include "Writer.h"
|
2017-10-03 05:00:41 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
2018-03-01 01:38:19 +08:00
|
|
|
#include "lld/Common/Strings.h"
|
2016-11-05 09:00:56 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2017-01-24 10:34:00 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2016-09-16 23:10:23 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2017-11-03 19:57:01 +08:00
|
|
|
#include "llvm/ADT/MapVector.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
|
|
|
|
2017-11-06 12:35:31 +08:00
|
|
|
class Defined;
|
2017-11-04 05:21:47 +08:00
|
|
|
class Symbol;
|
2017-02-23 10:28:28 +08:00
|
|
|
class InputSectionBase;
|
2017-02-24 00:49:07 +08:00
|
|
|
class InputSection;
|
2017-02-24 23:07:30 +08:00
|
|
|
class OutputSection;
|
2017-02-23 10:32:18 +08:00
|
|
|
class InputSectionBase;
|
2017-03-10 08:47:33 +08:00
|
|
|
class SectionBase;
|
2016-02-12 05:17:59 +08:00
|
|
|
|
2017-10-11 08:01:49 +08:00
|
|
|
// This represents an r-value in the linker script.
|
2017-03-17 21:05:04 +08:00
|
|
|
struct ExprValue {
|
2017-05-30 11:18:28 +08:00
|
|
|
ExprValue(SectionBase *Sec, bool ForceAbsolute, uint64_t Val,
|
2017-06-07 16:54:43 +08:00
|
|
|
const Twine &Loc)
|
2017-10-11 08:01:49 +08:00
|
|
|
: Sec(Sec), ForceAbsolute(ForceAbsolute), Val(Val), Loc(Loc.str()) {}
|
|
|
|
|
|
|
|
ExprValue(uint64_t Val) : ExprValue(nullptr, false, Val, "") {}
|
|
|
|
|
2017-03-17 21:05:04 +08:00
|
|
|
bool isAbsolute() const { return ForceAbsolute || Sec == nullptr; }
|
|
|
|
uint64_t getValue() const;
|
2017-03-17 22:55:36 +08:00
|
|
|
uint64_t getSecAddr() const;
|
2017-09-12 08:06:00 +08:00
|
|
|
uint64_t getSectionOffset() const;
|
2017-10-11 08:01:49 +08:00
|
|
|
|
|
|
|
// If a value is relative to a section, it has a non-null Sec.
|
|
|
|
SectionBase *Sec;
|
|
|
|
|
|
|
|
// True if this expression is enclosed in ABSOLUTE().
|
|
|
|
// This flag affects the return value of getValue().
|
|
|
|
bool ForceAbsolute;
|
|
|
|
|
|
|
|
uint64_t Val;
|
|
|
|
uint64_t Alignment = 1;
|
|
|
|
|
|
|
|
// Original source location. Used for error messages.
|
|
|
|
std::string Loc;
|
2017-03-17 21:05:04 +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.
|
2017-03-17 21:05:04 +08:00
|
|
|
// Later, we evaluate the expression by calling the function.
|
|
|
|
typedef std::function<ExprValue()> Expr;
|
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-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,
|
2017-10-11 12:22:09 +08:00
|
|
|
ByteKind // 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) {}
|
|
|
|
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 {
|
2018-04-05 19:25:58 +08:00
|
|
|
SymbolAssignment(StringRef Name, Expr E, std::string Loc)
|
|
|
|
: BaseCommand(AssignmentKind), Name(Name), Expression(E), Location(Loc) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2017-10-11 10:20:00 +08:00
|
|
|
static bool classof(const BaseCommand *C) {
|
|
|
|
return C->Kind == AssignmentKind;
|
|
|
|
}
|
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;
|
2017-11-06 12:35:31 +08:00
|
|
|
Defined *Sym = nullptr;
|
2016-07-29 13:52:33 +08:00
|
|
|
|
|
|
|
// 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;
|
2017-02-21 22:50:38 +08:00
|
|
|
|
2017-02-22 17:13:04 +08:00
|
|
|
// Holds file name and line number for error reporting.
|
2017-02-21 22:50:38 +08:00
|
|
|
std::string Location;
|
2018-03-15 17:16:40 +08:00
|
|
|
|
|
|
|
// A string representation of this command. We use this for -Map.
|
|
|
|
std::string CommandString;
|
|
|
|
|
2018-04-04 17:39:05 +08:00
|
|
|
// Address of this assignment command.
|
|
|
|
unsigned Addr;
|
2018-03-15 17:16:40 +08:00
|
|
|
|
2018-04-04 17:39:05 +08:00
|
|
|
// Size of this assignment command. This is usually 0, but if
|
|
|
|
// you move '.' this may be greater than 0.
|
2018-03-15 17:16:40 +08:00
|
|
|
unsigned Size;
|
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
|
|
|
|
2017-04-07 05:31:24 +08:00
|
|
|
// This struct is used to represent the location and size of regions of
|
|
|
|
// target memory. Instances of the struct are created by parsing the
|
|
|
|
// MEMORY command.
|
|
|
|
struct MemoryRegion {
|
2018-01-25 10:18:00 +08:00
|
|
|
MemoryRegion(StringRef Name, uint64_t Origin, uint64_t Length, uint32_t Flags,
|
|
|
|
uint32_t NegFlags)
|
|
|
|
: Name(Name), Origin(Origin), Length(Length), Flags(Flags),
|
|
|
|
NegFlags(NegFlags) {}
|
|
|
|
|
2017-04-07 05:31:24 +08:00
|
|
|
std::string Name;
|
|
|
|
uint64_t Origin;
|
|
|
|
uint64_t Length;
|
|
|
|
uint32_t Flags;
|
|
|
|
uint32_t NegFlags;
|
2018-01-25 10:18:00 +08:00
|
|
|
uint64_t CurPos = 0;
|
2017-04-07 05:31:24 +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
|
|
|
};
|
|
|
|
|
2017-10-27 16:56:20 +08:00
|
|
|
class ThunkSection;
|
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
|
|
|
|
2017-10-11 10:20:00 +08:00
|
|
|
static bool classof(const BaseCommand *C) {
|
|
|
|
return C->Kind == InputSectionKind;
|
|
|
|
}
|
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
|
|
|
|
2017-05-24 06:47:31 +08:00
|
|
|
std::vector<InputSection *> Sections;
|
2017-10-27 16:56:20 +08:00
|
|
|
|
2017-10-27 17:07:10 +08:00
|
|
|
// Temporary record of synthetic ThunkSection instances and the pass that
|
|
|
|
// they were created in. This is used to insert newly created ThunkSections
|
|
|
|
// into Sections at the end of a createThunks() pass.
|
|
|
|
std::vector<std::pair<ThunkSection *, uint32_t>> ThunkSections;
|
2016-07-21 22:26:59 +08:00
|
|
|
};
|
|
|
|
|
2016-10-14 07:08:33 +08:00
|
|
|
// Represents BYTE(), SHORT(), LONG(), or QUAD().
|
2017-10-11 12:22:09 +08:00
|
|
|
struct ByteCommand : BaseCommand {
|
2018-03-15 17:16:40 +08:00
|
|
|
ByteCommand(Expr E, unsigned Size, std::string CommandString)
|
2018-03-15 17:40:25 +08:00
|
|
|
: BaseCommand(ByteKind), CommandString(CommandString), Expression(E),
|
2018-03-15 17:24:51 +08:00
|
|
|
Size(Size) {}
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2017-10-11 12:22:09 +08:00
|
|
|
static bool classof(const BaseCommand *C) { return C->Kind == ByteKind; }
|
2016-11-05 09:00:56 +08:00
|
|
|
|
2018-03-15 17:16:40 +08:00
|
|
|
// Keeps string representing the command. Used for -Map" is perhaps better.
|
|
|
|
std::string CommandString;
|
|
|
|
|
2016-12-09 07:21:30 +08:00
|
|
|
Expr Expression;
|
2018-04-04 17:39:05 +08:00
|
|
|
|
|
|
|
// This is just an offset of this assignment command in the output section.
|
2016-09-27 03:22:50 +08:00
|
|
|
unsigned Offset;
|
2018-04-04 17:39:05 +08:00
|
|
|
|
|
|
|
// Size of this data command.
|
2016-09-27 03:22:50 +08:00
|
|
|
unsigned Size;
|
|
|
|
};
|
|
|
|
|
2016-07-19 17:25:43 +08:00
|
|
|
struct PhdrsCommand {
|
|
|
|
StringRef Name;
|
2017-10-08 11:45:49 +08:00
|
|
|
unsigned Type = llvm::ELF::PT_NULL;
|
|
|
|
bool HasFilehdr = false;
|
|
|
|
bool HasPhdrs = false;
|
|
|
|
llvm::Optional<unsigned> Flags;
|
|
|
|
Expr LMAExpr = nullptr;
|
2016-04-16 18:10:32 +08:00
|
|
|
};
|
|
|
|
|
2017-05-10 22:45:15 +08:00
|
|
|
class LinkerScript final {
|
2017-10-11 10:28:28 +08:00
|
|
|
// Temporary state used in processSectionCommands() and assignAddresses()
|
2017-07-07 17:11:27 +08:00
|
|
|
// that must be reinitialized for each call to the above functions, and must
|
|
|
|
// not be used outside of the scope of a call to the above functions.
|
|
|
|
struct AddressState {
|
2017-10-11 09:19:33 +08:00
|
|
|
AddressState();
|
2017-07-07 17:11:27 +08:00
|
|
|
uint64_t ThreadBssOffset = 0;
|
|
|
|
OutputSection *OutSec = nullptr;
|
|
|
|
MemoryRegion *MemRegion = nullptr;
|
2018-01-26 01:42:03 +08:00
|
|
|
MemoryRegion *LMARegion = nullptr;
|
2018-01-26 00:43:49 +08:00
|
|
|
uint64_t LMAOffset = 0;
|
2017-07-07 17:11:27 +08:00
|
|
|
};
|
2017-10-11 09:19:33 +08:00
|
|
|
|
2017-07-28 03:22:43 +08:00
|
|
|
llvm::DenseMap<StringRef, OutputSection *> NameToOutputSection;
|
2017-06-01 09:16:50 +08:00
|
|
|
|
2017-10-11 10:28:39 +08:00
|
|
|
void addSymbol(SymbolAssignment *Cmd);
|
2017-04-05 11:20:22 +08:00
|
|
|
void assignSymbol(SymbolAssignment *Cmd, bool InSec);
|
|
|
|
void setDot(Expr E, const Twine &Loc, bool InSec);
|
2018-03-05 18:54:03 +08:00
|
|
|
void expandOutputSection(uint64_t Size);
|
2018-03-26 16:58:16 +08:00
|
|
|
void expandMemoryRegions(uint64_t Size);
|
2017-03-14 20:03:34 +08:00
|
|
|
|
2017-05-24 06:47:31 +08:00
|
|
|
std::vector<InputSection *>
|
2018-01-31 00:20:08 +08:00
|
|
|
computeInputSections(const InputSectionDescription *);
|
2017-04-05 10:05:48 +08:00
|
|
|
|
2018-01-31 00:20:08 +08:00
|
|
|
std::vector<InputSection *> createInputSectionList(OutputSection &Cmd);
|
2017-03-14 20:03:34 +08:00
|
|
|
|
2017-07-28 03:22:43 +08:00
|
|
|
std::vector<size_t> getPhdrIndices(OutputSection *Sec);
|
2017-03-14 20:03:34 +08:00
|
|
|
|
2017-07-28 03:22:43 +08:00
|
|
|
MemoryRegion *findMemoryRegion(OutputSection *Sec);
|
2017-03-14 20:03:34 +08:00
|
|
|
|
|
|
|
void switchTo(OutputSection *Sec);
|
2017-05-04 11:00:27 +08:00
|
|
|
uint64_t advance(uint64_t Size, unsigned Align);
|
2017-03-14 20:03:34 +08:00
|
|
|
void output(InputSection *Sec);
|
|
|
|
|
2017-10-18 20:09:41 +08:00
|
|
|
void assignOffsets(OutputSection *Sec);
|
|
|
|
|
2017-10-24 05:12:19 +08:00
|
|
|
// Ctx captures the local AddressState and makes it accessible
|
|
|
|
// deliberately. This is needed as there are some cases where we cannot just
|
|
|
|
// thread the current state through to a lambda function created by the
|
|
|
|
// script parser.
|
|
|
|
// This should remain a plain pointer as its lifetime is smaller than
|
|
|
|
// LinkerScript.
|
|
|
|
AddressState *Ctx = nullptr;
|
|
|
|
|
2017-03-14 17:03:53 +08:00
|
|
|
OutputSection *Aether;
|
|
|
|
|
2017-03-17 05:50:30 +08:00
|
|
|
uint64_t Dot;
|
2017-03-14 20:03:34 +08:00
|
|
|
|
2017-03-14 17:03:53 +08:00
|
|
|
public:
|
2017-07-28 03:22:43 +08:00
|
|
|
OutputSection *createOutputSection(StringRef Name, StringRef Location);
|
|
|
|
OutputSection *getOrCreateOutputSection(StringRef Name);
|
2017-06-01 09:16:50 +08:00
|
|
|
|
2017-10-11 09:19:33 +08:00
|
|
|
bool hasPhdrsCommands() { return !PhdrsCommands.empty(); }
|
2017-03-17 05:50:30 +08:00
|
|
|
uint64_t getDot() { return Dot; }
|
2017-10-11 12:01:13 +08:00
|
|
|
void discard(ArrayRef<InputSection *> V);
|
2017-03-14 17:03:53 +08:00
|
|
|
|
2017-10-11 12:34:34 +08:00
|
|
|
ExprValue getSymbolValue(StringRef Name, const Twine &Loc);
|
2017-03-14 18:15:53 +08:00
|
|
|
|
2017-11-05 07:54:25 +08:00
|
|
|
void addOrphanSections();
|
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
|
|
|
|
2017-07-27 15:46:50 +08:00
|
|
|
std::vector<PhdrEntry *> createPhdrs();
|
2017-10-08 11:52:15 +08:00
|
|
|
bool needsInterpSection();
|
2016-07-23 22:18:48 +08:00
|
|
|
|
2017-02-23 10:28:28 +08:00
|
|
|
bool shouldKeep(InputSectionBase *S);
|
2018-01-31 01:24:28 +08:00
|
|
|
void assignAddresses();
|
|
|
|
void allocateHeaders(std::vector<PhdrEntry *> &Phdrs);
|
|
|
|
void processSectionCommands();
|
|
|
|
void declareSymbols();
|
|
|
|
|
2018-03-08 22:54:38 +08:00
|
|
|
// Used to handle INSERT AFTER statements.
|
|
|
|
void processInsertCommands();
|
|
|
|
|
2018-01-31 01:24:28 +08:00
|
|
|
// SECTIONS command list.
|
|
|
|
std::vector<BaseCommand *> SectionCommands;
|
2017-10-11 09:19:33 +08:00
|
|
|
|
|
|
|
// PHDRS command list.
|
|
|
|
std::vector<PhdrsCommand> PhdrsCommands;
|
|
|
|
|
2017-10-11 09:34:51 +08:00
|
|
|
bool HasSectionsCommand = false;
|
2017-10-11 10:28:39 +08:00
|
|
|
bool ErrorOnMissingSection = false;
|
2017-10-11 09:19:33 +08:00
|
|
|
|
|
|
|
// List of section patterns specified with KEEP commands. They will
|
|
|
|
// be kept even if they are unused and --gc-sections is specified.
|
|
|
|
std::vector<InputSectionDescription *> KeptSections;
|
|
|
|
|
|
|
|
// A map from memory region name to a memory region descriptor.
|
2017-11-03 16:21:51 +08:00
|
|
|
llvm::MapVector<llvm::StringRef, MemoryRegion *> MemoryRegions;
|
2017-10-11 09:19:33 +08:00
|
|
|
|
|
|
|
// A list of symbols referenced by the script.
|
|
|
|
std::vector<llvm::StringRef> ReferencedSymbols;
|
2018-03-08 22:54:38 +08:00
|
|
|
|
2018-03-13 17:18:11 +08:00
|
|
|
// Used to implement INSERT [AFTER|BEFORE]. Contains commands that need
|
2018-03-08 22:54:38 +08:00
|
|
|
// to be inserted into SECTIONS commands list.
|
|
|
|
llvm::DenseMap<StringRef, std::vector<BaseCommand *>> InsertAfterCommands;
|
2018-03-13 17:18:11 +08:00
|
|
|
llvm::DenseMap<StringRef, std::vector<BaseCommand *>> InsertBeforeCommands;
|
2016-04-21 04:13:41 +08:00
|
|
|
};
|
|
|
|
|
2017-03-22 07:02:51 +08:00
|
|
|
extern LinkerScript *Script;
|
2016-09-08 16:19:13 +08:00
|
|
|
|
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
|