Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 2021 11:14:56 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 17ef58221ccc - stable/13 - libc dl_iterate_phdr(): dlpi_tls_data is wrong
Message-ID:  <202104231114.13NBEung013009@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=17ef58221ccc39072eea716d4d68b2f0335ef3b6

commit 17ef58221ccc39072eea716d4d68b2f0335ef3b6
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-04-05 03:38:07 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-04-23 11:14:07 +0000

    libc dl_iterate_phdr(): dlpi_tls_data is wrong
    
    (cherry picked from commit dbd2053026a6af28adb1aa32e27603ae0d4efea6)
---
 lib/libc/gen/dlfcn.c | 6 ++++--
 1 file 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104231114.13NBEung013009>