From owner-svn-src-head@FreeBSD.ORG Fri Feb 10 06:42:51 2012 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 432CE1065673; Fri, 10 Feb 2012 06:42:51 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26F228FC1B; Fri, 10 Feb 2012 06:42:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1A6gpKP058159; Fri, 10 Feb 2012 06:42:51 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1A6goSd058155; Fri, 10 Feb 2012 06:42:50 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201202100642.q1A6goSd058155@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Fri, 10 Feb 2012 06:42:50 +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: r231347 - in 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: Fri, 10 Feb 2012 06:42:51 -0000 Author: gonzo Date: Fri Feb 10 06:42:50 2012 New Revision: 231347 URL: http://svn.freebsd.org/changeset/base/231347 Log: Switch MIPS TLS implementation to Variant I Modified: head/libexec/rtld-elf/mips/reloc.c head/libexec/rtld-elf/mips/rtld_machdep.h head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/mips/reloc.c ============================================================================== --- head/libexec/rtld-elf/mips/reloc.c Fri Feb 10 06:42:00 2012 (r231346) +++ head/libexec/rtld-elf/mips/reloc.c Fri Feb 10 06:42:50 2012 (r231347) @@ -39,8 +39,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "debug.h" #include "rtld.h" +#include "rtld_printf.h" #ifdef __mips_n64 #define GOT1_MASK 0x8000000000000000UL @@ -528,11 +531,32 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr void allocate_initial_tls(Obj_Entry *objs) { + char *tls; + /* + * Fix the size of the static TLS block by using the maximum + * offset allocated so far and adding a bit for dynamic modules to + * use. + */ + tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA; + + tls = ((char *) allocate_tls(objs, NULL, TLS_TCB_SIZE, 8) + + TLS_TP_OFFSET + TLS_TCB_SIZE); + + sysarch(MIPS_SET_TLS, tls); + rtld_printf("allocate_initial_tls -> %p(%p)\n", tls, tls - TLS_TP_OFFSET - TLS_TCB_SIZE); } void * __tls_get_addr(tls_index* ti) { - return (NULL); + Elf_Addr** tls; + char *p; + + sysarch(MIPS_GET_TLS, &tls); + + p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tls - TLS_TP_OFFSET + - TLS_TCB_SIZE), ti->ti_module, ti->ti_offset); + + return (p + TLS_DTV_OFFSET); } Modified: head/libexec/rtld-elf/mips/rtld_machdep.h ============================================================================== --- head/libexec/rtld-elf/mips/rtld_machdep.h Fri Feb 10 06:42:00 2012 (r231346) +++ head/libexec/rtld-elf/mips/rtld_machdep.h Fri Feb 10 06:42:50 2012 (r231347) @@ -47,21 +47,32 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, #define call_initfini_pointer(obj, target) \ (((InitFunc)(target))()) - + +/* + * TLS + */ + +#define TLS_TP_OFFSET 0x7000 +#define TLS_DTV_OFFSET 0x8000 +#ifdef __mips_n64 +#define TLS_TCB_SIZE 16 +#else +#define TLS_TCB_SIZE 8 +#endif + typedef struct { unsigned long ti_module; unsigned long ti_offset; } tls_index; #define round(size, align) \ - (((size) + (align) - 1) & ~((align) - 1)) + (((size) + (align) - 1) & ~((align) - 1)) #define calculate_first_tls_offset(size, align) \ - round(size, align) + round(TLS_TCB_SIZE, align) #define calculate_tls_offset(prev_offset, prev_size, size, align) \ - round(prev_offset + prev_size, align) + round(prev_offset + prev_size, align) #define calculate_tls_end(off, size) ((off) + (size)) - - + /* * Lazy binding entry point, called via PLT. */ Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Fri Feb 10 06:42:00 2012 (r231346) +++ head/libexec/rtld-elf/rtld.c Fri Feb 10 06:42:50 2012 (r231347) @@ -3543,7 +3543,7 @@ tls_get_addr_common(Elf_Addr** dtvp, int /* XXX not sure what variants to use for arm. */ -#if defined(__ia64__) || defined(__powerpc__) +#if defined(__ia64__) || defined(__powerpc__) || defined(__mips__) /* * Allocate Static TLS using the Variant I method. @@ -3625,7 +3625,7 @@ free_tls(void *tcb, size_t tcbsize, size #endif #if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \ - defined(__arm__) || defined(__mips__) + defined(__arm__) /* * Allocate Static TLS using the Variant II method.