From owner-svn-src-projects@freebsd.org Tue Oct 23 20:57:00 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 2E1C1FFC8F6 for ; Tue, 23 Oct 2018 20:57:00 +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 D7DFF70031; Tue, 23 Oct 2018 20:56:59 +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 B9F941530D; Tue, 23 Oct 2018 20:56:59 +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 w9NKux8e061631; Tue, 23 Oct 2018 20:56:59 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9NKux50061630; Tue, 23 Oct 2018 20:56:59 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201810232056.w9NKux50061630@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 23 Oct 2018 20:56:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r339669 - 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: 339669 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.29 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: Tue, 23 Oct 2018 20:57:00 -0000 Author: dim Date: Tue Oct 23 20:56:59 2018 New Revision: 339669 URL: https://svnweb.freebsd.org/changeset/base/339669 Log: Pull in r345002 from upstream lld trunk: Don't mess up RelIplt symbols during relocatable processing Summary: During upgrading of the FreeBSD source tree with lld 7.0.0, I noticed that it started complaining about crt1.o having an "index past the end of the symbol table". Such a symbol table looks approximately like this, viewed with readelf -s (note the Ndx field being messed up): Symbol table '.symtab' contains 4 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 NOTYPE WEAK HIDDEN RSV[0xffff] __rel_iplt_end 3: 00000000 0 NOTYPE WEAK HIDDEN RSV[0xffff] __rel_iplt_start At first, it seemed that recent ifunc relocation work had caused this: , but it turned out that it was due to incorrect processing of the object files by lld, when using -r (a.k.a. --relocatable). Bisecting showed that rL324421 ("Convert a use of Config->Static") was the commit where this new behavior began. Simply reverting it solved the issue, and the __rel_iplt symbols had an index of UND again. Looking at Rafael's commit message, I think he simply missed the possibility of --relocatable being in effect, so I have added an additional check for it. I also added a simple regression test case. Reviewers: grimar, ruiu, emaste, espindola Reviewed By: ruiu Subscribers: arichardson, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D53515 This fixes a problem in lld where it places incorrect indexes for ifunc related symbols in crt1.o and friends, making it impossible to link most normal programs with it. Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Modified: projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp ============================================================================== --- projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Tue Oct 23 20:45:46 2018 (r339668) +++ projects/clang700-import/contrib/llvm/tools/lld/ELF/Writer.cpp Tue Oct 23 20:56:59 2018 (r339669) @@ -874,7 +874,7 @@ void PhdrEntry::add(OutputSection *Sec) { // need these symbols, since IRELATIVE relocs are resolved through GOT // and PLT. For details, see http://www.airs.com/blog/archives/403. template void Writer::addRelIpltSymbols() { - if (needsInterpSection()) + if (Config->Relocatable || needsInterpSection()) return; StringRef S = Config->IsRela ? "__rela_iplt_start" : "__rel_iplt_start"; addOptionalRegular(S, InX::RelaIplt, 0, STV_HIDDEN, STB_WEAK);