m68k: Update elf_machine_load_address for static PIE

Message ID 20170929213522.GP2482@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Sept. 29, 2017, 9:35 p.m. UTC
  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

Andreas Schwab Oct. 20, 2017, 8:19 a.m. UTC | #1
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.
  

Patch

diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index fd8fb00103..a9a19009e5 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -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;
 }