From nobody Fri Oct 17 17:59:40 2025 X-Original-To: dev-commits-src-branches@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 4cpCJY39dqz6CRVM; Fri, 17 Oct 2025 17:59:41 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cpCJX69hcz3WnK; Fri, 17 Oct 2025 17:59:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760723980; 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=WnjX90eWIPJbeSIkDAgunYidDltkJmV56ux5uKJlEFg=; b=PfVp5MbfXFs++OQZw4mudwWs/rYxnV940CvgBdJgknO6sMjkHOZnTQwka5jVb6/6GG6+c7 Kq3Cry299F+/eFkeM9WR+beYMbNkMGMMO3bilIgNY4r9uP4uQUyJCS5Vuw3O1XjNpN03lk 5YY5zS1WAK2SUeZxBf2njAC+FORBJfceGUbgiwFpN3F+ZR/EqB7IUbI/nKmuj5U8vLuP0H EI43bvWy8FMWoXoPpNqfMu8tZL16PVY+SnlE+RN95l01/Xw/fBMvS7j4Y6pJu54kWwx1a8 IrekoWMPpZki2z1ymqyC6bb/9XjnQYxVtmkwpRzBtIDGxkCZkCWGtBhmO+Oqkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760723980; 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=WnjX90eWIPJbeSIkDAgunYidDltkJmV56ux5uKJlEFg=; b=kUBB5JapFy50Vt04tZfQBa2rCICA3X5UwgbOSc/NvZ70cJPghzoO9Rzw50tsXGHRcAqreI nxZujSt0Gah0ovd2gSWQwERpPIr8ViqbPNskLqgIe29XYwBeZ4sPlldU6F/NNDiwvWZk0x e09FKVqlYbv+fAjcDWfxY00c/3e5K3iwZ/bqlCn+H+dHYYKSa5giOfcVWoa8f5vjNil5pZ eXRZBC5XsTF8CPJF0jHHhyIDVpNfpFG6sYGBTDOrAgirvvd4pzNXIt4dC1MABdutquIU1L n9CSKDpuqTnuve9hnISvqlUwWVk/UQaWKzjgos0ETHQPuPeYWhB12Eto9FnSsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760723980; a=rsa-sha256; cv=none; b=fS5TbTxHXOpTrFIMdpDX215FH/+MUcespsYUKV6HEXkcFxYUDAKh81E2ch3pactCHPLE8S Ucsz/lfReAtRqvOiPoJRxWRvxAZEl1fWKoyaepDOxZrPIbIYajUdtjfHFFha96S+ke8EQu knOYi2RutcimLvQNSTplHTNDf+iGd74vb1Ql25n4Nez62EkwpZECL26LeaBrQTPme/utz3 330lUBjsGIKTnm3rMt5O/yZfkoLrBaz9JHLs5PXKaK3K+Ib1Bsgpr55vcwhWgmJwqfb5WO 6wFpNz/LxuXjWCsS8bfSjxtMIiJkyQWb3v0AUr8qbc81BHQ97FS7NYxurI8rZg== 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 4cpCJX5Gpkz149y; Fri, 17 Oct 2025 17:59:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59HHxe7c086354; Fri, 17 Oct 2025 17:59:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59HHxeLn086351; Fri, 17 Oct 2025 17:59:40 GMT (envelope-from git) Date: Fri, 17 Oct 2025 17:59:40 GMT Message-Id: <202510171759.59HHxeLn086351@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: 1ae34f2dd8c0 - releng/15.0 - linker: Make it easier to find the VNET section layout List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.0 X-Git-Reftype: branch X-Git-Commit: 1ae34f2dd8c0d407f6764822671f9409620ffad9 Auto-Submitted: auto-generated The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=1ae34f2dd8c0d407f6764822671f9409620ffad9 commit 1ae34f2dd8c0d407f6764822671f9409620ffad9 Author: Mark Johnston AuthorDate: 2025-10-03 14:25:38 +0000 Commit: Colin Percival CommitDate: 2025-10-17 17:59:15 +0000 linker: Make it easier to find the VNET section layout When trying to find the address of a VNET variable from a debugger, it helps to have the original address of the VNET section. In particular, given the address of a vnet_entry_foo symbol, one wants to easily find the linker file that the symbol belongs to. In link_elf_obj.c, the section address for VNET and DPCPU sections is overwritten in link_elf_link_preload() and link_elf_load_file(). Add an "origaddr" field to store the original absolute address of the section base. In link_elf.c the elf_file_t already has the fields we want, but they were not getting filled out for the kernel itself. Fix that too, since that simplifies things for debuggers and improves consistency. Approved by: re (cperciva) Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52730 (cherry picked from commit 07747afd516e710814fdc65afb0e5000d046f28f) (cherry picked from commit 5a926b3cd53b6c4516ad59c4693d7a999549c34c) --- sys/kern/link_elf.c | 6 ++++++ sys/kern/link_elf_obj.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index bbebadc4c395..ebd203858b66 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -518,9 +518,15 @@ link_elf_init(void* arg) (void)link_elf_link_common_finish(linker_kernel_file); linker_kernel_file->flags |= LINKER_FILE_LINKED; TAILQ_INIT(&set_pcpu_list); + ef->pcpu_start = DPCPU_START; + ef->pcpu_stop = DPCPU_STOP; + ef->pcpu_base = DPCPU_START; #ifdef VIMAGE TAILQ_INIT(&set_vnet_list); vnet_save_init((void *)VNET_START, VNET_STOP - VNET_START); + ef->vnet_start = VNET_START; + ef->vnet_stop = VNET_STOP; + ef->vnet_base = VNET_START; #endif } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 151aab96f9be..a3a53a39bfd6 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -70,6 +70,7 @@ typedef struct { void *addr; + void *origaddr; /* Used by debuggers. */ Elf_Off size; int flags; /* Section flags. */ int sec; /* Original section number. */ @@ -492,7 +493,8 @@ link_elf_link_preload(linker_class_t cls, const char *filename, case SHT_FINI_ARRAY: if (shdr[i].sh_addr == 0) break; - ef->progtab[pb].addr = (void *)shdr[i].sh_addr; + ef->progtab[pb].addr = ef->progtab[pb].origaddr = + (void *)shdr[i].sh_addr; if (shdr[i].sh_type == SHT_PROGBITS) ef->progtab[pb].name = "<>"; #ifdef __amd64__ @@ -1088,6 +1090,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, ef->progtab[pb].name = "<>"; if (ef->progtab[pb].name != NULL && !strcmp(ef->progtab[pb].name, DPCPU_SETNAME)) { + ef->progtab[pb].origaddr = + (void *)(uintptr_t)mapbase; ef->progtab[pb].addr = dpcpu_alloc(shdr[i].sh_size); if (ef->progtab[pb].addr == NULL) { @@ -1101,6 +1105,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, #ifdef VIMAGE else if (ef->progtab[pb].name != NULL && !strcmp(ef->progtab[pb].name, VNET_SETNAME)) { + ef->progtab[pb].origaddr = + (void *)(uintptr_t)mapbase; ef->progtab[pb].addr = vnet_data_alloc(shdr[i].sh_size); if (ef->progtab[pb].addr == NULL) {