]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
arm: Update elf_machine_load_address for static PIE
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 29 Sep 2017 23:23:18 +0000 (16:23 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 29 Sep 2017 23:23:33 +0000 (16:23 -0700)
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/arm/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.

ChangeLog
sysdeps/arm/dl-machine.h

index efd567ce34bc7bc667edc1fca66988dc58ba7e92..b6dbff0624bc472b580b58a7264e0b81eea2f018 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-09-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * sysdeps/arm/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.
+
 2017-09-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/mips/dl-machine.h (elf_machine_dynamic): Return 0 if
index 7d733f2b1c25d81bf7644e1c3b902b0fddf31d2b..efe2e1b3a3a0431ef3be571f66dd6b3b3ac5d1e6 100644 (file)
@@ -53,10 +53,20 @@ elf_machine_dynamic (void)
 static inline Elf32_Addr __attribute__ ((unused))
 elf_machine_load_address (void)
 {
+  Elf32_Addr pcrel_addr;
+#ifdef SHARED
   extern Elf32_Addr __dl_start (void *) asm ("_dl_start");
   Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
-  Elf32_Addr pcrel_addr;
   asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
+#else
+  extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+  if (!_DYNAMIC)
+    return 0;
+  extern Elf32_Addr __dl_relocate_static_pie (void *)
+    asm ("_dl_relocate_static_pie") attribute_hidden;
+  Elf32_Addr got_addr = (Elf32_Addr) &__dl_relocate_static_pie;
+  asm ("adr %0, _dl_relocate_static_pie" : "=r" (pcrel_addr));
+#endif
 #ifdef __thumb__
   /* Clear the low bit of the function address.