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).
> 
> 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<ELF64BE>::Got->getVA();
> +  uint64_t TocVA = In<ELF64BE>::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<ELF64BE>::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

_______________________________________________
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"

Reply via email to