From nobody Tue Jul 29 12:49:08 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 4brwC949qwz62xMv; Tue, 29 Jul 2025 12:49:09 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4brwC84Jvlz3lNb; Tue, 29 Jul 2025 12:49:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753793348; 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=KiwhLSEKmGE/vwaJuiSEGWpsi+2A/5GYNJayDP85l8w=; b=YkAx8wj1Oeqbay4HZgs8oQ8fBl1T37iV+V0vNtrqLN09+iEOfh5jPUTXh1Ymuq46C8LguB Zcy3EdAtzysnl4QdCgzFg+yukz3Gf6Uzv45RYpFi49eZVgHJL3WFn9P5+BPHBvhpjRqbM6 cj18nBtl/28VSGhP6VDQrp6WsGmJu5YNDQxV/CeAocwiF1DxdCeoYCYAKfm7egi4a8WDmy TSZytJvP6f77yStXnrYEHK4fpMydDVIZOhYptDpRhJQ7qq0ofpph1VtmLtf9p16DRzlmor 6MttkgZZWbsibCQGa3RhhfTX81enmZQJR5Qb95SYNUl/l+UlPZXs0Ys5qOiDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753793348; 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=KiwhLSEKmGE/vwaJuiSEGWpsi+2A/5GYNJayDP85l8w=; b=cM0CTQ+7M8aPbO83B4j8lClDsx6OGkOgMF4dRhaP8gmYxgs8V5Iv7bWH+d2BLHfriHEZxn vDlwtWlmNsbApg5Ox7bWeQPEK1dP53HFZthK9mt8ESV8ueijT9BXI/9h/E0KAwFNhclrGr eRy0N8MqcQSlPpH6QXCnxsb2PZTtiW3njYZ1vE+k8eEV5uPVaAwEcI14/C05ZZtVM66vv7 QRil+LJJwSkKc5fBG4uh/e3eRT4KyCbFx4t2tSIGyvDwsz6HEsckzT9l/nzgxMoYXBejbU SM4mvk+McwKe7bImAo/BM/q3iygTjK5eby7IfM1JcAF20Me0a5VbUbbFBbdLQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753793348; a=rsa-sha256; cv=none; b=TQw9AiK+MWWDGd5WwP1I5uJQc5V/pmwfMLaL8PbhTZKWI73x9OC9Rl3fnyw70qtgfrscBm BQtUkJBKuDQgMdWT/P0HnTXf1FmqOgtVVb6Idbky9fXKSKjnTdni2Edm6DQl5kuapmY+Pw j+HIhbZtqphLZB3HSOHaqNotLQC5/BpeEQT7upQgkZyuzeXujAR9tKe6KH3A6gY/nDdOJs 2bVNSwxzlRDUeCuQG5C5qvNeKWzH2LQVvKL82hKNifjOzSvdSkLTjn5qtN4tB5Bw9oRKoP ZIVAD6BVg8R9tJ0gaKF+y4/PjYwN5II3iyl7Fn5YDZGjzapIdVhHyimUBEgA8A== 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 4brwC82y83zXNx; Tue, 29 Jul 2025 12:49:08 +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 56TCn82D033497; Tue, 29 Jul 2025 12:49:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56TCn8MF033494; Tue, 29 Jul 2025 12:49:08 GMT (envelope-from git) Date: Tue, 29 Jul 2025 12:49:08 GMT Message-Id: <202507291249.56TCn8MF033494@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: e9e13081931f - stable/14 - dtrace: fix symbol address resolution 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/14 X-Git-Reftype: branch X-Git-Commit: e9e13081931f7dbe8e785d15502b07aab6267b26 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e9e13081931f7dbe8e785d15502b07aab6267b26 commit e9e13081931f7dbe8e785d15502b07aab6267b26 Author: Jiacong Fang AuthorDate: 2025-07-07 18:51:51 +0000 Commit: Mark Johnston CommitDate: 2025-07-29 12:08:32 +0000 dtrace: fix symbol address resolution Dtrace assumes only ELF sections of type SHT_PROGBITS or SHT_NOBITS occupy memory space. However, sections with SHF_ALLOC flag also consume memory space. Moreover, the symbol address initialization skips symbols at the very beginning of a section in ET_REL KLDs. Fix: Check section flag for calculating section offset, and disable the skipping at the beginning of a section. PR: 288000 Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51188 (cherry picked from commit 12bef37a824c52582ee8f38699b8ae4fde17068d) --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c index 2a0386c33124..f6a328bb9b39 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c @@ -109,8 +109,7 @@ dt_module_syminit32(dt_module_t *dmp) if (sym->st_name == 0 || sym->st_name >= ss_size) continue; /* skip null or invalid names */ - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) { asrsv++; /* reserve space in the address map */ #if defined(__FreeBSD__) @@ -159,8 +158,7 @@ dt_module_syminit64(dt_module_t *dmp) if (sym->st_name == 0 || sym->st_name >= ss_size) continue; /* skip null or invalid names */ - if (sym->st_value != 0 && - (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + if (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) { asrsv++; /* reserve space in the address map */ #if defined(__FreeBSD__) sym->st_value += (Elf_Addr) dmp->dm_reloc_offset; @@ -245,8 +243,7 @@ dt_module_symsort32(dt_module_t *dmp) for (i = 1; i < n; i++, dsp++) { Elf32_Sym *sym = symtab + dsp->ds_symid; - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) *sympp++ = sym; } @@ -269,8 +266,7 @@ dt_module_symsort64(dt_module_t *dmp) for (i = 1; i < n; i++, dsp++) { Elf64_Sym *sym = symtab + dsp->ds_symid; - if (sym->st_value != 0 && - (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) + if (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) *sympp++ = sym; } @@ -1218,7 +1214,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) continue; /* skip any malformed sections */ if (sh.sh_size == 0) continue; - if (sh.sh_type == SHT_PROGBITS || sh.sh_type == SHT_NOBITS) { + if (sh.sh_flags & SHF_ALLOC) { alignmask = sh.sh_addralign - 1; mapbase += alignmask; mapbase &= ~alignmask;