svn commit: r203947 - head/libexec/rtld-elf

Marcel Moolenaar marcel at FreeBSD.org
Tue Feb 16 02:48:11 UTC 2010


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 *


More information about the svn-src-all mailing list