From nobody Sun Jul 02 01:17:33 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 4Qtrl13fNKz4hPgb; Sun, 2 Jul 2023 01:17:33 +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 4Qtrl12lk8z4BKR; Sun, 2 Jul 2023 01:17:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688260653; 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=uoiioXGqRLY8PtQCziN+2G/vEcT5ii3hPDe0vKrc3Q8=; b=Y6dHMZbv0Ldo9Zp0I2OGB7qwAhNJsX0SuL4iJ8Okz81gACN/zdKZZakkx9fX7LCa5MXnwL VkrphqKYsrzjeSEwxMFByVSoIsETj9crXNT0G01uCWoJyAQjyl/J+gvA/t048EiHzp2rDZ tDPmlYTTMTUe4fz13k3TLpWb1CJNSxtn0zREEhCDb85rNg6nE6jkwptYSau05CUngrUl5o 86OVVKpBxjJGcDAXWPPQ/YeylxoVTLp3XOGsGkI0QL6vLE3Yn7nJoBn0EZ8gEnBM6sigFo lwu9fg1thn+nZenWHDxzsKa3TBuu52U8gjIzOBHqxanKN1+8A7359J5UkI5ISA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688260653; 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=uoiioXGqRLY8PtQCziN+2G/vEcT5ii3hPDe0vKrc3Q8=; b=i6pasiOPZFLrc3sqBialn2iyy3KiW7BypDZTXnUENgrHD5Mb/kGBuZ4mG9+tvjh7YiCcnW c77d9nrbVzw38tDytzL14D5YpdC6iunz6Qn8WVB/w3Dz7bbiypVwH0KWWwQYxjK4uKV69f nMnLFvSSZSAj5V+ZtCyhWzrIqZNYOXBC74TI3rHbD5pGUBykcqo9qXjjaYhntpUSQ9nlJj PNVrwRubdFNmdN60yLK/M+IL1dRHCedL5bR2m4vB+29N5EtMP4u1om8c/AqejOTiU5o5DC NHqrjIF4L53pXBJ53fwD6K1Hd1QI2wI0+p5aZd0lApMeWpVpE4Int81XomdYDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688260653; a=rsa-sha256; cv=none; b=LzkCoi3aJmofj6uSqbcbREmfMUEHfGoim5bLNY3yazAo35risZ5mhNsT+UzeSDmoq9KaIv XWTDvqgmyglk8dhoevumfnxkah3hDuJMuUHfnGw9fKQrx6vNTzvSbmcd9pmJR/OL4Q4eaX qAz8cUqb25sYyy4823utTCX2CvD1woHTOHZBLmMINJMU6Wf98s4TXSKiIJXBRy9koHFBoo UbaGlpyuqJ8HblvEI6ztYH25BB/Kw+twvoW5EL+rHw3F3zcmBSbs36odvkgzJlq2RtRlJD Jg2ma+9AQ/r+eTPT6QPWx2AkNCxz+A78S9t1VI/+wog0UmmjTbQCjpELtzwsAA== 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 4Qtrl11qFmznhp; Sun, 2 Jul 2023 01:17:33 +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 3621HX6x048094; Sun, 2 Jul 2023 01:17:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3621HXte048093; Sun, 2 Jul 2023 01:17:33 GMT (envelope-from git) Date: Sun, 2 Jul 2023 01:17:33 GMT Message-Id: <202307020117.3621HXte048093@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: e3fbeb1dd0c5 - stable/13 - libc.a: implement _rtld_addr_phdr() 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: e3fbeb1dd0c5b19efad5a90838a42df1775103a4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e3fbeb1dd0c5b19efad5a90838a42df1775103a4 commit e3fbeb1dd0c5b19efad5a90838a42df1775103a4 Author: Konstantin Belousov AuthorDate: 2023-06-24 10:59:56 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-02 01:16:50 +0000 libc.a: implement _rtld_addr_phdr() (cherry picked from commit 42ceab3ea1a997db93b65404be0ee4b17b5382d7) --- lib/libc/gen/dlfcn.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 337ad48fd691..52e93d1476d7 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "namespace.h" #include #include "un-namespace.h" @@ -248,13 +249,48 @@ _rtld_atfork_post(int *locks __unused) { } +#ifndef IN_LIBDL +struct _rtld_addr_phdr_cb_data { + const void *addr; + struct dl_phdr_info *dli; +}; + +static int +_rtld_addr_phdr_cb(struct dl_phdr_info *dli, size_t sz, void *arg) +{ + struct _rtld_addr_phdr_cb_data *rd; + const Elf_Phdr *ph; + unsigned i; + + rd = arg; + for (i = 0; i < dli->dlpi_phnum; i++) { + ph = &dli->dlpi_phdr[i]; + if (ph->p_type == PT_LOAD && + dli->dlpi_addr + ph->p_vaddr <= (uintptr_t)rd->addr && + (uintptr_t)rd->addr < dli->dlpi_addr + ph->p_vaddr + + ph->p_memsz) { + memcpy(rd->dli, dli, sz); + return (1); + } + } + return (0); +} +#endif + #pragma weak _rtld_addr_phdr int _rtld_addr_phdr(const void *addr __unused, struct dl_phdr_info *phdr_info_a __unused) { +#ifndef IN_LIBDL + struct _rtld_addr_phdr_cb_data rd; + rd.addr = addr; + rd.dli = phdr_info_a; + return (dl_iterate_phdr(_rtld_addr_phdr_cb, &rd)); +#else return (0); +#endif } #pragma weak _rtld_get_stack_prot