aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-10-11 01:19:33 +0000
committerRui Ueyama <ruiu@google.com>2017-10-11 01:19:33 +0000
commitac27de9dc707bb1dd191a2deb6ad347e0f9df602 (patch)
treeda286b64d5c67762b1693d6de3008522d1b0d948 /lld/ELF/ScriptParser.cpp
parentb920f85d8e8c067362618d6067686c6a5d84005a (diff)
downloadllvm-ac27de9dc707bb1dd191a2deb6ad347e0f9df602.zip
llvm-ac27de9dc707bb1dd191a2deb6ad347e0f9df602.tar.gz
llvm-ac27de9dc707bb1dd191a2deb6ad347e0f9df602.tar.bz2
Remove ScriptConfiguration class and move the members to LinkerScript class.
ScriptConfiguration was a class to contain parsed results of linker scripts. LinkerScript is a class to interpret it. That ditinction was needed because we haven't instantiated LinkerScript early (because, IIRC, LinkerScript class was a ELFT template function). So, when we parse linker scripts, we couldn't directly store the result to a LinkerScript instance. Now, that limitation is gone. We instantiate LinkerScript at the very beginning of our main function. We can directly store parse results to a LinkerScript instance. llvm-svn: 315403
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 58d1455..944e29f 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -234,7 +234,7 @@ void ScriptParser::readLinkerScript() {
continue;
if (Tok == "ASSERT") {
- Script->Opt.Commands.push_back(readAssert());
+ Script->Commands.push_back(readAssert());
} else if (Tok == "ENTRY") {
readEntry();
} else if (Tok == "EXTERN") {
@@ -262,7 +262,7 @@ void ScriptParser::readLinkerScript() {
} else if (Tok == "VERSION") {
readVersion();
} else if (SymbolAssignment *Cmd = readProvideOrAssignment(Tok)) {
- Script->Opt.Commands.push_back(Cmd);
+ Script->Commands.push_back(Cmd);
} else {
setError("unknown directive: " + Tok);
}
@@ -407,7 +407,7 @@ void ScriptParser::readPhdrs() {
setError("unexpected header attribute: " + next());
}
- Script->Opt.PhdrsCommands.push_back(Cmd);
+ Script->PhdrsCommands.push_back(Cmd);
}
}
@@ -418,11 +418,11 @@ void ScriptParser::readRegionAlias() {
StringRef Name = next();
expect(")");
- if (Script->Opt.MemoryRegions.count(Alias))
+ if (Script->MemoryRegions.count(Alias))
setError("redefinition of memory region '" + Alias + "'");
- if (!Script->Opt.MemoryRegions.count(Name))
+ if (!Script->MemoryRegions.count(Name))
setError("memory region '" + Name + "' is not defined");
- Script->Opt.MemoryRegions[Alias] = Script->Opt.MemoryRegions[Name];
+ Script->MemoryRegions[Alias] = Script->MemoryRegions[Name];
}
void ScriptParser::readSearchDir() {
@@ -434,7 +434,7 @@ void ScriptParser::readSearchDir() {
}
void ScriptParser::readSections() {
- Script->Opt.HasSections = true;
+ Script->HasSections = true;
// -no-rosegment is used to avoid placing read only non-executable sections in
// their own segment. We do the same if SECTIONS command is present in linker
@@ -451,7 +451,7 @@ void ScriptParser::readSections() {
else
Cmd = readOutputSectionDescription(Tok);
}
- Script->Opt.Commands.push_back(Cmd);
+ Script->Commands.push_back(Cmd);
}
}
@@ -572,7 +572,7 @@ ScriptParser::readInputSectionDescription(StringRef Tok) {
StringRef FilePattern = next();
InputSectionDescription *Cmd = readInputSectionRules(FilePattern);
expect(")");
- Script->Opt.KeptSections.push_back(Cmd);
+ Script->KeptSections.push_back(Cmd);
return Cmd;
}
return readInputSectionRules(Tok);
@@ -1013,9 +1013,9 @@ Expr ScriptParser::readPrimary() {
}
if (Tok == "LENGTH") {
StringRef Name = readParenLiteral();
- if (Script->Opt.MemoryRegions.count(Name) == 0)
+ if (Script->MemoryRegions.count(Name) == 0)
setError("memory region not defined: " + Name);
- return [=] { return Script->Opt.MemoryRegions[Name]->Length; };
+ return [=] { return Script->MemoryRegions[Name]->Length; };
}
if (Tok == "LOADADDR") {
StringRef Name = readParenLiteral();
@@ -1027,9 +1027,9 @@ Expr ScriptParser::readPrimary() {
}
if (Tok == "ORIGIN") {
StringRef Name = readParenLiteral();
- if (Script->Opt.MemoryRegions.count(Name) == 0)
+ if (Script->MemoryRegions.count(Name) == 0)
setError("memory region not defined: " + Name);
- return [=] { return Script->Opt.MemoryRegions[Name]->Origin; };
+ return [=] { return Script->MemoryRegions[Name]->Origin; };
}
if (Tok == "SEGMENT_START") {
expect("(");
@@ -1061,7 +1061,7 @@ Expr ScriptParser::readPrimary() {
// Tok is a symbol name.
if (!isValidCIdentifier(Tok))
setError("malformed number: " + Tok);
- Script->Opt.ReferencedSymbols.push_back(Tok);
+ Script->ReferencedSymbols.push_back(Tok);
return [=] { return Script->getSymbolValue(Location, Tok); };
}
@@ -1261,11 +1261,11 @@ void ScriptParser::readMemory() {
uint64_t Length = readMemoryAssignment("LENGTH", "len", "l");
// Add the memory region to the region map.
- if (Script->Opt.MemoryRegions.count(Name))
+ if (Script->MemoryRegions.count(Name))
setError("region '" + Name + "' already defined");
MemoryRegion *MR = make<MemoryRegion>();
*MR = {Name, Origin, Length, Flags, NegFlags};
- Script->Opt.MemoryRegions[Name] = MR;
+ Script->MemoryRegions[Name] = MR;
}
}