From owner-svn-src-head@FreeBSD.ORG Thu Jul 29 20:18:52 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE084106566B; Thu, 29 Jul 2010 20:18:52 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D2B48FC1F; Thu, 29 Jul 2010 20:18:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6TKIqbs044671; Thu, 29 Jul 2010 20:18:52 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6TKIqwH044668; Thu, 29 Jul 2010 20:18:52 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201007292018.o6TKIqwH044668@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 29 Jul 2010 20:18:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210629 - head/libexec/rtld-elf/mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2010 20:18:52 -0000 Author: jchandra Date: Thu Jul 29 20:18:52 2010 New Revision: 210629 URL: http://svn.freebsd.org/changeset/base/210629 Log: 64 bit support for MIPS rtld. - Handle the case where pltgot[1] is 64 bit. - use 'ifdef __mips_n64' instead of 'ELFSIZE == 64' to detect 64 bit compile. Modified: head/libexec/rtld-elf/mips/reloc.c head/libexec/rtld-elf/mips/rtld_start.S Modified: head/libexec/rtld-elf/mips/reloc.c ============================================================================== --- head/libexec/rtld-elf/mips/reloc.c Thu Jul 29 20:16:12 2010 (r210628) +++ head/libexec/rtld-elf/mips/reloc.c Thu Jul 29 20:18:52 2010 (r210629) @@ -41,13 +41,19 @@ __FBSDID("$FreeBSD$"); #include "debug.h" #include "rtld.h" +#ifdef __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 +70,7 @@ void _rtld_relocate_nonplt_self(Elf_Dyn * It is possible for the compiler to emit relocations for unaligned data. * We handle this situation with these inlines. */ -#if ELFSIZE == 64 +#ifdef __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 +96,7 @@ load_ptr(void *where, size_t len) Elf_Sxword val; if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) { -#if ELFSIZE == 64 +#ifdef __mips_n64 if (len == sizeof(Elf_Sxword)) return *(Elf_Sxword *)where; #endif @@ -111,7 +117,7 @@ static __inline void store_ptr(void *where, Elf_Sxword val, size_t len) { if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) { -#if ELFSIZE == 64 +#ifdef __mips_n64 if (len == sizeof(Elf_Sxword)) { *(Elf_Sxword *)where = val; return; @@ -165,7 +171,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp } } - 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 +203,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp : sizeof(Elf_Sword); Elf_Sxword old = load_ptr(where, rlen); Elf_Sxword val = old; -#if ELFSIZE == 64 +#ifdef __mips_n64 assert(r_type == R_TYPE(REL32) || r_type == (R_TYPE(REL32)|(R_TYPE(64) << 8))); #endif @@ -272,7 +278,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 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; Modified: head/libexec/rtld-elf/mips/rtld_start.S ============================================================================== --- head/libexec/rtld-elf/mips/rtld_start.S Thu Jul 29 20:16:12 2010 (r210628) +++ head/libexec/rtld-elf/mips/rtld_start.S Thu Jul 29 20:18:52 2010 (r210629) @@ -130,11 +130,12 @@ _rtld_bind_start: /* .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 */ -#endif and a0, a0, 0x7fffffff +#endif move a1, t8 /* symbol index */ PTR_LA t9, _C_LABEL(_mips_rtld_bind)