Port-powerpc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
TLS usage fix
Hi all,
the attached patch fixes the TLS issues discussed earlier.
Joerg
Index: lib/libc/tls/tls.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/tls/tls.c,v
retrieving revision 1.5
diff -u -p -r1.5 tls.c
--- lib/libc/tls/tls.c 18 Mar 2011 14:56:01 -0000 1.5
+++ lib/libc/tls/tls.c 6 Apr 2011 23:34:50 -0000
@@ -154,8 +154,13 @@ __libc_static_tls_setup(void)
{
struct tls_tcb *tcb;
- if (&rtld_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL) {
+#ifdef __powerpc__
+ /* Older versions of crt0.o clobber %r2, undo the damage. */
+ _lwp_setprivate(_lwp_getprivate());
+#endif
return;
+ }
dl_iterate_phdr(__libc_static_tls_setup_cb, NULL);
Index: sys/arch/powerpc/include/mcontext.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/arch/powerpc/include/mcontext.h,v
retrieving revision 1.13
diff -u -p -r1.13 mcontext.h
--- sys/arch/powerpc/include/mcontext.h 12 Mar 2011 07:38:16 -0000 1.13
+++ sys/arch/powerpc/include/mcontext.h 6 Apr 2011 23:33:22 -0000
@@ -150,12 +150,10 @@ __lwp_gettcb_fast(void)
static __inline void
__lwp_settcb(void *__tcb)
{
- __asm __volatile(
- "addi %%r2,%[__tcb],%[__offset]@l"
- :
- : [__tcb] "r" (__tcb),
- [__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
+ unsigned char *__tcbp = (unsigned char *)__tcb;
+ _lwp_setprivate(__tcbp + TLS_TP_OFFSET + sizeof(struct tls_tcb));
}
+
#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
#endif /* !_POWERPC_MCONTEXT_H_ */
Home |
Main Index |
Thread Index |
Old Index