diff options
author | George Rimar <grimar@accesssoftek.com> | 2018-03-08 14:54:38 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2018-03-08 14:54:38 +0000 |
commit | 9e2c8a9db16f502b135a38fdb6555de8739b9a5f (patch) | |
tree | 43f4ef01cf0b3671e43fd56cff2f161ecc10c0c3 /lld/ELF/ScriptParser.cpp | |
parent | 9003b3b76d57c15ee8c451f0c2292977916dcb88 (diff) | |
download | bcm5719-llvm-9e2c8a9db16f502b135a38fdb6555de8739b9a5f.tar.gz bcm5719-llvm-9e2c8a9db16f502b135a38fdb6555de8739b9a5f.zip |
[ELF] - Support "INSERT AFTER" statement.
This implements INSERT AFTER in a following way:
During reading scripts it collects all insert statements.
After we done and read all files it inserts statements into script commands list.
With that:
* Rest of code does know nothing about INSERT.
* Approach is straightforward and have no visible limitations.
* It is also easy to support INSERT BEFORE (was seen in clang code once).
* Should work for PR35877 and similar cases.
Cons:
* It assumes we have "main" scripts that describes sections.
Differential revision: https://reviews.llvm.org/D43468
llvm-svn: 327003
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index c68c25ad615..29dec116ce8 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -436,6 +436,7 @@ void ScriptParser::readSections() { Config->SingleRoRx = true; expect("{"); + std::vector<BaseCommand *> V; while (!errorCount() && !consume("}")) { StringRef Tok = next(); BaseCommand *Cmd = readProvideOrAssignment(Tok); @@ -445,8 +446,18 @@ void ScriptParser::readSections() { else Cmd = readOutputSectionDescription(Tok); } - Script->SectionCommands.push_back(Cmd); + V.push_back(Cmd); } + + if (!atEOF() && consume("INSERT")) { + consume("AFTER"); + std::vector<BaseCommand *> &Dest = Script->InsertAfterCommands[next()]; + Dest.insert(Dest.end(), V.begin(), V.end()); + return; + } + + Script->SectionCommands.insert(Script->SectionCommands.end(), V.begin(), + V.end()); } static int precedence(StringRef Op) { |