m68k: Update elf_machine_load_address for static PIE
Commit Message
When --enable-static-pie is used to configure glibc, we need to use
_dl_relocate_static_pie to compute load address in static PIE.
OK for master?
* sysdeps/m68k/dl-machine.h (elf_machine_load_address): Use
_dl_relocate_static_pie instead of _dl_start to compute load
address in static PIE. Return 0 if _DYNAMIC is undefined for
static executable.
---
sysdeps/m68k/dl-machine.h | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On Sep 29 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> * sysdeps/m68k/dl-machine.h (elf_machine_load_address): Use
> _dl_relocate_static_pie instead of _dl_start to compute load
> address in static PIE. Return 0 if _DYNAMIC is undefined for
> static executable.
Ok.
Andreas.
@@ -51,9 +51,18 @@ static inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr addr;
+#ifdef SHARED
asm (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t"
"sub.l _dl_start@GOT.w(%%a5), %0"
: "=a" (addr));
+#else
+ extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+ if (!_DYNAMIC)
+ return 0;
+ asm (PCREL_OP ("lea", "_dl_relocate_static_pie", "%0", "%0", "%%pc") "\n\t"
+ "sub.l _dl_relocate_static_pie@GOT.w(%%a5), %0"
+ : "=a" (addr));
+#endif
return addr;
}