diff options
author | Rui Ueyama <ruiu@google.com> | 2018-10-12 17:07:32 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2018-10-12 17:07:32 +0000 |
commit | 2e9d40d5f45c4f7fa3e58acfb99c822dddec74df (patch) | |
tree | 6c398cdbfe8fd7cd43a7ff6a96219d2697221fa3 /lld/ELF/ScriptParser.cpp | |
parent | d0fbef9c753a78aa20d5a462b682bfaf83cc6e6e (diff) | |
download | llvm-2e9d40d5f45c4f7fa3e58acfb99c822dddec74df.zip llvm-2e9d40d5f45c4f7fa3e58acfb99c822dddec74df.tar.gz llvm-2e9d40d5f45c4f7fa3e58acfb99c822dddec74df.tar.bz2 |
[lld] Add more complete support for the INCLUDE command.
Patch by Ian Tessier.
This change adds INCLUDE support to the MEMORY and SECTION commands, and
to output sections, as per:
https://sourceware.org/binutils/docs/ld/File-Commands.html#File-Commands
Differential Revision: https://reviews.llvm.org/D52951
llvm-svn: 344368
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 4d1dd75..d548689c 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -501,6 +501,9 @@ void ScriptParser::readSections() { for (BaseCommand *Cmd : readOverlay()) V.push_back(Cmd); continue; + } else if (Tok == "INCLUDE") { + readInclude(); + continue; } if (BaseCommand *Cmd = readAssignment(Tok)) @@ -803,6 +806,8 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef OutSec) { Cmd->Filler = readFill(); } else if (Tok == "SORT") { readSort(); + } else if (Tok == "INCLUDE") { + readInclude(); } else if (peek() == "(") { Cmd->SectionCommands.push_back(readInputSectionDescription(Tok)); } else { @@ -1429,7 +1434,11 @@ uint64_t ScriptParser::readMemoryAssignment(StringRef S1, StringRef S2, void ScriptParser::readMemory() { expect("{"); while (!errorCount() && !consume("}")) { - StringRef Name = next(); + StringRef Tok = next(); + if (Tok == "INCLUDE") { + readInclude(); + continue; + } uint32_t Flags = 0; uint32_t NegFlags = 0; @@ -1444,10 +1453,9 @@ void ScriptParser::readMemory() { uint64_t Length = readMemoryAssignment("LENGTH", "len", "l"); // Add the memory region to the region map. - MemoryRegion *MR = - make<MemoryRegion>(Name, Origin, Length, Flags, NegFlags); - if (!Script->MemoryRegions.insert({Name, MR}).second) - setError("region '" + Name + "' already defined"); + MemoryRegion *MR = make<MemoryRegion>(Tok, Origin, Length, Flags, NegFlags); + if (!Script->MemoryRegions.insert({Tok, MR}).second) + setError("region '" + Tok + "' already defined"); } } |