This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] m68k: Update elf_machine_load_address for static PIE
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 29 Sep 2017 14:35:22 -0700
- Subject: [PATCH] m68k: Update elf_machine_load_address for static PIE
- Authentication-results: sourceware.org; auth=none
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(+)
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;
}
--
2.13.6