From owner-svn-src-head@FreeBSD.ORG Tue Feb 16 02:48:11 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 993C81065670; Tue, 16 Feb 2010 02:48:11 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89A998FC19; Tue, 16 Feb 2010 02:48:11 +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 o1G2mBJ3090588; Tue, 16 Feb 2010 02:48:11 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1G2mBDG090586; Tue, 16 Feb 2010 02:48:11 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201002160248.o1G2mBDG090586@svn.freebsd.org> From: Marcel Moolenaar Date: Tue, 16 Feb 2010 02:48:11 +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: r203947 - head/libexec/rtld-elf 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: Tue, 16 Feb 2010 02:48:11 -0000 Author: marcel Date: Tue Feb 16 02:48:11 2010 New Revision: 203947 URL: http://svn.freebsd.org/changeset/base/203947 Log: Improve TLS variant I: o Use obj->tlsinitsize to determine whether there's initialized data. o If obj->tlssize > obj->tlsinitsize, then bzero uninitialized data. o Don't exclude variant I from the work-around in free_tls_offset(). Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue Feb 16 02:22:59 2010 (r203946) +++ head/libexec/rtld-elf/rtld.c Tue Feb 16 02:48:11 2010 (r203947) @@ -3151,13 +3151,13 @@ allocate_tls(Obj_Entry *objs, void *oldt dtv[1] = tls_max_index; for (obj = objs; obj; obj = obj->next) { - if (obj->tlsoffset) { + if (obj->tlsoffset > 0) { addr = (Elf_Addr)tls + obj->tlsoffset; - memset((void*) (addr + obj->tlsinitsize), - 0, obj->tlssize - obj->tlsinitsize); - if (obj->tlsinit) - memcpy((void*) addr, obj->tlsinit, - obj->tlsinitsize); + if (obj->tlsinitsize > 0) + memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize); + if (obj->tlssize > obj->tlsinitsize) + memset((void*) (addr + obj->tlsinitsize), 0, + obj->tlssize - obj->tlsinitsize); dtv[obj->tlsindex + 1] = addr; } } @@ -3357,21 +3357,18 @@ allocate_tls_offset(Obj_Entry *obj) void free_tls_offset(Obj_Entry *obj) { -#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \ - defined(__arm__) || defined(__mips__) + /* * If we were the last thing to allocate out of the static TLS * block, we give our space back to the 'allocator'. This is a * simplistic workaround to allow libGL.so.1 to be loaded and - * unloaded multiple times. We only handle the Variant II - * mechanism for now - this really needs a proper allocator. + * unloaded multiple times. */ if (calculate_tls_end(obj->tlsoffset, obj->tlssize) == calculate_tls_end(tls_last_offset, tls_last_size)) { tls_last_offset -= obj->tlssize; tls_last_size = 0; } -#endif } void *