git: 2c444fdb0c75 - main - libc,libthr: Remove __pthread_distribute_static_tls

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Thu, 10 Jul 2025 19:06:08 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=2c444fdb0c75fbc73a0ac78d0ecbaef4e1e8baf8

commit 2c444fdb0c75fbc73a0ac78d0ecbaef4e1e8baf8
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2025-07-10 19:00:28 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2025-07-10 19:00:28 +0000

    libc,libthr: Remove __pthread_distribute_static_tls
    
    This private API is no longer used by rtld-elf so can be removed.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D50921
---
 lib/libc/gen/Symbol.map               |  1 -
 lib/libc/gen/elf_utils.c              | 26 ------------------------
 lib/libc/gen/libc_interposing_table.c |  1 -
 lib/libc/include/libc_private.h       |  4 +---
 lib/libthr/pthread.map                |  1 -
 lib/libthr/thread/thr_list.c          | 38 -----------------------------------
 lib/libthr/thread/thr_private.h       |  2 --
 7 files changed, 1 insertion(+), 72 deletions(-)

diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index c2020ac3d8d2..26f638568efc 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -596,7 +596,6 @@ FBSDprivate_1.0 {
 
 	__libc_tcdrain;
 
-	__pthread_distribute_static_tls;
 	__pthread_map_stacks_exec;
 	__fillcontextx;
 	__fillcontextx2;
diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c
index 330aa8f17f7e..3714a0dc42b5 100644
--- a/lib/libc/gen/elf_utils.c
+++ b/lib/libc/gen/elf_utils.c
@@ -41,7 +41,6 @@
 #include "libc_private.h"
 
 void __pthread_map_stacks_exec(void);
-void __pthread_distribute_static_tls(size_t, void *, size_t, size_t);
 
 int
 __elf_phdr_match_addr(struct dl_phdr_info *phdr_info, void *addr)
@@ -105,28 +104,3 @@ __pthread_map_stacks_exec(void)
 
 	((void (*)(void))__libc_interposing[INTERPOS_map_stacks_exec])();
 }
-
-void
-__libc_distribute_static_tls(size_t offset, void *src, size_t len,
-    size_t total_len)
-{
-	char *tlsbase;
-
-#ifdef TLS_VARIANT_I
-	tlsbase = (char *)_tcb_get() + offset;
-#else
-	tlsbase = (char *)_tcb_get() - offset;
-#endif
-	memcpy(tlsbase, src, len);
-	memset(tlsbase + len, 0, total_len - len);
-}
-
-#pragma weak __pthread_distribute_static_tls
-void
-__pthread_distribute_static_tls(size_t offset, void *src, size_t len,
-    size_t total_len)
-{
-
-	((void (*)(size_t, void *, size_t, size_t))__libc_interposing[
-	    INTERPOS_distribute_static_tls])(offset, src, len, total_len);
-}
diff --git a/lib/libc/gen/libc_interposing_table.c b/lib/libc/gen/libc_interposing_table.c
index 8eae6c7f5d95..025a67ac3eac 100644
--- a/lib/libc/gen/libc_interposing_table.c
+++ b/lib/libc/gen/libc_interposing_table.c
@@ -42,7 +42,6 @@ interpos_func_t __libc_interposing[INTERPOS_MAX] = {
 	SLOT(spinlock, __libc_spinlock_stub),
 	SLOT(spinunlock, __libc_spinunlock_stub),
 	SLOT(map_stacks_exec, __libc_map_stacks_exec),
-	SLOT(distribute_static_tls, __libc_distribute_static_tls),
 	SLOT(uexterr_gettext, __libc_uexterr_gettext),
 };
 #undef SLOT
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index 1bc22f3931a5..db4cbc32be35 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -249,7 +249,7 @@ enum {
 	INTERPOS_map_stacks_exec,
 	INTERPOS_fdatasync,
 	INTERPOS_clock_nanosleep,
-	INTERPOS_distribute_static_tls,
+	INTERPOS__reserved0, /* was distribute_static_tls */
 	INTERPOS_pdfork,
 	INTERPOS_uexterr_gettext,
 	INTERPOS_MAX
@@ -361,8 +361,6 @@ struct dl_phdr_info;
 int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
 void __init_elf_aux_vector(void);
 void __libc_map_stacks_exec(void);
-void __libc_distribute_static_tls(__size_t, void *, __size_t, __size_t);
-__uintptr_t __libc_static_tls_base(__size_t);
 
 void	_pthread_cancel_enter(int);
 void	_pthread_cancel_leave(int);
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index 1c8dde03367b..3a5353a32dc3 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -136,7 +136,6 @@ FBSDprivate_1.0 {
 	__pthread_mutex_lock;
 	__pthread_mutex_timedlock;
 	__pthread_mutex_trylock;
-	__pthread_distribute_static_tls;
 	_pthread_atfork;
 	_pthread_barrier_destroy;
 	_pthread_barrier_init;
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c
index 820766f6f5e0..cbf16179f619 100644
--- a/lib/libthr/thread/thr_list.c
+++ b/lib/libthr/thread/thr_list.c
@@ -363,41 +363,3 @@ _thr_find_thread(struct pthread *curthread, struct pthread *thread,
 	THREAD_LIST_UNLOCK(curthread);
 	return (ret);
 }
-
-static void
-thr_distribute_static_tls(char *tlsbase, void *src, size_t len,
-    size_t total_len)
-{
-
-	memcpy(tlsbase, src, len);
-	memset(tlsbase + len, 0, total_len - len);
-}
-
-void
-__pthread_distribute_static_tls(size_t offset, void *src, size_t len,
-    size_t total_len)
-{
-	struct pthread *curthread, *thrd;
-	char *tlsbase;
-
-	if (!_thr_is_inited()) {
-#ifdef TLS_VARIANT_I
-		tlsbase = (char *)_tcb_get() + offset;
-#else
-		tlsbase = (char *)_tcb_get() - offset;
-#endif
-		thr_distribute_static_tls(tlsbase, src, len, total_len);
-		return;
-	}
-	curthread = _get_curthread();
-	THREAD_LIST_RDLOCK(curthread);
-	TAILQ_FOREACH(thrd, &_thread_list, tle) {
-#ifdef TLS_VARIANT_I
-		tlsbase = (char *)thrd->tcb + offset;
-#else
-		tlsbase = (char *)thrd->tcb - offset;
-#endif
-		thr_distribute_static_tls(tlsbase, src, len, total_len);
-	}
-	THREAD_LIST_UNLOCK(curthread);
-}
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index bca890829057..d7b889930365 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -986,8 +986,6 @@ void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
 void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
 void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
 void _thr_stack_fix_protection(struct pthread *thrd);
-void __pthread_distribute_static_tls(size_t offset, void *src, size_t len,
-    size_t total_len);
 
 int *__error_threaded(void) __hidden;
 void __thr_interpose_libc(void) __hidden;