Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Oct 2006 02:29:23 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 107476 for review
Message-ID:  <200610080229.k982TNqc033030@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107476

Change 107476 by kmacy@kmacy_storage:sun4v_work_stable on 2006/10/08 02:28:26

	fix TLS initialization for dynamic and static linking
	reviewed by: marcel and jmg

Affected files ...

.. //depot/projects/kmacy_sun4v_stable/src/lib/csu/sparc64/crt1.c#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/lib/libc/gen/tls.c#4 edit
.. //depot/projects/kmacy_sun4v_stable/src/lib/libc/sparc64/gen/_set_tp.c#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/libexec/rtld-elf/sparc64/reloc.c#2 edit

Differences ...

==== //depot/projects/kmacy_sun4v_stable/src/lib/csu/sparc64/crt1.c#2 (text+ko) ====

@@ -98,13 +98,12 @@
 				__progname = s + 1;
 	}
 
-	__sparc_utrap_setup();
-
 	if (&_DYNAMIC != NULL)
 		atexit(cleanup);
-	else
+	else {
+		__sparc_utrap_setup();
 		_init_tls();
-
+	}
 #ifdef GCRT
 	atexit(_mcleanup);
 #endif

==== //depot/projects/kmacy_sun4v_stable/src/lib/libc/gen/tls.c#4 (text+ko) ====

@@ -58,6 +58,15 @@
 void *__libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign);
 void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
 
+#if defined(__ia64__) || defined(__amd64__)
+#define TLS_TCB_ALIGN 16
+#elif defined(__powerpc__) || defined(__i386__) || defined(__arm__) || \
+    defined(__sparc64__)
+#define TLS_TCB_ALIGN sizeof(void *)
+#else
+#error TLS_TCB_ALIGN undefined for target architecture
+#endif
+
 #if defined(__ia64__) || defined(__powerpc__)
 #define TLS_VARIANT_I
 #endif
@@ -299,7 +308,7 @@
 		}
 	}
 
-	tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, 1);
+	tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
 
 	_set_tp(tls);
 #endif

==== //depot/projects/kmacy_sun4v_stable/src/lib/libc/sparc64/gen/_set_tp.c#2 (text+ko) ====

@@ -29,7 +29,6 @@
 void
 _set_tp(void *tpval)
 {
-	register void* tp __asm__("%g7");
 
-	tp = tpval;
+	__asm __volatile("mov %0, %%g7" : : "r" (tpval));
 }

==== //depot/projects/kmacy_sun4v_stable/src/libexec/rtld-elf/sparc64/reloc.c#2 (text+ko) ====

@@ -723,7 +723,7 @@
 void
 allocate_initial_tls(Obj_Entry *objs)
 {
-    register Elf_Addr** tp __asm__("%g7");
+    Elf_Addr* tpval;
 
     /*
      * Fix the size of the static TLS block by using the maximum
@@ -731,7 +731,8 @@
      * use.
      */
     tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
-    tp = allocate_tls(objs, NULL, 3*sizeof(Elf_Addr), sizeof(Elf_Addr));
+    tpval = allocate_tls(objs, NULL, 3*sizeof(Elf_Addr), sizeof(Elf_Addr));
+    __asm __volatile("mov %0, %%g7" : : "r" (tpval));
 }
 
 void *__tls_get_addr(tls_index *ti)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610080229.k982TNqc033030>