Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jan 2017 13:53:14 -0800
From:      Mark Millard <markmi@dsl-only.net>
To:        Roman Divacky <rdivacky@vlakno.cz>
Cc:        Ed Maste <emaste@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
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:  <237EB920-0795-4B18-94D4-2EAC0FC76F01@dsl-only.net>
In-Reply-To: <20170117195424.GA89237@vlakno.cz>
References:  <EF97071B-AE4A-4520-A997-52249B8DAB5A@dsl-only.net> <20170112192223.GA49469@vlakno.cz> <932E3C38-B226-4BF1-B587-5A2D5EA19300@dsl-only.net> <F3923971-6FDF-4269-A7CA-3428249A128F@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> <F38C9607-5AB9-4BF9-BEC1-88EA2518A9CE@dsl-only.net> <27422F1B-6906-4D37-860A-D1BC8DC83BBF@dsl-only.net> <20170117195424.GA89237@vlakno.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2017-Jan-17, at 11:54 AM, Roman Divacky <rdivacky at vlakno.cz> =
wrote:

. . .
> I wonder if it doesnt work because of my first patch (the one to turn =
GOT
> reloc into PLT one).
>=20
> LLD understands that we use GOT as TOC (which was true before my =
patch),
> I wonder if something like this:
>=20
> ndex: tools/lld/ELF/Target.cpp
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- tools/lld/ELF/Target.cpp	(revision 292071)
> +++ tools/lld/ELF/Target.cpp	(working copy)
> @@ -1070,7 +1070,8 @@
> }
>=20
> PPC64TargetInfo::PPC64TargetInfo() {
> -  PltRel =3D GotRel =3D R_PPC64_GLOB_DAT;
> +  GotRel =3D R_PPC64_GLOB_DAT;
> +  PltRel =3D R_PPC64_JMP_SLOT;
>   RelativeRel =3D R_PPC64_RELATIVE;
>   GotEntrySize =3D 8;
>   GotPltEntrySize =3D 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 =3D In<ELF64BE>::Got->getVA();
> +  uint64_t TocVA =3D In<ELF64BE>::Plt->getVA();
>=20
>   // 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 =3D Out<ELF64BE>::Got->getVA();
     =20
  // 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          =
<<<<<=3D=3D=3D=3D=3D NOTE!!!!
	0x0000000010020000 - 0x0000000010020010 is .ctors
	0x0000000010020010 - 0x0000000010020020 is .dtors
	0x0000000010020020 - 0x0000000010020028 is .jcr
	0x0000000010020028 - 0x0000000010020138 is .dynamic
	0x0000000010020138 - 0x0000000010020138 is .got          =
<<<<<=3D=3D=3D=3D=3D NOTE!!!!
	0x0000000010030000 - 0x0000000010030019 is .data
	0x0000000010030020 - 0x0000000010030050 is .got.plt      =
<<<<<=3D=3D=3D=3D=3D NOTE!!!!
	0x0000000010030050 - 0x00000000100300a0 is .toc          =
<<<<<=3D=3D=3D=3D=3D 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.

=3D=3D=3D
Mark Millard
markmi at dsl-only.net




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?237EB920-0795-4B18-94D4-2EAC0FC76F01>