Date: Mon, 05 Apr 2021 03:13:20 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 254774] [rtld] dl_iterate_phdr: dlpi_tls_data should be the iterated module's TLS image instead of TLS initialization image Message-ID: <bug-254774-227-DUT8g3hypn@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-254774-227@https.bugs.freebsd.org/bugzilla/> References: <bug-254774-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254774 --- Comment #3 from Konstantin Belousov <kib@FreeBSD.org> --- (In reply to Brandon Bergren from comment #2) The drv reallocation should not affect dl_iterate_phdr() result. That said, for dl_iterate_phdr() for dynamic binary, the fix is indeed simp= le: diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 733c3c80b70f..0ded117b1019 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3909,13 +3909,16 @@ dlinfo(void *handle, int request, void *p) static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_inf= o) { + tls_index ti; phdr_info->dlpi_addr =3D (Elf_Addr)obj->relocbase; phdr_info->dlpi_name =3D obj->path; phdr_info->dlpi_phdr =3D obj->phdr; phdr_info->dlpi_phnum =3D obj->phsize / sizeof(obj->phdr[0]); phdr_info->dlpi_tls_modid =3D obj->tlsindex; - phdr_info->dlpi_tls_data =3D obj->tlsinit; + ti.ti_module =3D obj->tlsindex; + ti.ti_offset =3D 0; + phdr_info->dlpi_tls_data =3D __tls_get_addr(&ti); phdr_info->dlpi_adds =3D obj_loads; phdr_info->dlpi_subs =3D obj_loads - obj_count; } But for static binary where libc TLS implementation is used, we do not prov= ide working __tls_get_addr(). Do you need this for static binaries, or it would be only the consistency that is hurt if libc implementation is provided lat= er? --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-254774-227-DUT8g3hypn>