PowerPC64 DT_RELR

H.J. Lu hjl.tools@gmail.com
Sat Jan 22 13:04:37 GMT 2022


On Fri, Jan 21, 2022 at 8:28 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Jan 19, 2022 at 02:56:07PM -0800, H.J. Lu wrote:
> > Does PowerPC64 support static PIE?  If yes, it may need more linker changes.
>
> No.  There are things in glibc that need fixing.  We have small-model
> toc relocs being used in assembly.  This results in the linker
> refusing to do toc/got indirect to toc pointer relative code
> optimisation for those sequences.  So we get toc/got entries with
> relative relocations that result in segfaults when static-pie binaries
> are trying to relocate themselves.
>
> What were the linker changes you thought would be necessary?
>

The main issue is symbols generated by linker and linker scripts.
I enabled DT_RELR in glibc and binutls by default

$ readelf -r elf/ld.so
...
Relocation section '.relr.dyn' at offset 0xd78 contains 6 entries:
  142 offsets
0000000000033000
...

diff --git a/ld/ldmain.c b/ld/ldmain.c
index ea72b14a301..6ed71a74d87 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -359,6 +359,7 @@ main (int argc, char **argv)
 #endif
   link_info.start_stop_gc = false;
   link_info.start_stop_visibility = STV_PROTECTED;
+  link_info.enable_dt_relr = 1;

   ldfile_add_arch ("");
   emulation = get_emulation (argc, argv);

These triggered many run-time and link-time failures.

-- 
H.J.


More information about the Binutils mailing list