diff options
author | Ed Maste <emaste@FreeBSD.org> | 2018-01-18 21:38:21 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2018-01-18 21:38:21 +0000 |
commit | d3f08be7dcfb94a6978fdc912645d0a0790ffbfa (patch) | |
tree | eebecf1e8eff1e2e3a5d16fe4cdb6ec8ff99ffec /contrib/llvm | |
parent | f5b26e1334ef0befbf2c5cd96932251132f7fa68 (diff) | |
download | src-d3f08be7dcfb94a6978fdc912645d0a0790ffbfa.tar.gz src-d3f08be7dcfb94a6978fdc912645d0a0790ffbfa.zip |
lld: Fix for ld.lld does not accept "AT" syntax for declaring LMA region
AT> lma_region expression allows to specify the memory region
for section load address.
Should fix [upstream LLVM] PR35684.
LLVM review: https://reviews.llvm.org/D41397
Obtained from: LLVM r322359 by George Rimar
Notes
Notes:
svn path=/head/; revision=328141
Diffstat (limited to 'contrib/llvm')
-rw-r--r-- | contrib/llvm/tools/lld/ELF/LinkerScript.cpp | 9 | ||||
-rw-r--r-- | contrib/llvm/tools/lld/ELF/OutputSections.h | 1 | ||||
-rw-r--r-- | contrib/llvm/tools/lld/ELF/ScriptParser.cpp | 8 |
3 files changed, 18 insertions, 0 deletions
diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp index 16b306da4654..95848bd20bed 100644 --- a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp +++ b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp @@ -667,6 +667,15 @@ void LinkerScript::assignOffsets(OutputSection *Sec) { Ctx->LMAOffset = [=] { return Sec->LMAExpr().getValue() - D; }; } + if (!Sec->LMARegionName.empty()) { + if (MemoryRegion *MR = MemoryRegions.lookup(Sec->LMARegionName)) { + uint64_t Offset = MR->Origin - Dot; + Ctx->LMAOffset = [=] { return Offset; }; + } else { + error("memory region '" + Sec->LMARegionName + "' not declared"); + } + } + switchTo(Sec); // The Size previously denoted how many InputSections had been added to this diff --git a/contrib/llvm/tools/lld/ELF/OutputSections.h b/contrib/llvm/tools/lld/ELF/OutputSections.h index b2845773e9af..009f45c03333 100644 --- a/contrib/llvm/tools/lld/ELF/OutputSections.h +++ b/contrib/llvm/tools/lld/ELF/OutputSections.h @@ -99,6 +99,7 @@ public: ConstraintKind Constraint = ConstraintKind::NoConstraint; std::string Location; std::string MemoryRegionName; + std::string LMARegionName; bool Noload = false; template <class ELFT> void finalize(); diff --git a/contrib/llvm/tools/lld/ELF/ScriptParser.cpp b/contrib/llvm/tools/lld/ELF/ScriptParser.cpp index 4263944981f2..435b3b28f4f2 100644 --- a/contrib/llvm/tools/lld/ELF/ScriptParser.cpp +++ b/contrib/llvm/tools/lld/ELF/ScriptParser.cpp @@ -709,6 +709,14 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef OutSec) { if (consume(">")) Cmd->MemoryRegionName = next(); + if (consume("AT")) { + expect(">"); + Cmd->LMARegionName = next(); + } + + if (Cmd->LMAExpr && !Cmd->LMARegionName.empty()) + error("section can't have both LMA and a load region"); + Cmd->Phdrs = readOutputSectionPhdrs(); if (consume("=")) |