Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2018 21:38:22 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r328141 - head/contrib/llvm/tools/lld/ELF
Message-ID:  <201801182138.w0ILcMcW010694@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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("="))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801182138.w0ILcMcW010694>