diff options
author | Jessica Clarke <jrtc27@FreeBSD.org> | 2025-05-29 16:06:54 +0000 |
---|---|---|
committer | Jessica Clarke <jrtc27@FreeBSD.org> | 2025-05-29 16:06:54 +0000 |
commit | 250b2eda0acc44cf882d5ea8fcf28125e7501719 (patch) | |
tree | f71e302f27f7d1d54c9dadb065557dfeea7592bf /lib/libc/gen/elf_utils.c | |
parent | 960f40b892cf15961f059f509990652555db7b4f (diff) |
Diffstat (limited to 'lib/libc/gen/elf_utils.c')
-rw-r--r-- | lib/libc/gen/elf_utils.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c index 5b87e012d0eb..330aa8f17f7e 100644 --- a/lib/libc/gen/elf_utils.c +++ b/lib/libc/gen/elf_utils.c @@ -31,11 +31,14 @@ #include <sys/mman.h> #include <sys/resource.h> #include <sys/sysctl.h> + +#include <machine/tls.h> + #include <link.h> #include <stddef.h> #include <string.h> + #include "libc_private.h" -#include "static_tls.h" void __pthread_map_stacks_exec(void); void __pthread_distribute_static_tls(size_t, void *, size_t, size_t); @@ -107,11 +110,15 @@ void __libc_distribute_static_tls(size_t offset, void *src, size_t len, size_t total_len) { - uintptr_t tlsbase; + char *tlsbase; - tlsbase = _libc_get_static_tls_base(offset); - memcpy((void *)tlsbase, src, len); - memset((char *)tlsbase + len, 0, total_len - len); +#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 |