From owner-svn-src-projects@freebsd.org Fri Aug 24 17:48:06 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89F38109018D for ; Fri, 24 Aug 2018 17:48:06 +0000 (UTC) (envelope-from dim@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 3FE598F907; Fri, 24 Aug 2018 17:48:06 +0000 (UTC) (envelope-from dim@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 207A814481; Fri, 24 Aug 2018 17:48:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7OHm6l8097428; Fri, 24 Aug 2018 17:48:06 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7OHm5SD097425; Fri, 24 Aug 2018 17:48:05 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201808241748.w7OHm5SD097425@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 24 Aug 2018 17:48:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r338297 - projects/clang700-import/contrib/llvm/tools/lld/ELF X-SVN-Group: projects X-SVN-Commit-Author: dim X-SVN-Commit-Paths: projects/clang700-import/contrib/llvm/tools/lld/ELF X-SVN-Commit-Revision: 338297 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2018 17:48:06 -0000 Author: dim Date: Fri Aug 24 17:48:05 2018 New Revision: 338297 URL: https://svnweb.freebsd.org/changeset/base/338297 Log: Apply r338251 ("Preserve relocations against ifuncs when -zifunc-noplt is specified") on top of lld 7.0.0. This is to prepare for another merge from head. Obtained from: https://github.com/markjdb/freebsd-dev/commit/02f35faa6df364769b9223746b99e3c7ba05c5dd Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Config.h projects/clang700-import/contrib/llvm/tools/lld/ELF/Driver.cpp projects/clang700-import/contrib/llvm/tools/lld/ELF/Relocations.cpp projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Config.h ============================================================================== --- projects/clang700-import/contrib/llvm/tools/lld/ELF/Config.h Fri Aug 24 15:01:58 2018 (r338296) +++ projects/clang700-import/contrib/llvm/tools/lld/ELF/Config.h Fri Aug 24 17:48:05 2018 (r338297) @@ -181,6 +181,7 @@ struct Configuration { bool ZCopyreloc; bool ZExecstack; bool ZHazardplt; + bool ZIfuncnoplt; bool ZInitfirst; bool ZKeepTextSectionPrefix; bool ZNodelete; Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Driver.cpp ============================================================================== --- projects/clang700-import/contrib/llvm/tools/lld/ELF/Driver.cpp Fri Aug 24 15:01:58 2018 (r338296) +++ projects/clang700-import/contrib/llvm/tools/lld/ELF/Driver.cpp Fri Aug 24 17:48:05 2018 (r338297) @@ -338,7 +338,8 @@ static bool getZFlag(opt::InputArgList &Args, StringRe static bool isKnown(StringRef S) { return S == "combreloc" || S == "copyreloc" || S == "defs" || - S == "execstack" || S == "hazardplt" || S == "initfirst" || + S == "execstack" || S == "hazardplt" || S == "ifunc-noplt" || + S == "initfirst" || S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" || S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" || S == "nodlopen" || S == "noexecstack" || @@ -843,6 +844,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true); Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false); Config->ZHazardplt = hasZOption(Args, "hazardplt"); + Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt"); Config->ZInitfirst = hasZOption(Args, "initfirst"); Config->ZKeepTextSectionPrefix = getZFlag( Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false); Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Relocations.cpp ============================================================================== --- projects/clang700-import/contrib/llvm/tools/lld/ELF/Relocations.cpp Fri Aug 24 15:01:58 2018 (r338296) +++ projects/clang700-import/contrib/llvm/tools/lld/ELF/Relocations.cpp Fri Aug 24 17:48:05 2018 (r338297) @@ -366,6 +366,10 @@ static bool isStaticLinkTimeConstant(RelExpr E, RelTyp R_TLSLD_HINT>(E)) return true; + // The computation involves output from the ifunc resolver. + if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) + return false; + // These never do, except if the entire file is position dependent or if // only the low bits are used. if (E == R_GOT || E == R_PLT || E == R_TLSDESC) @@ -816,6 +820,10 @@ static void processRelocAux(InputSectionBase &Sec, Rel Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); return; } + if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) { + InX::RelaDyn->addReloc(Type, &Sec, Offset, &Sym, Addend, R_ADDEND, Type); + return; + } bool CanWrite = (Sec.Flags & SHF_WRITE) || !Config->ZText; if (CanWrite) { // R_GOT refers to a position in the got, even if the symbol is preemptible. @@ -985,7 +993,7 @@ static void scanReloc(InputSectionBase &Sec, OffsetGet // all dynamic symbols that can be resolved within the executable will // actually be resolved that way at runtime, because the main exectuable // is always at the beginning of a search list. We can leverage that fact. - if (Sym.isGnuIFunc()) + if (Sym.isGnuIFunc() && !Config->ZIfuncnoplt) Expr = toPlt(Expr); else if (!Sym.IsPreemptible && Expr == R_GOT_PC && !isAbsoluteValue(Sym)) Expr = Target->adjustRelaxExpr(Type, RelocatedAddr, Expr); Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp ============================================================================== --- projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Fri Aug 24 15:01:58 2018 (r338296) +++ projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Fri Aug 24 17:48:05 2018 (r338297) @@ -1561,8 +1561,11 @@ template void Writer::finalizeSecti applySynthetic({InX::EhFrame}, [](SyntheticSection *SS) { SS->finalizeContents(); }); - for (Symbol *S : Symtab->getSymbols()) + for (Symbol *S : Symtab->getSymbols()) { S->IsPreemptible |= computeIsPreemptible(*S); + if (S->isGnuIFunc() && Config->ZIfuncnoplt) + S->ExportDynamic = true; + } // Scan relocations. This must be done after every symbol is declared so that // we can correctly decide if a dynamic relocation is needed.