summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-03-13 09:18:11 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-03-13 09:18:11 +0000
commit796684b451b42c72a1c963ea8e1aa47e974c5cc4 (patch)
tree819cd07bb6089a47b69686897e34aca1e42b4fb3 /lld/ELF/ScriptParser.cpp
parentebc1d1fddec15d941c88e07bf98e67557b5fda88 (diff)
downloadbcm5719-llvm-796684b451b42c72a1c963ea8e1aa47e974c5cc4.tar.gz
bcm5719-llvm-796684b451b42c72a1c963ea8e1aa47e974c5cc4.zip
[ELF] - Implement INSERT BEFORE.
This finishes PR35877. INSERT BEFORE used similar to INSERT AFTER, it inserts sections before the given target section. Differential revision: https://reviews.llvm.org/D44380 llvm-svn: 327378
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