From owner-svn-src-all@freebsd.org Thu May 21 22:24:24 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 913542F6A31; Thu, 21 May 2020 22:24:24 +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 49SkgX21yHz4R03; Thu, 21 May 2020 22:24:24 +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 3C5651485B; Thu, 21 May 2020 22:24:24 +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 04LMONMg028798; Thu, 21 May 2020 22:24:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04LMONEF028795; Thu, 21 May 2020 22:24:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202005212224.04LMONEF028795@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 21 May 2020 22:24:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361349 - in head: cddl/contrib/opensolaris/lib/libdtrace/common lib/libc/gen libexec/rtld-elf sys/sys X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head: cddl/contrib/opensolaris/lib/libdtrace/common lib/libc/gen libexec/rtld-elf sys/sys X-SVN-Commit-Revision: 361349 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: Thu, 21 May 2020 22:24:24 -0000 Author: kib Date: Thu May 21 22:24:23 2020 New Revision: 361349 URL: https://svnweb.freebsd.org/changeset/base/361349 Log: Restore the binary compatibility for link_map l_addr. Keep link_map l_addr binary layout compatible, rename l_addr to l_base where rtld returns map base. Provide relocbase in newly added l_addr. This effectively reverts the patch to the initial version of D24918. Reported by: antoine (portmgr) Reviewed by: jhb, markj Tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24946 Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c head/lib/libc/gen/dlinfo.3 head/libexec/rtld-elf/rtld.c head/sys/sys/link_elf.h Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c Thu May 21 21:42:49 2020 (r361348) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c Thu May 21 22:24:23 2020 (r361349) @@ -143,12 +143,18 @@ dtrace_dof_init(void) return; } +#ifdef __FreeBSD__ + elf = (void *)lmp->l_base; +#else elf = (void *)lmp->l_addr; +#endif dh.dofhp_dof = (uintptr_t)dof; - dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0; #ifdef __FreeBSD__ + dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_base : 0; dh.dofhp_pid = getpid(); +#else + dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0; #endif if (lmid == 0) { Modified: head/lib/libc/gen/dlinfo.3 ============================================================================== --- head/lib/libc/gen/dlinfo.3 Thu May 21 21:42:49 2020 (r361348) +++ head/lib/libc/gen/dlinfo.3 Thu May 21 22:24:23 2020 (r361349) @@ -105,17 +105,16 @@ structure is defined in .In link.h and has the following members: .Bd -literal -offset indent -caddr_t l_addr; /* Load Offset of library */ +caddr_t l_base; /* Base Address of library */ const char *l_name; /* Absolute Path to Library */ const void *l_ld; /* Pointer to .dynamic in memory */ struct link_map *l_next, /* linked list of mapped libs */ *l_prev; +caddr_t l_addr; /* Load Offset of library */ .Ed .Bl -tag -width ".Va l_addr" -.It Va l_addr -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_base +The base address of the object loaded into memory. .It Va l_name The full name of the loaded shared object. .It Va l_ld @@ -130,6 +129,10 @@ structure on the link-map list. The previous .Vt Link_map structure on the link-map list. +.It Va l_addr +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. .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 Thu May 21 21:42:49 2020 (r361348) +++ head/libexec/rtld-elf/rtld.c Thu May 21 22:24:23 2020 (r361349) @@ -4032,8 +4032,9 @@ linkmap_add(Obj_Entry *obj) struct link_map *prev; obj->linkmap.l_name = obj->path; - obj->linkmap.l_addr = obj->relocbase; + obj->linkmap.l_base = obj->mapbase; obj->linkmap.l_ld = obj->dynamic; + obj->linkmap.l_addr = obj->relocbase; if (r_debug.r_map == NULL) { r_debug.r_map = l; Modified: head/sys/sys/link_elf.h ============================================================================== --- head/sys/sys/link_elf.h Thu May 21 21:42:49 2020 (r361348) +++ head/sys/sys/link_elf.h Thu May 21 22:24:23 2020 (r361349) @@ -57,13 +57,14 @@ #define LA_SER_SECURE 0x80 /* default (secure) path prepended */ typedef struct link_map { - caddr_t l_addr; /* Load Offset of library */ + caddr_t l_base; /* Base Address of library */ #ifdef __mips__ caddr_t l_xxx; /* unused */ #endif const char *l_name; /* Absolute Path to Library */ 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 */ } Link_map; struct r_debug {