From nobody Fri Oct 03 14:32:23 2025 X-Original-To: dev-commits-src-main@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 4cdWMq3yGpz69wBS; Fri, 03 Oct 2025 14:32:23 +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 4cdWMq3978z3pJx; Fri, 03 Oct 2025 14:32:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759501943; 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=o8TA9Jglg7F2wtPmjy3xx3/pcDK+gVqJAqAaV+flyCQ=; b=VW2XMHP2PvjldH6SugC4OuK0TZ1eURffHIviNeKbzd//ftAQ0onzfnMW7Q06BwoYT/EcuL 3YIamBoF447qQpZZdmWOz4F/wdviykS2m82z9U6Dz0yBPSvs7wZachJXTA2P7GsxgRYthO jy3IoKR0yVvLHn7/T70XU5WlVuQ0L3xZ3FsZLMO6To7v3CTyoXZU69+IBKItYzabBs8K7e Xpk/3/FwsEHMKtT7e4LuadIQ8hKMGagQmsThxFwEoum5GbUnzCYz7K/mXCe1pnMfHddEiA B/JLd9T7wsNHM6urwVYjECAHCqFyT5hkhVb9dE9UCLD0s9ukYOllOTh7XUzSKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759501943; 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=o8TA9Jglg7F2wtPmjy3xx3/pcDK+gVqJAqAaV+flyCQ=; b=uo2Gjpr+MXTwae3FMKu88p6i4+xCeDacv3IVWK0McVnROYOfUiGYl7DvrtDjhwt3pbP+6F Gc9ubBtwWy+vidhNlsK7NZmbydFukgj/14OHpYGqIWR3t+z8ahh27SDacrhH6f0gOtpp+X BqIKWI29iaCWxHFDiN4vh8KmUUJT5Htsa0ADwF5F2cKSZWV2LWnasxSRgtkqV+PcvkZ3o7 9L+Bs77AoX+lYCBYLXyZILeW8n6eP6wzcfKCPvTw/N5W94m73Ax5hwOh2P4yvNNOo/Jfs+ +JJH+fzM6QlN+GGlADyJ5rfvKseUIEXv2eSrppzmAEen+PLXzu8KnHoSHKyLZw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759501943; a=rsa-sha256; cv=none; b=JuY94tf/8bvRWxn+n9qMIEirIGqe5Bb8w4UD7kINcBzRq2wic4DFhnTV/ralQPsmWDdXE9 rMOR4/DWSUR5bA/sduqIfZxoWdnoWhgUsuh6hdl5BX1Jhz6COPhGgntN8Mrs9lXAgl4ug+ 8hUf0nyW84wssePXVdaJbmDO0oxqMlpUtrETvDjTNhVSCpEoUeZUZRLM0rku48TPLMT5bC 17XQaDL1cfSHfumqrbxcvlP1lAi0nMenlwRiRVQcKJ9LqVqBbuiv8OMuOG5G9vC6c3T1J2 6C/BpLABnKF3Mh5cNSiyB7158w5XZvcImxocHmvD2ab74Ti3HnO/KMIHpa0QgA== 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 4cdWMq2bJWzyQ4; Fri, 03 Oct 2025 14:32:23 +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 593EWNIg097959; Fri, 3 Oct 2025 14:32:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 593EWN2s097956; Fri, 3 Oct 2025 14:32:23 GMT (envelope-from git) Date: Fri, 3 Oct 2025 14:32:23 GMT Message-Id: <202510031432.593EWN2s097956@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 07747afd516e - main - linker: Make it easier to find the VNET section layout List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 07747afd516e710814fdc65afb0e5000d046f28f Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=07747afd516e710814fdc65afb0e5000d046f28f commit 07747afd516e710814fdc65afb0e5000d046f28f Author: Mark Johnston AuthorDate: 2025-10-03 14:25:38 +0000 Commit: Mark Johnston CommitDate: 2025-10-03 14:32:09 +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 --- 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) {