summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 2ff94650dbd..cc51cb0437b 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -450,9 +450,15 @@ void ScriptParser::readSections() {
}
if (!atEOF() && consume("INSERT")) {
- expect("AFTER");
- std::vector<BaseCommand *> &Dest = Script->InsertAfterCommands[next()];
- Dest.insert(Dest.end(), V.begin(), V.end());
+ std::vector<BaseCommand *> *Dest = nullptr;
+ if (consume("AFTER"))
+ Dest = &Script->InsertAfterCommands[next()];
+ else if (consume("BEFORE"))
+ Dest = &Script->InsertBeforeCommands[next()];
+ else
+ setError("expected AFTER/BEFORE, but got '" + next() + "'");
+ if (Dest)
+ Dest->insert(Dest->end(), V.begin(), V.end());
return;
}
OpenPOWER on IntegriCloud