Index: pkg/uclibc/lib/contrib/uclibc/ldso/ldso/arm/dl-sysdep.h =================================================================== --- pkg/uclibc/lib/contrib/uclibc/ldso/ldso/arm/dl-sysdep.h (revision 38) +++ pkg/uclibc/lib/contrib/uclibc/ldso/ldso/arm/dl-sysdep.h (working copy) @@ -110,7 +110,7 @@ return dynamic; } -extern void __dl_start __asm__ ("_dl_start"); +extern /*void*/ int __dl_start __asm__ ("_dl_start"); /* Return the run-time load address of the shared object. */ static __always_inline Elf32_Addr __attribute__ ((unused)) Index: pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S =================================================================== --- pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S (revision 38) +++ pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S (working copy) @@ -16,6 +16,7 @@ #else .align 2 .arm + .L1: ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} #endif .size .L1, .-.L1 @@ -32,6 +33,7 @@ #else .align 2 .arm + .L2: ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} #endif .size .L2,.-.L2 Index: pkg/uclibc/lib/uclibc/ARCH-arm/include/bits/uClibc_config.h =================================================================== --- pkg/uclibc/lib/uclibc/ARCH-arm/include/bits/uClibc_config.h (revision 38) +++ pkg/uclibc/lib/uclibc/ARCH-arm/include/bits/uClibc_config.h (working copy) @@ -100,8 +100,8 @@ #ifndef L4_MINIMAL_LIBC #define __UCLIBC_HAS_THREADS__ 1 #define __LINUXTHREADS_OLD__ 1 -#undef __UCLIBC_HAS_TLS__ -#undef __UCLIBC_HAS_THREADS_NATIVE__ +#define __UCLIBC_HAS_TLS__ 1 +#define __UCLIBC_HAS_THREADS_NATIVE__ 1 #define __UCLIBC_HAS_LFS__ 1 #define __UCLIBC_STATIC_LDCONFIG__ 1 Index: pkg/uclibc/lib/uclibc/ARCH-arm/aeabi_read_tp_generic.c =================================================================== --- pkg/uclibc/lib/uclibc/ARCH-arm/aeabi_read_tp_generic.c (revision 0) +++ pkg/uclibc/lib/uclibc/ARCH-arm/aeabi_read_tp_generic.c (revision 0) @@ -0,0 +1,15 @@ + +#include +#include + +#ifdef NOT_IN_libc +#define HIDDEN __attribute__((visibility("hidden"),nothrow)) +#else +#define HIDDEN __attribute__((nothrow)) +#endif + +unsigned long HIDDEN __aeabi_read_tp(void); +unsigned long HIDDEN __aeabi_read_tp(void) +{ + return l4_utcb_tcr()->user[0] + TLS_PRE_TCB_SIZE; +} Index: pkg/uclibc/lib/uclibc/Make.rules =================================================================== --- pkg/uclibc/lib/uclibc/Make.rules (revision 38) +++ pkg/uclibc/lib/uclibc/Make.rules (working copy) @@ -1,11 +1,12 @@ # vi:ft=make LIBCSRC_DIR ?= $(SRC_DIR) -DEFINES += -DL4_THREAD_SAFE -DL4_NO_RTTI=1 -DEFINES_x86-l4f += -DUSE_TLS=1 -TARGET := libuc_c.a libuc_c.so libuc_c_nonshared.p.a -PC_FILENAME := libc -PC_LIBS := -luc_c +DEFINES += -DL4_THREAD_SAFE -DL4_NO_RTTI=1 +DEFINES_x86-l4f += -DUSE_TLS=1 +DEFINES_arm-l4f += -DUSE_TLS=1 +TARGET := libuc_c.a libuc_c.so libuc_c_nonshared.p.a +PC_FILENAME := libc +PC_LIBS := -luc_c include $(LIBCSRC_DIR)/make_vars.mk include $(LIBCSRC_DIR)/make_rules.mk @@ -39,16 +40,25 @@ SRC_CC_libuc_c.so += $(UCLIBC_SRC_CC) $(UCLIBC_SRC_CC_libuc_c.so) SRC_CC_libuc_c.a += $(UCLIBC_SRC_CC) $(UCLIBC_SRC_CC_libuc_c.a) -SRC_C_libuc_c.so += $(PTHOBJ_PFX)/forward.c $(PTHOBJ_PFX)/libc_pthread_init.c -SRC_CC_libuc_c.a_x86-l4f += $(PTHOBJ_PFX)/sysdeps/generic/libc-tls.cc -SRC_C_libuc_c.a_x86-l4f += $(PTHOBJ_PFX)/sysdeps/generic/dl-tls.c +SRC_C_libuc_c.so += $(PTHOBJ_PFX)/forward.c $(PTHOBJ_PFX)/libc_pthread_init.c +SRC_CC_libuc_c.a_x86-l4f += $(PTHOBJ_PFX)/sysdeps/generic/libc-tls.cc +SRC_C_libuc_c.a_x86-l4f += $(PTHOBJ_PFX)/sysdeps/generic/dl-tls.c +SRC_CC_libuc_c.a_arm-l4f += $(PTHOBJ_PFX)/sysdeps/generic/libc-tls.cc +SRC_C_libuc_c.a_arm-l4f += $(PTHOBJ_PFX)/sysdeps/generic/dl-tls.c SRC_C_libuc_c_nonshared.p.a += libc/stdlib/atexit.c SRC_C_libuc_c.a += libc/stdlib/atexit.c SRC_C_libuc_c.so_x86-l4f += libc/misc/pthread/tsd.c SRC_C_libuc_c.a_x86-l4f += libc/misc/pthread/tsd.c +SRC_C_libuc_c.so_arm-l4f += libc/misc/pthread/tsd.c +SRC_C_libuc_c.a_arm-l4f += libc/misc/pthread/tsd.c +SRC_C_libuc_c.so_arm-l4f += ARCH-arm/aeabi_read_tp_generic.c +SRC_C_libuc_c.a_arm-l4f += ARCH-arm/aeabi_read_tp_generic.c +#SRC_S_libuc_c.so_arm-l4f += ARCH-arm/aeabi_read_tp-v6p.S +#SRC_S_libuc_c.a_arm-l4f += ARCH-arm/aeabi_read_tp-v6p.S + CXXFLAGS_$(PTHOBJ_PFX)/sysdeps/generic/libc-tls.cc += -fno-rtti -fno-exceptions CPPFLAGS_libc-tls.cc += $(LDSO_INC) Index: pkg/uclibc/lib/libpthread/src/Makefile =================================================================== --- pkg/uclibc/lib/libpthread/src/Makefile (revision 38) +++ pkg/uclibc/lib/libpthread/src/Makefile (working copy) @@ -41,7 +41,8 @@ -D_GNU_SOURCE=1 -D__NO_WEAK_PTHREAD_ALIASES=1 \ -D_LIBC=1 -DIS_IN_libpthread=1 -DNOT_IN_libc=1 -DEFINES_x86-l4f := -DUSE___THREAD=1 +DEFINES_x86-l4f := -DUSE___THREAD=1 +DEFINES_arm-l4f := -DUSE___THREAD=1 CFLAGS += -include $(CONTRIBDIR)/include/libc-symbols.h CXXFLAGS += -include $(CONTRIBDIR)/include/libc-symbols.h Index: pkg/uclibc/lib/libpthread/src/sysdeps/arm/tls.h =================================================================== --- pkg/uclibc/lib/libpthread/src/sysdeps/arm/tls.h (revision 38) +++ pkg/uclibc/lib/libpthread/src/sysdeps/arm/tls.h (working copy) @@ -19,7 +19,6 @@ #ifndef _TLS_H #define _TLS_H 1 -#if defined USE_TLS && USE_TLS //l4 #ifndef __ASSEMBLER__ # include @@ -53,7 +52,7 @@ #ifndef __ASSEMBLER__ /* Get system call information. */ -# include +//# include /* The TP points to the start of the thread blocks. */ # define TLS_DTV_AT_TP 1 @@ -64,7 +63,7 @@ typedef struct { dtv_t *dtv; - void *private; + void *private_data; } tcbhead_t; /* This is the size of the initial TCB. */ @@ -77,7 +76,7 @@ # define TLS_TCB_SIZE sizeof (tcbhead_t) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE sizeof (struct pthread) +# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN 16 @@ -98,20 +97,29 @@ /* Code to initially initialize the thread pointer. This might need special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ -# define TLS_INIT_TP(tcbp, secondcall) \ +# define TLS_INIT_TP_ORIG(tcbp, secondcall) \ ({ INTERNAL_SYSCALL_DECL (err); \ long result_var; \ result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (tcbp)); \ INTERNAL_SYSCALL_ERROR_P (result_var, err) \ ? "unknown error" : NULL; }) +# define TLS_INIT_TP_v6(tcbp, secondcall) \ + ({ asm volatile ("mcr p15, 0, %0, c13, c0, 2" : : "r" (tcbp)); NULL; }) + +# define TLS_INIT_TP_generic(tcbp, secondcall) \ + ({ l4_utcb_tcr()->user[0] = (l4_addr_t)tcbp - TLS_PRE_TCB_SIZE; NULL; }) + +# define TLS_INIT_TP(tcbp, secondcall) \ + TLS_INIT_TP_generic(tcbp, secondcall) + /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ (((tcbhead_t *) __builtin_thread_pointer ())->dtv) /* Return the thread descriptor for the current thread. */ # define THREAD_SELF \ - ((struct pthread *)__builtin_thread_pointer () - 1) + ((struct _pthread_descr_struct *)__builtin_thread_pointer () - 1) /* Magic for libthread_db to know how to do THREAD_SELF. */ # define DB_THREAD_SELF \ @@ -155,5 +163,4 @@ GL(dl_wait_lookup_done) () #endif /* __ASSEMBLER__ */ -#endif #endif /* tls.h */ Index: pkg/uclibc/lib/libpthread/src/sysdeps/generic/libc-tls.cc =================================================================== --- pkg/uclibc/lib/libpthread/src/sysdeps/generic/libc-tls.cc (revision 38) +++ pkg/uclibc/lib/libpthread/src/sysdeps/generic/libc-tls.cc (working copy) @@ -176,7 +176,8 @@ tcb_offset = roundup (tcbsize, align ?: 1); tlsblock = __libc_alloc_initial_tls(tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); - tlsblock += TLS_PRE_TCB_SIZE; + //tlsblock += TLS_PRE_TCB_SIZE; + tlsblock = (char *)tlsblock + TLS_PRE_TCB_SIZE; # else /* In case a model with a different layout for the TCB and DTV is defined add another #elif here and in the following #ifs. */ Index: pkg/uclibc/lib/libpthread/src/manager.cc =================================================================== --- pkg/uclibc/lib/libpthread/src/manager.cc (revision 38) +++ pkg/uclibc/lib/libpthread/src/manager.cc (working copy) @@ -116,8 +116,14 @@ struct pthread_request request; #ifdef USE_TLS +# if defined(TLS_TCB_AT_TP) TLS_INIT_TP(self, 0); +#elif defined(TLS_DTV_AT_TP) + TLS_INIT_TP(self + 1, 0); +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" #endif +#endif /* If we have special thread_self processing, initialize it. */ #ifdef INIT_THREAD_SELF INIT_THREAD_SELF(self, 1); @@ -251,8 +257,14 @@ { pthread_descr self = (pthread_descr) arg; #ifdef USE_TLS +# if defined(TLS_TCB_AT_TP) TLS_INIT_TP(self, 0); +#elif defined(TLS_DTV_AT_TP) + TLS_INIT_TP(self + 1, 0); +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" #endif +#endif #ifdef NOT_FOR_L4 struct pthread_request request;