svn commit: r328141 - head/contrib/llvm/tools/lld/ELF
Ed Maste
emaste at FreeBSD.org
Thu Jan 18 21:38:23 UTC 2018
Author: emaste
Date: Thu Jan 18 21:38:21 2018
New Revision: 328141
URL: https://svnweb.freebsd.org/changeset/base/328141
Log:
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
Modified:
head/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
head/contrib/llvm/tools/lld/ELF/OutputSections.h
head/contrib/llvm/tools/lld/ELF/ScriptParser.cpp
Modified: head/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/LinkerScript.cpp Thu Jan 18 21:35:18 2018 (r328140)
+++ head/contrib/llvm/tools/lld/ELF/LinkerScript.cpp Thu Jan 18 21:38:21 2018 (r328141)
@@ -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
Modified: head/contrib/llvm/tools/lld/ELF/OutputSections.h
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/OutputSections.h Thu Jan 18 21:35:18 2018 (r328140)
+++ head/contrib/llvm/tools/lld/ELF/OutputSections.h Thu Jan 18 21:38:21 2018 (r328141)
@@ -99,6 +99,7 @@ class OutputSection final : public BaseCommand, public
ConstraintKind Constraint = ConstraintKind::NoConstraint;
std::string Location;
std::string MemoryRegionName;
+ std::string LMARegionName;
bool Noload = false;
template <class ELFT> void finalize();
Modified: head/contrib/llvm/tools/lld/ELF/ScriptParser.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/ScriptParser.cpp Thu Jan 18 21:35:18 2018 (r328140)
+++ head/contrib/llvm/tools/lld/ELF/ScriptParser.cpp Thu Jan 18 21:38:21 2018 (r328141)
@@ -709,6 +709,14 @@ OutputSection *ScriptParser::readOutputSectionDescript
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("="))
More information about the svn-src-all
mailing list