From owner-freebsd-toolchain@freebsd.org Tue Jan 17 21:58:44 2017 Return-Path: Delivered-To: freebsd-toolchain@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 B8DAFCB4187 for ; Tue, 17 Jan 2017 21:58:44 +0000 (UTC) (envelope-from rdivacky@vlakno.cz) Received: from vlakno.cz (mail.vlakno.cz [91.217.96.224]) by mx1.freebsd.org (Postfix) with ESMTP id 49F911753; Tue, 17 Jan 2017 21:58:43 +0000 (UTC) (envelope-from rdivacky@vlakno.cz) Received: by vlakno.cz (Postfix, from userid 1002) id 30C6E12CB9F; Tue, 17 Jan 2017 22:56:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=vlakno.cz; s=mail; t=1484690173; bh=YgEOUahFsxp37/1XIHUkewe3HbwHyb7x+GzkqPPT8fA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=O+o8UYMMqJaCiVGS+j4OpiPIL94iune4db86ismlgay0pJRjj63ZIeoor42fejbF3 bTTsV8zz6SFJDew9NLUxUuWvvTQnLUHJII9cEKGKgUJt2EoeKEfS+VRSLRSmCYKvfk kbVmWAPR7lLDUXeEyrPWccDuk6OQMbO5FTDj2jMg= Date: Tue, 17 Jan 2017 22:56:13 +0100 From: Roman Divacky To: Mark Millard Cc: Ed Maste , FreeBSD Toolchain Subject: Re: /usr/bin/ld.lld on powerpc64: produces a.out for which: ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/powerpc64/reloc.c:374 Message-ID: <20170117215613.GA95258@vlakno.cz> References: <932E3C38-B226-4BF1-B587-5A2D5EA19300@dsl-only.net> <20170116194035.GA20175@vlakno.cz> <2B1414C5-C56D-42F2-A1CB-4B1FE074667B@dsl-only.net> <43DBF7C7-6632-4906-BB37-FD00621AF857@dsl-only.net> <82402941-D1B2-4938-A43D-E21A390DE041@dsl-only.net> <27422F1B-6906-4D37-860A-D1BC8DC83BBF@dsl-only.net> <20170117195424.GA89237@vlakno.cz> <237EB920-0795-4B18-94D4-2EAC0FC76F01@dsl-only.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <237EB920-0795-4B18-94D4-2EAC0FC76F01@dsl-only.net> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2017 21:58:44 -0000 Go with Out. On Tue, Jan 17, 2017 at 01:53:14PM -0800, Mark Millard wrote: > On 2017-Jan-17, at 11:54 AM, Roman Divacky wrote: > > . . . > > I wonder if it doesnt work because of my first patch (the one to turn GOT > > reloc into PLT one). > > > > LLD understands that we use GOT as TOC (which was true before my patch), > > I wonder if something like this: > > > > ndex: tools/lld/ELF/Target.cpp > > =================================================================== > > --- tools/lld/ELF/Target.cpp (revision 292071) > > +++ tools/lld/ELF/Target.cpp (working copy) > > @@ -1070,7 +1070,8 @@ > > } > > > > PPC64TargetInfo::PPC64TargetInfo() { > > - PltRel = GotRel = R_PPC64_GLOB_DAT; > > + GotRel = R_PPC64_GLOB_DAT; > > + PltRel = R_PPC64_JMP_SLOT; > > RelativeRel = R_PPC64_RELATIVE; > > GotEntrySize = 8; > > GotPltEntrySize = 8; > > @@ -1099,7 +1100,7 @@ > > // TOC starts where the first of these sections starts. We always create a > > // .got when we see a relocation that uses it, so for us the start is always > > // the .got. > > - uint64_t TocVA = In::Got->getVA(); > > + uint64_t TocVA = In::Plt->getVA(); > > > > // Per the ppc64-elf-linux ABI, The TOC base is TOC value plus 0x8000 > > // thus permitting a full 64 Kbytes segment. Note that the glibc startup > > The modern 3.9.1 source does not match for the last. Note the > "Out" vs. "In" below ("svnlite status" does not show my source > as different in this area): > > uint64_t getPPC64TocBase() { > // The TOC consists of sections .got, .toc, .tocbss, .plt in that order. The > // TOC starts where the first of these sections starts. We always create a > // .got when we see a relocation that uses it, so for us the start is always > // the .got. > uint64_t TocVA = Out::Got->getVA(); > > // Per the ppc64-elf-linux ABI, The TOC base is TOC value plus 0x8000 > // thus permitting a full 64 Kbytes segment. Note that the glibc startup > // code (crt1.o) assumes that you can get from the TOC base to the > // start of the .toc section with only a single (signed) 16-bit relocation. > return TocVA + PPC64TocOffset; > } > > [Also the "// TOC . . ." comment is at line 1005 (given the prior > GotRel vs. PltRel split into separate lines).] > > Which should I use?: In vs. Out > > > would make any difference? It's not correct but might shed some light on what needs to be done > > if I am right. > > Separately if I understand the change you are picking out which section > is first of .got, .toc, .tocbss, .plt (.got.plt as well?). But for the > order of things that would still make the .ctors, .dtors, .jcr, .dynamic, > and .data sections as being inside the TOC and taking TOC address range > space: > > 0x0000000010010560 - 0x00000000100105c0 is .plt <<<<<===== NOTE!!!! > 0x0000000010020000 - 0x0000000010020010 is .ctors > 0x0000000010020010 - 0x0000000010020020 is .dtors > 0x0000000010020020 - 0x0000000010020028 is .jcr > 0x0000000010020028 - 0x0000000010020138 is .dynamic > 0x0000000010020138 - 0x0000000010020138 is .got <<<<<===== NOTE!!!! > 0x0000000010030000 - 0x0000000010030019 is .data > 0x0000000010030020 - 0x0000000010030050 is .got.plt <<<<<===== NOTE!!!! > 0x0000000010030050 - 0x00000000100300a0 is .toc <<<<<===== NOTE!!!! > > Is that expected/desired/allowed? > > > Could you explore this please? > > After you report for sure for In vs. Out I'll take a stab > at it. > > === > Mark Millard > markmi at dsl-only.net