diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/internal/pthread_impl.h | 1 | ||||
-rw-r--r-- | src/ldso/aarch64/tlsdesc.s | 59 | ||||
-rw-r--r-- | src/ldso/arm/tlsdesc.S | 19 | ||||
-rw-r--r-- | src/ldso/i386/tlsdesc.s | 8 | ||||
-rw-r--r-- | src/ldso/x86_64/tlsdesc.s | 21 | ||||
-rw-r--r-- | src/thread/__tls_get_addr.c | 7 | ||||
-rw-r--r-- | src/thread/i386/tls.s | 8 | ||||
-rw-r--r-- | src/thread/pthread_create.c | 2 |
8 files changed, 7 insertions, 118 deletions
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h index d5d969ec..de089967 100644 --- a/src/internal/pthread_impl.h +++ b/src/internal/pthread_impl.h @@ -130,6 +130,7 @@ hidden int __init_tp(void *); hidden void *__copy_tls(unsigned char *); hidden void __reset_tls(); +hidden void __dl_prepare_for_threads(void); hidden void __dl_thread_cleanup(void); hidden void __testcancel(); hidden void __do_cleanup_push(struct __ptcb *); diff --git a/src/ldso/aarch64/tlsdesc.s b/src/ldso/aarch64/tlsdesc.s index 8e4004d7..c91baa45 100644 --- a/src/ldso/aarch64/tlsdesc.s +++ b/src/ldso/aarch64/tlsdesc.s @@ -29,67 +29,10 @@ __tlsdesc_dynamic: ldr x0,[x0,#8] // p ldr x2,[x0] // p->modidx ldr x3,[x1,#-8] // dtv - ldr x4,[x3] // dtv[0] - cmp x2,x4 - b.hi 1f ldr x2,[x3,x2,lsl #3] // dtv[p->modidx] ldr x0,[x0,#8] // p->off add x0,x0,x2 -2: sub x0,x0,x1 + sub x0,x0,x1 ldp x3,x4,[sp,#16] ldp x1,x2,[sp],#32 ret - - // save all registers __tls_get_new may clobber - // update sp in two steps because offset must be in [-512,509] -1: stp x29,x30,[sp,#-160]! - stp x5,x6,[sp,#16] - stp x7,x8,[sp,#32] - stp x9,x10,[sp,#48] - stp x11,x12,[sp,#64] - stp x13,x14,[sp,#80] - stp x15,x16,[sp,#96] - stp x17,x18,[sp,#112] - stp q0,q1,[sp,#128] - stp q2,q3,[sp,#-480]! - stp q4,q5,[sp,#32] - stp q6,q7,[sp,#64] - stp q8,q9,[sp,#96] - stp q10,q11,[sp,#128] - stp q12,q13,[sp,#160] - stp q14,q15,[sp,#192] - stp q16,q17,[sp,#224] - stp q18,q19,[sp,#256] - stp q20,q21,[sp,#288] - stp q22,q23,[sp,#320] - stp q24,q25,[sp,#352] - stp q26,q27,[sp,#384] - stp q28,q29,[sp,#416] - stp q30,q31,[sp,#448] - bl __tls_get_new - mrs x1,tpidr_el0 - ldp q4,q5,[sp,#32] - ldp q6,q7,[sp,#64] - ldp q8,q9,[sp,#96] - ldp q10,q11,[sp,#128] - ldp q12,q13,[sp,#160] - ldp q14,q15,[sp,#192] - ldp q16,q17,[sp,#224] - ldp q18,q19,[sp,#256] - ldp q20,q21,[sp,#288] - ldp q22,q23,[sp,#320] - ldp q24,q25,[sp,#352] - ldp q26,q27,[sp,#384] - ldp q28,q29,[sp,#416] - ldp q30,q31,[sp,#448] - ldp q2,q3,[sp],#480 - ldp x5,x6,[sp,#16] - ldp x7,x8,[sp,#32] - ldp x9,x10,[sp,#48] - ldp x11,x12,[sp,#64] - ldp x13,x14,[sp,#80] - ldp x15,x16,[sp,#96] - ldp x17,x18,[sp,#112] - ldp q0,q1,[sp,#128] - ldp x29,x30,[sp],#160 - b 2b diff --git a/src/ldso/arm/tlsdesc.S b/src/ldso/arm/tlsdesc.S index 4e67c3e2..455eac1d 100644 --- a/src/ldso/arm/tlsdesc.S +++ b/src/ldso/arm/tlsdesc.S @@ -35,13 +35,9 @@ __tlsdesc_dynamic: #endif #endif ldr r3,[r0,#-4] // r3 = dtv - ldr ip,[r3] // ip = dtv slot count - cmp r1,ip - bhi 3f ldr ip,[r3,r1,LSL #2] sub r0,ip,r0 add r0,r0,r2 // r0 = r3[r1]-r0+r2 -4: #if __ARM_ARCH >= 5 pop {r2,r3,ip,pc} #else @@ -49,21 +45,6 @@ __tlsdesc_dynamic: bx lr #endif -3: -#if __ARM_PCS_VFP || !__SOFTFP__ - .fpu vfp - vpush {d0-d7} -#endif - push {r0-r3} - add r0,sp,#4 - bl __tls_get_new - pop {r1-r3,ip} -#if __ARM_PCS_VFP || !__SOFTFP__ - vpop {d0-d7} -#endif - sub r0,r0,r1 // r0 = retval-tp - b 4b - #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 #else diff --git a/src/ldso/i386/tlsdesc.s b/src/ldso/i386/tlsdesc.s index 4a553bce..a5c0100c 100644 --- a/src/ldso/i386/tlsdesc.s +++ b/src/ldso/i386/tlsdesc.s @@ -17,15 +17,9 @@ __tlsdesc_dynamic: mov %gs:4,%edx push %ecx mov (%eax),%ecx - cmp %ecx,(%edx) - jc 1f mov 4(%eax),%eax add (%edx,%ecx,4),%eax -2: pop %ecx + pop %ecx sub %gs:0,%eax pop %edx ret -1: push %eax - call __tls_get_new - pop %ecx - jmp 2b diff --git a/src/ldso/x86_64/tlsdesc.s b/src/ldso/x86_64/tlsdesc.s index 8238c3eb..0151d15c 100644 --- a/src/ldso/x86_64/tlsdesc.s +++ b/src/ldso/x86_64/tlsdesc.s @@ -17,28 +17,9 @@ __tlsdesc_dynamic: mov %fs:8,%rdx push %rcx mov (%rax),%rcx - cmp %rcx,(%rdx) - jc 1f mov 8(%rax),%rax add (%rdx,%rcx,8),%rax -2: pop %rcx + pop %rcx sub %fs:0,%rax pop %rdx ret -1: push %rdi - push %rdi - push %rsi - push %r8 - push %r9 - push %r10 - push %r11 - mov %rax,%rdi - call __tls_get_new - pop %r11 - pop %r10 - pop %r9 - pop %r8 - pop %rsi - pop %rdi - pop %rdi - jmp 2b diff --git a/src/thread/__tls_get_addr.c b/src/thread/__tls_get_addr.c index d7afdabd..19524fe0 100644 --- a/src/thread/__tls_get_addr.c +++ b/src/thread/__tls_get_addr.c @@ -1,12 +1,7 @@ -#include <stddef.h> #include "pthread_impl.h" void *__tls_get_addr(tls_mod_off_t *v) { pthread_t self = __pthread_self(); - if (v[0] <= self->dtv[0]) - return (void *)(self->dtv[v[0]] + v[1]); - return __tls_get_new(v); + return (void *)(self->dtv[v[0]] + v[1]); } - -weak_alias(__tls_get_addr, __tls_get_new); diff --git a/src/thread/i386/tls.s b/src/thread/i386/tls.s index 76d5d462..6e4c4cb9 100644 --- a/src/thread/i386/tls.s +++ b/src/thread/i386/tls.s @@ -4,14 +4,6 @@ ___tls_get_addr: mov %gs:4,%edx mov (%eax),%ecx - cmp %ecx,(%edx) - jc 1f mov 4(%eax),%eax add (%edx,%ecx,4),%eax ret -1: push %eax -.weak __tls_get_new -.hidden __tls_get_new - call __tls_get_new - pop %edx - ret diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index cec82157..0142b347 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -15,6 +15,7 @@ weak_alias(dummy_0, __release_ptc); weak_alias(dummy_0, __pthread_tsd_run_dtors); weak_alias(dummy_0, __do_orphaned_stdio_locks); weak_alias(dummy_0, __dl_thread_cleanup); +weak_alias(dummy_0, __dl_prepare_for_threads); void __tl_lock(void) { @@ -235,6 +236,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att init_file_lock(__stderr_used); __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, _NSIG/8); self->tsd = (void **)__pthread_tsd_main; + __dl_prepare_for_threads(); libc.threaded = 1; } if (attrp && !c11) attr = *attrp; |