about summary refs log tree commit diff
path: root/sysdeps/i386/dl-machine.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/dl-machine.h')
-rw-r--r--sysdeps/i386/dl-machine.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 2e17eba5c0..242c692c17 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -54,8 +54,15 @@ elf_machine_load_address (void)
   /* Compute the difference between the runtime address of _DYNAMIC as seen
      by a GOTOFF reference, and the link-time address found in the special
      unrelocated first GOT entry.  */
-  extern Elf32_Dyn bygotoff[] asm ("_DYNAMIC") attribute_hidden;
-  return (Elf32_Addr) &bygotoff - elf_machine_dynamic ();
+#ifndef SHARED
+  extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+  if (!_DYNAMIC)
+    return 0;
+#endif
+  /* The address of dynamic must be taken as non-weak to avoid dynamic
+     relocation.  */
+  extern Elf32_Dyn dynamic[] asm ("_DYNAMIC") attribute_hidden;
+  return (Elf32_Addr) &dynamic - elf_machine_dynamic ();
 }
 
 /* Set up the loaded object described by L so its unrelocated PLT