From owner-svn-src-all@freebsd.org Fri May 22 17:52:10 2020 Return-Path: Delivered-To: svn-src-all@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 4DCDD2CF159; Fri, 22 May 2020 17:52:10 +0000 (UTC) (envelope-from kib@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49TDZy1Rv7z4dNN; Fri, 22 May 2020 17:52:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 13F702282A; Fri, 22 May 2020 17:52:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04MHq9Hl050209; Fri, 22 May 2020 17:52:09 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04MHq9cv050207; Fri, 22 May 2020 17:52:09 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202005221752.04MHq9cv050207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 22 May 2020 17:52:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361398 - in head: lib/libc/gen libexec/rtld-elf sys/sys X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head: lib/libc/gen libexec/rtld-elf sys/sys X-SVN-Commit-Revision: 361398 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 May 2020 17:52:10 -0000 Author: kib Date: Fri May 22 17:52:09 2020 New Revision: 361398 URL: https://svnweb.freebsd.org/changeset/base/361398 Log: Implement Solaris-like link_map l_refname member. The implementation is based on the public documentation, in particular dlinfo(3) from Solaris. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/lib/libc/gen/dlinfo.3 head/libexec/rtld-elf/rtld.c head/sys/sys/link_elf.h Modified: head/lib/libc/gen/dlinfo.3 ============================================================================== --- head/lib/libc/gen/dlinfo.3 Fri May 22 17:45:07 2020 (r361397) +++ head/lib/libc/gen/dlinfo.3 Fri May 22 17:52:09 2020 (r361398) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 19, 2020 +.Dd May 21, 2020 .Dt DLINFO 3 .Os .Sh NAME @@ -111,6 +111,7 @@ const void *l_ld; /* Pointer to .dynamic in m struct link_map *l_next, /* linked list of mapped libs */ *l_prev; caddr_t l_addr; /* Load Offset of library */ +const char *l_refname; /* Object this one filters for */ .Ed .Bl -tag -width ".Va l_addr" .It Va l_base @@ -133,6 +134,11 @@ structure on the link-map list. The load offset of the object, that is, the difference between the actual load address and the base virtual address the object was linked at. +.It Va l_refname +A name of the object this object filters for, if any. +If there are more then one filtee, a name from the first +.Dv DT_FILTER +dynamic entry is supplied. .El .It Dv RTLD_DI_SERINFO Retrieve the library search paths associated with the given Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Fri May 22 17:45:07 2020 (r361397) +++ head/libexec/rtld-elf/rtld.c Fri May 22 17:52:09 2020 (r361398) @@ -1207,6 +1207,9 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_D *needed_filtees_tail = nep; needed_filtees_tail = &nep->next; + + if (obj->linkmap.l_refname == NULL) + obj->linkmap.l_refname = (char *)dynp->d_un.d_val; } break; @@ -1402,6 +1405,10 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_D } obj->dynsymcount += obj->symndx_gnu; } + + if (obj->linkmap.l_refname != NULL) + obj->linkmap.l_refname = obj->strtab + (unsigned long)obj-> + linkmap.l_refname; } static bool Modified: head/sys/sys/link_elf.h ============================================================================== --- head/sys/sys/link_elf.h Fri May 22 17:45:07 2020 (r361397) +++ head/sys/sys/link_elf.h Fri May 22 17:52:09 2020 (r361398) @@ -65,6 +65,7 @@ typedef struct link_map { const void *l_ld; /* Pointer to .dynamic in memory */ struct link_map *l_next, *l_prev; /* linked list of of mapped libs */ caddr_t l_addr; /* Load Offset of library */ + const char *l_refname; /* object we are filtering for */ } Link_map; struct r_debug {