[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] [PATCH][m68k] Fix dynamic linker not to make assumptions about GOT pointer



Hello,

While developing multi-GOT support for m68k I noted that m68k dynamic linker assumes that GOT pointer always points to the first GOT entry. With multiple GOTs in the binary GOT pointer will no longer point to the 3 special entries at the start of the global GOT.

The solution is to explicitly put _DYNAMIC to usual GOT slot and retrieve it at run-time.

OK for trunk, 2.5, 2.6 and 2.7 branches?


Thanks,

Maxim Kuvyrkov


2008-01-17  Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>

	Explicitly get address of _DYNAMIC.

	* sysdeps/m68k/dl-machine.h (elf_machine_dynamic): Retrieve _DYNAMIC
	from GOT instead of assuming value at GOT pointer.
--- ports/sysdeps/m68k/dl-machine.h	(revision 191524)
+++ ports/sysdeps/m68k/dl-machine.h	(revision 191525)
@@ -33,14 +33,16 @@ elf_machine_matches_host (const Elf32_Eh
 }
 
 
-/* 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@xxxxx(%%a5), %0"
+       : "=a" (addr));
+  return addr;
 }