From nobody Sun Aug 13 04:37:56 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RNlBs0T6tz4mSP7; Sun, 13 Aug 2023 04:37:57 +0000 (UTC) (envelope-from git@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 4RNlBr44bHz3YTZ; Sun, 13 Aug 2023 04:37:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691901476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hU3sv8Ea8PamUnLAvVkq3yhizqFyh3eVcVg7X6re4Uc=; b=b4kIA+MGObAvkWE6x0TG4DXpEUIxsy9JiCVYxFUX6TRmsnmvBkeJPK5OraS+xFTxR0sazM SuXok91WvVySFl7r3mid+bM6Ht0UK5Vtknv+Bd8NH8Z1GFKLmPJ2lHhPcgWl4Xdkm9p6as 3ahcKFND5I9+WSGerQb73Jup0/5JHpn1GlEaPepPNJTvvul6GLJcRYhSKa5bNq0MI3Ybkr QRzlM3paBqHcJA+QQwIYGxf5zVe8o0/hwkF/eCHy+Vt0GiVnQ9rmm6N4Vo6d92l/R/vtXm 2076OpJggHE4FEeqN3bbbaaT6dwacVhI0O83j85NTVsB2UHF0r/bDrG1PZeXsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691901476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hU3sv8Ea8PamUnLAvVkq3yhizqFyh3eVcVg7X6re4Uc=; b=Tkyzwrv6MlVWzpIvAgC0eBtzZD4r551J2QKkjhHdRrM7GkWxL7vYTawkLYkXcdRwrQCp/Y kcBe9tCOLZFx71zgdrALekJ43ERp27AaUhEUY2+vA5GIXQTmbCVfY5r6SB3nBQoX4yBZ3y N8WEujCNkiiSfsApFn/eWLVf+YC+lNCk08ppTXRrhDRdhgKFvhrTQ4CvxUp3iNXmKn9qin 4FtPcD7AmLrE4YvaemSyyzAyG/pB7ws1ze6N2sWPPHQkg/ERaCsZtmXgWKmOg0u760DHtc li24gEj5z3zozTuCN5XAZxBMapV/JN0dqi1qADZ9/AIloGKQ1TRhEu81ib6xJA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691901476; a=rsa-sha256; cv=none; b=quaOhGNH9VJUT3mQx1H6e2q/5qXWDhKR2geX9WQZz//KtOg7E4PlGSiBMnG4HoQzYXgTeA XTp6/ouNIqCCrqbxN/Vva+Qy9E/TeLqNBUggkl+FycHfJjlFp5ml35z/e9o0jAyQdcQud8 0rcNZxFWqjmpuR6HTOjgDg1CJVTm/oqt07pqN8OS6Nc3omgk06JdVKS+jIj+fvzEaoZyyx 3MU0KZb0FGhYsb3BRkz5Z+FhhPKzJhnOWP5QtJtewroLkwmvwE3EY7M14Apo5yjXxZ8Ba1 Q1xsmzxRjoCB5V9Fe1WFe3kPFfl7S6NTAsc/vn6okEQlhh5aghkJxi3K/MHGYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4RNlBr2vhTzpM4; Sun, 13 Aug 2023 04:37:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37D4bu4d035978; Sun, 13 Aug 2023 04:37:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37D4buaH035975; Sun, 13 Aug 2023 04:37:56 GMT (envelope-from git) Date: Sun, 13 Aug 2023 04:37:56 GMT Message-Id: <202308130437.37D4buaH035975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b53ecd5cf63b - stable/13 - libc dlfcn.c: make dl_iterate_phdr() from libc more useful List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b53ecd5cf63b90a72436642056733b686d881eb1 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b53ecd5cf63b90a72436642056733b686d881eb1 commit b53ecd5cf63b90a72436642056733b686d881eb1 Author: Konstantin Belousov AuthorDate: 2023-08-09 05:07:05 +0000 Commit: Konstantin Belousov CommitDate: 2023-08-13 04:35:41 +0000 libc dlfcn.c: make dl_iterate_phdr() from libc more useful PR: 272992 (cherry picked from commit 21a52f99440c9bec7679f3b0c5c9d888901c3694) --- lib/libc/gen/dlfcn.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 61984e2fe86c..f1ee86ec1934 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -169,7 +169,9 @@ _rtld_thread_init(void *li __unused) #ifndef IN_LIBDL static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT; static struct dl_phdr_info phdr_info; +#ifndef PIC static mutex_t dl_phdr_info_lock = MUTEX_INITIALIZER; +#endif static void dl_init_phdr_info(void) @@ -208,7 +210,16 @@ int dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused, void *data __unused) { -#ifndef IN_LIBDL +#if defined IN_LIBDL + return (0); +#elif defined PIC + int (*r)(int (*)(struct dl_phdr_info *, size_t, void *), void *); + + r = dlsym(RTLD_DEFAULT, "dl_iterate_phdr"); + if (r == NULL) + return (0); + return (r(callback, data)); +#else tls_index ti; int ret; @@ -223,8 +234,6 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused, ret = callback(&phdr_info, sizeof(phdr_info), data); mutex_unlock(&dl_phdr_info_lock); return (ret); -#else - return (0); #endif }