This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
[PATCH][m68k] Fix dynamic linker not to make assumptions about GOT pointer
- From: Maxim Kuvyrkov <maxim at codesourcery dot com>
- To: libc-ports at sourceware dot org
- Cc: Andreas Schwab <schwab at suse dot de>
- Date: Thu, 27 Mar 2008 17:44:54 +0300
- Subject: [PATCH][m68k] Fix dynamic linker not to make assumptions about GOT pointer
Hello Andreas,
I'm about to submit multi-GOT support for m68k to binutils. While
developing this support 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?
Thanks,
Maxim Kuvyrkov
2008-01-17 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.
--- 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@GOT.w(%%a5), %0"
+ : "=a" (addr));
+ return addr;
}