2015-10-01 01:23:26 +08:00
|
|
|
//===- LinkerScript.cpp ---------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the parser/evaluator of the linker script.
|
|
|
|
// It does not construct an AST but consume linker script directives directly.
|
2015-10-14 03:51:57 +08:00
|
|
|
// Results are written to Driver or Config object.
|
2015-10-01 01:23:26 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
#include "LinkerScript.h"
|
2015-10-01 01:23:26 +08:00
|
|
|
#include "Config.h"
|
|
|
|
#include "Driver.h"
|
2016-02-13 05:47:28 +08:00
|
|
|
#include "InputSection.h"
|
2015-10-01 01:23:26 +08:00
|
|
|
#include "SymbolTable.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2015-10-13 08:09:21 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2015-10-11 09:53:04 +08:00
|
|
|
#include "llvm/Support/StringSaver.h"
|
2015-10-01 01:23:26 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
2016-02-13 05:47:28 +08:00
|
|
|
using namespace llvm::object;
|
2015-10-01 01:23:26 +08:00
|
|
|
using namespace lld;
|
|
|
|
using namespace lld::elf2;
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
LinkerScript *elf2::Script;
|
|
|
|
|
2016-02-13 05:47:28 +08:00
|
|
|
template <class ELFT>
|
|
|
|
StringRef LinkerScript::getOutputSection(InputSectionBase<ELFT> *S) {
|
|
|
|
for (SectionRule &R : Sections)
|
|
|
|
if (R.match(S))
|
|
|
|
return R.Dest;
|
|
|
|
return "";
|
2016-02-12 05:17:59 +08:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:47:28 +08:00
|
|
|
template <class ELFT>
|
|
|
|
bool LinkerScript::isDiscarded(InputSectionBase<ELFT> *S) {
|
|
|
|
return getOutputSection(S) == "/DISCARD/";
|
2016-02-12 05:17:59 +08:00
|
|
|
}
|
|
|
|
|
2016-02-13 04:41:43 +08:00
|
|
|
// A compartor to sort output sections. Returns -1 or 1 if both
|
|
|
|
// A and B are mentioned in linker scripts. Otherwise, returns 0
|
|
|
|
// to use the default rule which is implemented in Writer.cpp.
|
2016-02-12 05:17:59 +08:00
|
|
|
int LinkerScript::compareSections(StringRef A, StringRef B) {
|
2016-02-13 04:41:43 +08:00
|
|
|
auto E = SectionOrder.end();
|
|
|
|
auto I = std::find(SectionOrder.begin(), E, A);
|
|
|
|
auto J = std::find(SectionOrder.begin(), E, B);
|
|
|
|
if (I == E || J == E)
|
2016-02-12 05:17:59 +08:00
|
|
|
return 0;
|
|
|
|
return I < J ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
2016-02-13 05:47:28 +08:00
|
|
|
// Returns true if S matches T. S may contain a meta character '*'
|
|
|
|
// which matches zero or more occurrences of any character.
|
|
|
|
static bool matchStr(StringRef S, StringRef T) {
|
|
|
|
for (;;) {
|
|
|
|
if (S.empty())
|
|
|
|
return T.empty();
|
|
|
|
if (S[0] == '*') {
|
|
|
|
S = S.substr(1);
|
|
|
|
if (S.empty())
|
|
|
|
// Fast path. If a pattern is '*', it matches anything.
|
|
|
|
return true;
|
|
|
|
for (size_t I = 0, E = T.size(); I < E; ++I)
|
|
|
|
if (matchStr(S, T.substr(I)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (T.empty() || S[0] != T[0])
|
|
|
|
return false;
|
|
|
|
S = S.substr(1);
|
|
|
|
T = T.substr(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ELFT> bool SectionRule::match(InputSectionBase<ELFT> *S) {
|
|
|
|
return matchStr(SectionPattern, S->getSectionName());
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
class elf2::ScriptParser {
|
2015-10-01 01:23:26 +08:00
|
|
|
public:
|
2016-02-12 05:17:59 +08:00
|
|
|
ScriptParser(BumpPtrAllocator *A, StringRef S, bool B)
|
2016-02-19 18:45:45 +08:00
|
|
|
: Saver(*A), Tokens(tokenize(S)), IsUnderSysroot(B) {
|
2016-02-19 19:56:49 +08:00
|
|
|
Cmd["ENTRY"] = std::mem_fn(&ScriptParser::readEntry);
|
|
|
|
Cmd["EXTERN"] = std::mem_fn(&ScriptParser::readExtern);
|
|
|
|
Cmd["GROUP"] = std::mem_fn(&ScriptParser::readGroup);
|
|
|
|
Cmd["INCLUDE"] = std::mem_fn(&ScriptParser::readInclude);
|
|
|
|
Cmd["INPUT"] = std::mem_fn(&ScriptParser::readGroup);
|
|
|
|
Cmd["OUTPUT"] = std::mem_fn(&ScriptParser::readOutput);
|
|
|
|
Cmd["OUTPUT_ARCH"] = std::mem_fn(&ScriptParser::readOutputArch);
|
|
|
|
Cmd["OUTPUT_FORMAT"] = std::mem_fn(&ScriptParser::readOutputFormat);
|
|
|
|
Cmd["SEARCH_DIR"] = std::mem_fn(&ScriptParser::readSearchDir);
|
|
|
|
Cmd["SECTIONS"] = std::mem_fn(&ScriptParser::readSections);
|
2016-02-19 18:45:45 +08:00
|
|
|
Cmd[";"] = [](ScriptParser &) {};
|
|
|
|
}
|
|
|
|
|
2015-10-01 01:23:26 +08:00
|
|
|
void run();
|
|
|
|
|
|
|
|
private:
|
2016-02-03 04:27:59 +08:00
|
|
|
void setError(const Twine &Msg);
|
2015-10-01 01:23:26 +08:00
|
|
|
static std::vector<StringRef> tokenize(StringRef S);
|
|
|
|
static StringRef skipSpace(StringRef S);
|
2016-02-03 04:27:59 +08:00
|
|
|
bool atEOF();
|
2015-10-01 01:23:26 +08:00
|
|
|
StringRef next();
|
2015-11-12 17:52:08 +08:00
|
|
|
bool skip(StringRef Tok);
|
2015-10-01 01:23:26 +08:00
|
|
|
void expect(StringRef Expect);
|
|
|
|
|
2015-10-11 11:28:42 +08:00
|
|
|
void addFile(StringRef Path);
|
|
|
|
|
2015-10-01 01:23:26 +08:00
|
|
|
void readAsNeeded();
|
2015-10-08 14:48:38 +08:00
|
|
|
void readEntry();
|
2015-10-20 01:35:12 +08:00
|
|
|
void readExtern();
|
2015-10-01 01:23:26 +08:00
|
|
|
void readGroup();
|
2015-10-11 09:31:55 +08:00
|
|
|
void readInclude();
|
2015-10-07 08:25:09 +08:00
|
|
|
void readOutput();
|
2015-10-13 05:50:08 +08:00
|
|
|
void readOutputArch();
|
2015-10-01 01:23:26 +08:00
|
|
|
void readOutputFormat();
|
2015-10-09 01:51:41 +08:00
|
|
|
void readSearchDir();
|
2015-11-12 17:52:08 +08:00
|
|
|
void readSections();
|
|
|
|
|
|
|
|
void readOutputSectionDescription();
|
2015-10-01 01:23:26 +08:00
|
|
|
|
2015-10-11 09:53:04 +08:00
|
|
|
StringSaver Saver;
|
2015-10-01 01:23:26 +08:00
|
|
|
std::vector<StringRef> Tokens;
|
2016-02-19 18:45:45 +08:00
|
|
|
llvm::StringMap<std::function<void(ScriptParser &)>> Cmd;
|
2015-10-01 01:23:26 +08:00
|
|
|
size_t Pos = 0;
|
2015-11-26 13:53:00 +08:00
|
|
|
bool IsUnderSysroot;
|
2016-02-19 18:45:45 +08:00
|
|
|
bool Error = false;
|
2015-10-01 01:23:26 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::run() {
|
2015-10-01 01:23:26 +08:00
|
|
|
while (!atEOF()) {
|
|
|
|
StringRef Tok = next();
|
2016-02-19 18:45:45 +08:00
|
|
|
auto It = Cmd.find(Tok);
|
|
|
|
if (It != Cmd.end()) {
|
|
|
|
std::function<void(ScriptParser &)> &Handler = It->second;
|
|
|
|
Handler(*this);
|
2015-10-01 01:23:26 +08:00
|
|
|
} else {
|
2016-02-03 04:27:59 +08:00
|
|
|
setError("unknown directive: " + Tok);
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 04:27:59 +08:00
|
|
|
// We don't want to record cascading errors. Keep only the first one.
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::setError(const Twine &Msg) {
|
2016-02-03 04:27:59 +08:00
|
|
|
if (Error)
|
|
|
|
return;
|
|
|
|
error(Msg);
|
|
|
|
Error = true;
|
|
|
|
}
|
|
|
|
|
2015-10-01 01:23:26 +08:00
|
|
|
// Split S into linker script tokens.
|
2016-02-12 05:17:59 +08:00
|
|
|
std::vector<StringRef> ScriptParser::tokenize(StringRef S) {
|
2015-10-01 01:23:26 +08:00
|
|
|
std::vector<StringRef> Ret;
|
|
|
|
for (;;) {
|
|
|
|
S = skipSpace(S);
|
|
|
|
if (S.empty())
|
|
|
|
return Ret;
|
|
|
|
|
|
|
|
// Quoted token
|
|
|
|
if (S.startswith("\"")) {
|
|
|
|
size_t E = S.find("\"", 1);
|
2016-02-03 04:27:59 +08:00
|
|
|
if (E == StringRef::npos) {
|
|
|
|
error("unclosed quote");
|
|
|
|
return {};
|
|
|
|
}
|
2016-01-23 07:46:37 +08:00
|
|
|
Ret.push_back(S.substr(1, E - 1));
|
2015-10-01 01:23:26 +08:00
|
|
|
S = S.substr(E + 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unquoted token
|
|
|
|
size_t Pos = S.find_first_not_of(
|
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
|
|
"0123456789_.$/\\~=+[]*?-:");
|
|
|
|
// A character that cannot start a word (which is usually a
|
|
|
|
// punctuation) forms a single character token.
|
|
|
|
if (Pos == 0)
|
|
|
|
Pos = 1;
|
|
|
|
Ret.push_back(S.substr(0, Pos));
|
|
|
|
S = S.substr(Pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skip leading whitespace characters or /**/-style comments.
|
2016-02-12 05:17:59 +08:00
|
|
|
StringRef ScriptParser::skipSpace(StringRef S) {
|
2015-10-01 01:23:26 +08:00
|
|
|
for (;;) {
|
|
|
|
if (S.startswith("/*")) {
|
|
|
|
size_t E = S.find("*/", 2);
|
2016-02-03 04:27:59 +08:00
|
|
|
if (E == StringRef::npos) {
|
|
|
|
error("unclosed comment in a linker script");
|
|
|
|
return "";
|
|
|
|
}
|
2015-10-01 01:23:26 +08:00
|
|
|
S = S.substr(E + 2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
size_t Size = S.size();
|
|
|
|
S = S.ltrim();
|
|
|
|
if (S.size() == Size)
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-03 04:27:59 +08:00
|
|
|
// An errneous token is handled as if it were the last token before EOF.
|
2016-02-12 05:17:59 +08:00
|
|
|
bool ScriptParser::atEOF() { return Error || Tokens.size() == Pos; }
|
2016-02-03 04:27:59 +08:00
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
StringRef ScriptParser::next() {
|
2016-02-03 04:27:59 +08:00
|
|
|
if (Error)
|
|
|
|
return "";
|
|
|
|
if (atEOF()) {
|
|
|
|
setError("unexpected EOF");
|
|
|
|
return "";
|
|
|
|
}
|
2015-10-01 01:23:26 +08:00
|
|
|
return Tokens[Pos++];
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
bool ScriptParser::skip(StringRef Tok) {
|
2016-02-03 04:27:59 +08:00
|
|
|
if (Error)
|
|
|
|
return false;
|
|
|
|
if (atEOF()) {
|
|
|
|
setError("unexpected EOF");
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-12 17:52:08 +08:00
|
|
|
if (Tok != Tokens[Pos])
|
|
|
|
return false;
|
|
|
|
++Pos;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::expect(StringRef Expect) {
|
2016-02-03 04:27:59 +08:00
|
|
|
if (Error)
|
|
|
|
return;
|
2015-10-01 01:23:26 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
if (Tok != Expect)
|
2016-02-03 04:27:59 +08:00
|
|
|
setError(Expect + " expected, but got " + Tok);
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::addFile(StringRef S) {
|
2015-11-26 13:53:00 +08:00
|
|
|
if (IsUnderSysroot && S.startswith("/")) {
|
|
|
|
SmallString<128> Path;
|
|
|
|
(Config->Sysroot + S).toStringRef(Path);
|
|
|
|
if (sys::fs::exists(Path)) {
|
|
|
|
Driver->addFile(Saver.save(Path.str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-13 08:09:21 +08:00
|
|
|
if (sys::path::is_absolute(S)) {
|
2015-10-11 11:28:42 +08:00
|
|
|
Driver->addFile(S);
|
|
|
|
} else if (S.startswith("=")) {
|
|
|
|
if (Config->Sysroot.empty())
|
|
|
|
Driver->addFile(S.substr(1));
|
|
|
|
else
|
|
|
|
Driver->addFile(Saver.save(Config->Sysroot + "/" + S.substr(1)));
|
|
|
|
} else if (S.startswith("-l")) {
|
2016-02-03 05:13:09 +08:00
|
|
|
Driver->addLibrary(S.substr(2));
|
2015-11-27 04:23:46 +08:00
|
|
|
} else if (sys::fs::exists(S)) {
|
|
|
|
Driver->addFile(S);
|
2015-10-11 11:28:42 +08:00
|
|
|
} else {
|
|
|
|
std::string Path = findFromSearchPaths(S);
|
|
|
|
if (Path.empty())
|
2016-02-03 04:27:59 +08:00
|
|
|
setError("Unable to find " + S);
|
|
|
|
else
|
|
|
|
Driver->addFile(Saver.save(Path));
|
2015-10-11 11:28:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readAsNeeded() {
|
2015-10-01 01:23:26 +08:00
|
|
|
expect("(");
|
2015-10-12 04:59:12 +08:00
|
|
|
bool Orig = Config->AsNeeded;
|
|
|
|
Config->AsNeeded = true;
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error) {
|
2015-10-01 01:23:26 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
if (Tok == ")")
|
2015-10-12 04:59:12 +08:00
|
|
|
break;
|
2015-10-11 11:28:42 +08:00
|
|
|
addFile(Tok);
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
2015-10-12 04:59:12 +08:00
|
|
|
Config->AsNeeded = Orig;
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readEntry() {
|
2015-10-08 14:48:38 +08:00
|
|
|
// -e <symbol> takes predecence over ENTRY(<symbol>).
|
|
|
|
expect("(");
|
|
|
|
StringRef Tok = next();
|
|
|
|
if (Config->Entry.empty())
|
|
|
|
Config->Entry = Tok;
|
|
|
|
expect(")");
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readExtern() {
|
2015-10-20 01:35:12 +08:00
|
|
|
expect("(");
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error) {
|
2015-10-20 01:35:12 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
if (Tok == ")")
|
|
|
|
return;
|
|
|
|
Config->Undefined.push_back(Tok);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readGroup() {
|
2015-10-01 01:23:26 +08:00
|
|
|
expect("(");
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error) {
|
2015-10-01 01:23:26 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
if (Tok == ")")
|
|
|
|
return;
|
|
|
|
if (Tok == "AS_NEEDED") {
|
|
|
|
readAsNeeded();
|
|
|
|
continue;
|
|
|
|
}
|
2015-10-11 11:28:42 +08:00
|
|
|
addFile(Tok);
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readInclude() {
|
2015-10-11 09:31:55 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
auto MBOrErr = MemoryBuffer::getFile(Tok);
|
2016-02-03 04:27:59 +08:00
|
|
|
if (!MBOrErr) {
|
|
|
|
setError("cannot open " + Tok);
|
|
|
|
return;
|
|
|
|
}
|
2015-10-11 09:31:55 +08:00
|
|
|
std::unique_ptr<MemoryBuffer> &MB = *MBOrErr;
|
2015-10-11 09:53:04 +08:00
|
|
|
StringRef S = Saver.save(MB->getMemBufferRef().getBuffer());
|
|
|
|
std::vector<StringRef> V = tokenize(S);
|
2015-10-11 09:31:55 +08:00
|
|
|
Tokens.insert(Tokens.begin() + Pos, V.begin(), V.end());
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readOutput() {
|
2015-10-07 08:25:09 +08:00
|
|
|
// -o <file> takes predecence over OUTPUT(<file>).
|
|
|
|
expect("(");
|
|
|
|
StringRef Tok = next();
|
|
|
|
if (Config->OutputFile.empty())
|
|
|
|
Config->OutputFile = Tok;
|
|
|
|
expect(")");
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readOutputArch() {
|
2015-10-13 05:50:08 +08:00
|
|
|
// Error checking only for now.
|
|
|
|
expect("(");
|
|
|
|
next();
|
|
|
|
expect(")");
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readOutputFormat() {
|
2015-10-01 01:23:26 +08:00
|
|
|
// Error checking only for now.
|
|
|
|
expect("(");
|
|
|
|
next();
|
2015-10-13 05:08:41 +08:00
|
|
|
StringRef Tok = next();
|
|
|
|
if (Tok == ")")
|
|
|
|
return;
|
2016-02-03 04:27:59 +08:00
|
|
|
if (Tok != ",") {
|
|
|
|
setError("unexpected token: " + Tok);
|
|
|
|
return;
|
|
|
|
}
|
2015-10-13 05:08:41 +08:00
|
|
|
next();
|
|
|
|
expect(",");
|
|
|
|
next();
|
2015-10-01 01:23:26 +08:00
|
|
|
expect(")");
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readSearchDir() {
|
2015-10-09 01:51:41 +08:00
|
|
|
expect("(");
|
2015-10-11 11:28:42 +08:00
|
|
|
Config->SearchPaths.push_back(next());
|
2015-10-09 01:51:41 +08:00
|
|
|
expect(")");
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readSections() {
|
2015-11-12 17:52:08 +08:00
|
|
|
expect("{");
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error && !skip("}"))
|
2015-11-12 17:52:08 +08:00
|
|
|
readOutputSectionDescription();
|
|
|
|
}
|
|
|
|
|
2016-02-12 05:17:59 +08:00
|
|
|
void ScriptParser::readOutputSectionDescription() {
|
2016-02-13 04:41:43 +08:00
|
|
|
StringRef OutSec = next();
|
|
|
|
Script->SectionOrder.push_back(OutSec);
|
2015-11-12 17:52:08 +08:00
|
|
|
expect(":");
|
|
|
|
expect("{");
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error && !skip("}")) {
|
2015-11-12 17:52:08 +08:00
|
|
|
next(); // Skip input file name.
|
|
|
|
expect("(");
|
2016-02-03 04:27:59 +08:00
|
|
|
while (!Error && !skip(")"))
|
2016-02-13 05:47:28 +08:00
|
|
|
Script->Sections.push_back({OutSec, next()});
|
2015-11-12 17:52:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-26 13:53:00 +08:00
|
|
|
static bool isUnderSysroot(StringRef Path) {
|
|
|
|
if (Config->Sysroot == "")
|
|
|
|
return false;
|
|
|
|
for (; !Path.empty(); Path = sys::path::parent_path(Path))
|
|
|
|
if (sys::fs::equivalent(Config->Sysroot, Path))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-01 01:23:26 +08:00
|
|
|
// Entry point. The other functions or classes are private to this file.
|
2016-02-12 05:38:55 +08:00
|
|
|
void LinkerScript::read(MemoryBufferRef MB) {
|
2015-11-26 13:53:00 +08:00
|
|
|
StringRef Path = MB.getBufferIdentifier();
|
2016-02-12 05:38:55 +08:00
|
|
|
ScriptParser(&Alloc, MB.getBuffer(), isUnderSysroot(Path)).run();
|
2015-10-01 01:23:26 +08:00
|
|
|
}
|
2016-02-13 05:47:28 +08:00
|
|
|
|
|
|
|
template StringRef LinkerScript::getOutputSection(InputSectionBase<ELF32LE> *);
|
|
|
|
template StringRef LinkerScript::getOutputSection(InputSectionBase<ELF32BE> *);
|
|
|
|
template StringRef LinkerScript::getOutputSection(InputSectionBase<ELF64LE> *);
|
|
|
|
template StringRef LinkerScript::getOutputSection(InputSectionBase<ELF64BE> *);
|
|
|
|
|
|
|
|
template bool LinkerScript::isDiscarded(InputSectionBase<ELF32LE> *);
|
|
|
|
template bool LinkerScript::isDiscarded(InputSectionBase<ELF32BE> *);
|
|
|
|
template bool LinkerScript::isDiscarded(InputSectionBase<ELF64LE> *);
|
|
|
|
template bool LinkerScript::isDiscarded(InputSectionBase<ELF64BE> *);
|
|
|
|
|
|
|
|
template bool SectionRule::match(InputSectionBase<ELF32LE> *);
|
|
|
|
template bool SectionRule::match(InputSectionBase<ELF32BE> *);
|
|
|
|
template bool SectionRule::match(InputSectionBase<ELF64LE> *);
|
|
|
|
template bool SectionRule::match(InputSectionBase<ELF64BE> *);
|