From owner-svn-src-head@freebsd.org Thu Jan 18 21:38:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BE4EEC4AD9; Thu, 18 Jan 2018 21:38:23 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 26B0682985; Thu, 18 Jan 2018 21:38:23 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6792524257; Thu, 18 Jan 2018 21:38:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0ILcMoF010697; Thu, 18 Jan 2018 21:38:22 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0ILcMcW010694; Thu, 18 Jan 2018 21:38:22 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201801182138.w0ILcMcW010694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 18 Jan 2018 21:38:22 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/contrib/llvm/tools/lld/ELF X-SVN-Commit-Revision: 328141 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jan 2018 21:38:23 -0000 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 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("="))