From 8ec6b3707b403fff21a21195ebc4b0da9b7890a8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 28 Sep 2017 14:55:18 -0700 Subject: sh: Update elf_machine_load_address for static PIE When --enable-static-pie is used to configure glibc, we need to use _dl_relocate_static_pie to compute load address in static PIE. * sysdeps/sh/dl-machine.h (elf_machine_load_address): Use _dl_relocate_static_pie instead of _dl_start to compute load address in static PIE. --- sysdeps/sh/dl-machine.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 3f157c9a7d..d28b0fdd45 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -50,6 +50,7 @@ static inline Elf32_Addr __attribute__ ((unused)) elf_machine_load_address (void) { Elf32_Addr addr; +#ifdef SHARED asm ("mov.l 1f,r0\n\ mov.l 3f,r2\n\ add r12,r2\n\ @@ -61,6 +62,19 @@ elf_machine_load_address (void) 3: .long _dl_start@GOTOFF\n\ 2: mov r2,%0" : "=r" (addr) : : "r0", "r1", "r2"); +#else + asm ("mov.l 1f,r0\n\ + mov.l 3f,r2\n\ + add r12,r2\n\ + mov.l @(r0,r12),r0\n\ + bra 2f\n\ + sub r0,r2\n\ + .align 2\n\ + 1: .long _dl_relocate_static_pie@GOT\n\ + 3: .long _dl_relocate_static_pie@GOTOFF\n\ + 2: mov r2,%0" + : "=r" (addr) : : "r0", "r1", "r2"); +#endif return addr; } -- cgit v1.2.1