aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-04-05 03:38:07 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-04-09 20:46:24 +0000
commitdbd2053026a6af28adb1aa32e27603ae0d4efea6 (patch)
treef53f2a4195712a753a0c3dadf745d6a67efd3fab /lib/libc
parentca46b5698e8ac38ab45d781d592700be59e7de97 (diff)
downloadsrc-dbd2053026a6af28adb1aa32e27603ae0d4efea6.tar.gz
src-dbd2053026a6af28adb1aa32e27603ae0d4efea6.zip
libc dl_iterate_phdr(): dlpi_tls_data is wrong
This is the same change as d36d681615170590, but for libc static implementaion of dl_iterate_phdr(). Reported by: emacsray@gmail.com PR: 254774 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29623
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/dlfcn.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index 16afdb6bf5d1..337ad48fd691 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -196,8 +196,6 @@ dl_init_phdr_info(void)
for (i = 0; i < phdr_info.dlpi_phnum; i++) {
if (phdr_info.dlpi_phdr[i].p_type == PT_TLS) {
phdr_info.dlpi_tls_modid = 1;
- phdr_info.dlpi_tls_data =
- (void*)phdr_info.dlpi_phdr[i].p_vaddr;
}
}
phdr_info.dlpi_adds = 1;
@@ -210,13 +208,17 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
void *data __unused)
{
#ifndef IN_LIBDL
+ tls_index ti;
int ret;
__init_elf_aux_vector();
if (__elf_aux_vector == NULL)
return (1);
_once(&dl_phdr_info_once, dl_init_phdr_info);
+ ti.ti_module = 1;
+ ti.ti_offset = 0;
mutex_lock(&dl_phdr_info_lock);
+ phdr_info.dlpi_tls_data = __tls_get_addr(&ti);
ret = callback(&phdr_info, sizeof(phdr_info), data);
mutex_unlock(&dl_phdr_info_lock);
return (ret);