From owner-freebsd-bugs@freebsd.org Mon Apr 5 03:13:20 2021 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F077B5BF887 for ; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4FDG2861DQz4s6R for ; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id CDE9B5BF1E5; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD9E15BF886 for ; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FDG285DX9z4rkX for ; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A593A1145D for ; Mon, 5 Apr 2021 03:13:20 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1353DK9b079718 for ; Mon, 5 Apr 2021 03:13:20 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1353DK3a079717 for bugs@FreeBSD.org; Mon, 5 Apr 2021 03:13:20 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f 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 Date: Mon, 05 Apr 2021 03:13:20 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: kib@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2021 03:13:21 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254774 --- Comment #3 from Konstantin Belousov --- (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.=