Re: powerpc ld.lld fix

2020-11-01 Thread Mark Kettenis
> From: Philip Guenther 
> Date: Sun, 1 Nov 2020 05:06:13 -0900
> 
> Makes sense.  This code is just the space reservation, the relocation
> generation or whatever fills them in is suppressed already, yes?  Assuming
> so, r+

Yes.  The slots are reserved such that ld.so can fill them in.

> On Sat, Oct 31, 2020 at 2:46 PM Mark Kettenis 
> wrote:
> 
>  > Date: Sat, 10 Oct 2020 23:19:19 +0200 (CEST)
>  > From: Mark Kettenis 
>  > 
>  > On powerpc with the secure-plt ABI we need a .got section, even if the
>  > _GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
>  > the first three entries of the GOT are used by the dynamic linker.
>  > 
>  > With this fix I can build executables of all flavours (including
>  > -static/-nopie).
> 
>  Turns out that adding these GOT entries when using "ld -r" is a bad
>  idea.  Dif below fixes that.
> 
>  ok?
> 
>  Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
>  ===
>  RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
>  retrieving revision 1.2
>  diff -u -p -r1.2 SyntheticSections.cpp
>  --- gnu/llvm/lld/ELF/SyntheticSections.cpp  11 Oct 2020 13:10:13
>  -  1.2
>  +++ gnu/llvm/lld/ELF/SyntheticSections.cpp  31 Oct 2020 23:37:11
>  -
>  @@ -604,7 +604,7 @@ GotSection::GotSection()
> // ElfSym::globalOffsetTable.
> if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
>   numEntries += target->gotHeaderEntriesNum;
>  -  else if (config->emachine == EM_PPC)
>  +  else if (config->emachine == EM_PPC && !config->relocatable)
>   numEntries += target->gotHeaderEntriesNum;
>   }



Re: powerpc ld.lld fix

2020-11-01 Thread Philip Guenther
Makes sense.  This code is just the space reservation, the relocation
generation or whatever fills them in is suppressed already, yes?  Assuming
so, r+

On Sat, Oct 31, 2020 at 2:46 PM Mark Kettenis 
wrote:

> > Date: Sat, 10 Oct 2020 23:19:19 +0200 (CEST)
> > From: Mark Kettenis 
> >
> > On powerpc with the secure-plt ABI we need a .got section, even if the
> > _GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
> > the first three entries of the GOT are used by the dynamic linker.
> >
> > With this fix I can build executables of all flavours (including
> > -static/-nopie).
>
> Turns out that adding these GOT entries when using "ld -r" is a bad
> idea.  Dif below fixes that.
>
> ok?
>
>
> Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
> ===
> RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
> retrieving revision 1.2
> diff -u -p -r1.2 SyntheticSections.cpp
> --- gnu/llvm/lld/ELF/SyntheticSections.cpp  11 Oct 2020 13:10:13
> -  1.2
> +++ gnu/llvm/lld/ELF/SyntheticSections.cpp  31 Oct 2020 23:37:11 -
> @@ -604,7 +604,7 @@ GotSection::GotSection()
>// ElfSym::globalOffsetTable.
>if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
>  numEntries += target->gotHeaderEntriesNum;
> -  else if (config->emachine == EM_PPC)
> +  else if (config->emachine == EM_PPC && !config->relocatable)
>  numEntries += target->gotHeaderEntriesNum;
>  }
>
>
>


Re: powerpc ld.lld fix

2020-10-31 Thread Mark Kettenis
> Date: Sat, 10 Oct 2020 23:19:19 +0200 (CEST)
> From: Mark Kettenis 
> 
> On powerpc with the secure-plt ABI we need a .got section, even if the
> _GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
> the first three entries of the GOT are used by the dynamic linker.
> 
> With this fix I can build executables of all flavours (including
> -static/-nopie).

Turns out that adding these GOT entries when using "ld -r" is a bad
idea.  Dif below fixes that.

ok?


Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
===
RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
retrieving revision 1.2
diff -u -p -r1.2 SyntheticSections.cpp
--- gnu/llvm/lld/ELF/SyntheticSections.cpp  11 Oct 2020 13:10:13 -  
1.2
+++ gnu/llvm/lld/ELF/SyntheticSections.cpp  31 Oct 2020 23:37:11 -
@@ -604,7 +604,7 @@ GotSection::GotSection()
   // ElfSym::globalOffsetTable.
   if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
 numEntries += target->gotHeaderEntriesNum;
-  else if (config->emachine == EM_PPC)
+  else if (config->emachine == EM_PPC && !config->relocatable)
 numEntries += target->gotHeaderEntriesNum;
 }
 



powerpc ld.lld fix

2020-10-10 Thread Mark Kettenis
On powerpc with the secure-plt ABI we need a .got section, even if the
_GLOBAL_OFFSET_TABLE_ symbol isn't referenced.  This is needed because
the first three entries of the GOT are used by the dynamic linker.

With this fix I can build executables of all flavours (including
-static/-nopie).

ok?


Index: gnu/llvm/lld/ELF/SyntheticSections.cpp
===
RCS file: /cvs/src/gnu/llvm/lld/ELF/SyntheticSections.cpp,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 SyntheticSections.cpp
--- gnu/llvm/lld/ELF/SyntheticSections.cpp  3 Aug 2020 14:32:29 -   
1.1.1.1
+++ gnu/llvm/lld/ELF/SyntheticSections.cpp  10 Oct 2020 21:13:59 -
@@ -604,6 +604,8 @@ GotSection::GotSection()
   // ElfSym::globalOffsetTable.
   if (ElfSym::globalOffsetTable && !target->gotBaseSymInGotPlt)
 numEntries += target->gotHeaderEntriesNum;
+  else if (config->emachine == EM_PPC)
+numEntries += target->gotHeaderEntriesNum;
 }
 
 void GotSection::addEntry(Symbol ) {