2008-03-28 Maxim Kuvyrkov <maxim@codesourcery.com>
authorAndreas Schwab <schwab@suse.de>
Fri, 28 Mar 2008 12:23:06 +0000 (12:23 +0000)
committerAndreas Schwab <schwab@suse.de>
Fri, 28 Mar 2008 12:23:06 +0000 (12:23 +0000)
Explicitly get address of _DYNAMIC.
* sysdeps/m68k/dl-machine.h (elf_machine_dynamic): Retrieve _DYNAMIC
from GOT instead of assuming value at GOT pointer.

ChangeLog.m68k
sysdeps/m68k/dl-machine.h

index 33323c6..b6aa316 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-28  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       Explicitly get address of _DYNAMIC.
+       * sysdeps/m68k/dl-machine.h (elf_machine_dynamic): Retrieve _DYNAMIC
+       from GOT instead of assuming value at GOT pointer.
+
 2007-10-22  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * sysdeps/unix/sysv/linux/m68k/bits/fcntl.h (F_DUPFD_CLOEXEC): Define.
index fad1ef9..08a4396 100644 (file)
@@ -33,14 +33,16 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
 }
 
 
-/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
-   first element of the GOT.  This must be inlined in a function which
-   uses global data.  */
+/* Return the link-time address of _DYNAMIC.
+   This must be inlined in a function which uses global data.  */
 static inline Elf32_Addr
 elf_machine_dynamic (void)
 {
-  register Elf32_Addr *got asm ("%a5");
-  return *got;
+  Elf32_Addr addr;
+
+  asm ("move.l _DYNAMIC@GOT.w(%%a5), %0"
+       : "=a" (addr));
+  return addr;
 }