From nobody Fri Oct 17 14:14:02 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 4cp6JC1gVWz6DLRP; Fri, 17 Oct 2025 14:14:03 +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 4cp6JB48tnz3sZZ; Fri, 17 Oct 2025 14:14:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760710442; 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=V6O5VlMwUWfa8T98sritD+v4gKukS6l+0k4g5LjUPuI=; b=fFFf0N/P2GI31BvAqDx+Wn3W2xenTyEIgpclVesSbZQ4+7xCx29fdO1juCR8XnthgDtHyT sjUZf2pfL5KOGiolGDexMKFF4jeOK1kkVGFNXtFqFseaWppBuXe0b9wkxpMzW9Pc7Uzvy0 VyiBLu6OCxoLmC2zKweUmg+nVFNnZ2JPVNCZYSvo2W2DjDChJr5bcRZUqWpWe/7z4QNpo3 x4sdt0SEsxCz+pXG8rTY3gMKmLXL3kQt46k5VKIDanriEGdBBBGMA+Bi58O9jjyuc/Mn4Q dQWnOBGCeadwH0dO0WlHR/sDkP4d3Wyc3mQVlrhiVtrC/dFhSKXoqLAoV2j75Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760710442; 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=V6O5VlMwUWfa8T98sritD+v4gKukS6l+0k4g5LjUPuI=; b=fDxbOAL6M0O8nOMBhj/cz3wAiAYboRQQqoHs8Z0X+jnVgtgYMusGpzTKv07FSFT/1VPe9+ /7qF2OA+jhlT2OeQPi4rIs+XLL/7qchREQT3Rgai7t/6HfvoCU652/HoxPAi0q+xp/71Hi b4Bkc2cSO9l0HQ6ENiCYi37EMqM4Ze/gHp6KCafGtqycXOU7Uh8tz5KpZHB0DiJEVzuL1c 908cofMudyO5346EsURzJIwgdECH6bgHD1ZkWiRvYBvBq+aJ9JbE/TWW5KYuoxGTYfLTt+ QfS7a4dgexK6gbjbdmSCq8ze38NPWonQc4jRDPX17bprMKB8kYvRJi67dLCRvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760710442; a=rsa-sha256; cv=none; b=o8sVPNucHgAiTzjpGfTtAWFOnfZh/3zXPtV7pI2C8LGhO7McON1AAhd1NwwqQ9TRSXAKVt CZ9BTzXLbIaihlIgXDTCBazSxJw1A/9N0aChzOBLQCx/3OGFu8NkddDJnTukE2hIGZTMLf vXx0+eObQH8yUEAaa89r4HZqQty2FqZyjqxWuIB61ois2XQjy68wgmH0a5bevRwC3Z++Dw 1U/iRhd26oQkBFp5Ib+QDIIid+dEaq4/5MOv/LzldVptsdv+quCDKn75hdTyHhqI0AMFDM CzmgWsYovIDdiF8/vFec35fj5T3VFs7KU3x5yJ4bNkpflInZB/ku38SVyu0itQ== 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 4cp6JB3kg4zy2F; Fri, 17 Oct 2025 14:14:02 +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 59HEE2DB069243; Fri, 17 Oct 2025 14:14:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59HEE2Gg069240; Fri, 17 Oct 2025 14:14:02 GMT (envelope-from git) Date: Fri, 17 Oct 2025 14:14:02 GMT Message-Id: <202510171414.59HEE2Gg069240@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 5a926b3cd53b - stable/15 - 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 5a926b3cd53b6c4516ad59c4693d7a999549c34c Auto-Submitted: auto-generated The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5a926b3cd53b6c4516ad59c4693d7a999549c34c commit 5a926b3cd53b6c4516ad59c4693d7a999549c34c Author: Mark Johnston AuthorDate: 2025-10-03 14:25:38 +0000 Commit: Mark Johnston CommitDate: 2025-10-17 12:43:16 +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. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52730 (cherry picked from commit 07747afd516e710814fdc65afb0e5000d046f28f) --- 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) {