Date: Thu, 29 Jul 2010 05:02:44 +0530 From: "Jayachandran C." <c.jayachandran@gmail.com> To: freebsd-mips@freebsd.org Subject: Re: Support for 64bit userspace. Message-ID: <AANLkTim738fcSO%2BL70BLoabOareLhSES2nAFe6pKoMrk@mail.gmail.com> In-Reply-To: <AANLkTikAjRTMn0m1DemdmUXKMydmyQPxij%2BN=1d9L2=y@mail.gmail.com> References: <AANLkTikAjRTMn0m1DemdmUXKMydmyQPxij%2BN=1d9L2=y@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On Wed, Jul 28, 2010 at 2:04 AM, Jayachandran C.
<c.jayachandran@gmail.com> wrote:
> Here's my initial work to get 64bit user space. With this set of
> changes, I can boot to the single user shell with n64 /sbin/init and
> /bin/sh. There are still issues to fix, and the dynamic loader is
> still not working, but I think this would be a good time to get some
> initial feedback.
The dynamic loader seems to work after some straight-forward changes.
The only change is that the got[1] entry needs to be 64-bit. The
changes are attached.
There is still an occasional kernel panic in n64, which I need to
track down - but I think the changes other than pmap.c/pmap64.c are
ready for check in. I would like some feedback on pmap64.c I can
clean it up for check in.
Thanks,
JC.
[-- Attachment #2 --]
Index: libexec/rtld-elf/mips/rtld_start.S
===================================================================
--- libexec/rtld-elf/mips/rtld_start.S (revision 210534)
+++ libexec/rtld-elf/mips/rtld_start.S (working copy)
@@ -130,11 +130,12 @@
/* .got = $gp - 0x7ff0 */
/* Simple math as you can see. */
#if defined(__mips_n64)
- ld a0, 8(a0) /* object = pltgot[1] & 0x7fffffff */
+ ld a0, 8(a0) /* object = pltgot[1] */
+ and a0, a0, 0x7fffffffffffffff
#else
lw a0, 4(a0) /* object = pltgot[1] & 0x7fffffff */
+ and a0, a0, 0x7fffffff
#endif
- and a0, a0, 0x7fffffff
move a1, t8 /* symbol index */
PTR_LA t9, _C_LABEL(_mips_rtld_bind)
Index: libexec/rtld-elf/mips/reloc.c
===================================================================
--- libexec/rtld-elf/mips/reloc.c (revision 210534)
+++ libexec/rtld-elf/mips/reloc.c (working copy)
@@ -41,13 +41,20 @@
#include "debug.h"
#include "rtld.h"
+
+#if defined(__mips_n64)
+#define GOT1_MASK 0x8000000000000000UL
+#else
+#define GOT1_MASK 0x80000000UL
+#endif
+
void
init_pltgot(Obj_Entry *obj)
{
if (obj->pltgot != NULL) {
obj->pltgot[0] = (Elf_Addr) &_rtld_bind_start;
- /* XXX only if obj->pltgot[1] & 0x80000000 ?? */
- obj->pltgot[1] |= (Elf_Addr) obj;
+ if (obj->pltgot[1] & 0x80000000)
+ obj->pltgot[1] = (Elf_Addr) obj | GOT1_MASK;
}
}
@@ -64,7 +71,7 @@
* It is possible for the compiler to emit relocations for unaligned data.
* We handle this situation with these inlines.
*/
-#if ELFSIZE == 64
+#if defined(__mips_n64)
/*
* ELF64 MIPS encodes the relocs uniquely. The first 32-bits of info contain
* the symbol index. The top 32-bits contain three relocation types encoded
@@ -90,7 +97,7 @@
Elf_Sxword val;
if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) {
-#if ELFSIZE == 64
+#if defined(__mips_n64)
if (len == sizeof(Elf_Sxword))
return *(Elf_Sxword *)where;
#endif
@@ -111,7 +118,7 @@
store_ptr(void *where, Elf_Sxword val, size_t len)
{
if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) {
-#if ELFSIZE == 64
+#if defined(__mips_n64)
if (len == sizeof(Elf_Sxword)) {
*(Elf_Sxword *)where = val;
return;
@@ -165,7 +172,7 @@
}
}
- i = (got[1] & 0x80000000) ? 2 : 1;
+ i = (got[1] & GOT1_MASK) ? 2 : 1;
/* Relocate the local GOT entries */
got += i;
for (; i < local_gotno; i++) {
@@ -197,7 +204,7 @@
: sizeof(Elf_Sword);
Elf_Sxword old = load_ptr(where, rlen);
Elf_Sxword val = old;
-#if ELFSIZE == 64
+#if defined(__mips_n64)
assert(r_type == R_TYPE(REL32)
|| r_type == (R_TYPE(REL32)|(R_TYPE(64) << 8)));
#endif
@@ -272,7 +279,7 @@
dbg("%s: broken=%d", obj->path, broken);
#endif
- i = (got[1] & 0x80000000) ? 2 : 1;
+ i = (got[1] & GOT1_MASK) ? 2 : 1;
/* Relocate the local GOT entries */
got += i;
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTim738fcSO%2BL70BLoabOareLhSES2nAFe6pKoMrk>
