From d5d0918f796c0d1d602a9f2de502afe5b47eaf88 Mon Sep 17 00:00:00 2001 From: dhy308 Date: Tue, 29 Nov 2022 15:09:11 +0800 Subject: [PATCH] Save the tsd in new pthread stack. Issue: I63P90 Test: libc-test pass Signed-off-by: dhy308 --- porting/linux/user/ldso/dynlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/porting/linux/user/ldso/dynlink.c b/porting/linux/user/ldso/dynlink.c index b0b9688e..c72da6e2 100644 --- a/porting/linux/user/ldso/dynlink.c +++ b/porting/linux/user/ldso/dynlink.c @@ -2842,9 +2842,12 @@ void __dls3(size_t *sp, size_t *auxv) /* Actual copying to new TLS needs to happen after relocations, * since the TLS images might have contained relocated addresses. */ if (initial_tls != builtin_tls) { - if (__init_tp(__copy_tls(initial_tls)) < 0) { + pthread_t self = __pthread_self(); + pthread_t td = __copy_tls(initial_tls); + if (__init_tp(td) < 0) { a_crash(); } + td->tsd = self->tsd; } else { size_t tmp_tls_size = libc.tls_size; pthread_t self = __pthread_self(); -- GitLab