From nobody Thu Jan 18 22:26:04 2024 X-Original-To: dev-commits-src-all@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 4TGHQP4k5rz578R5; Thu, 18 Jan 2024 22:26:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TGHQP1NJHz419C; Thu, 18 Jan 2024 22:26:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705616765; 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=fcBYAks5vEGi4TflzfXsJTz6KxyDg9GOwpuJL1S5hS8=; b=mrHxLEw/axIaYfiSYcLksRZTUyMaWyUGiXRnECsX52YAI4Xv5q0MWYEZCNG7PvoKML1Ebq ZvAqjOk0jORaK/grl08eUJgRuNCnX7o9N3z9ANAGKKEt1+ujAzCAAKQOjUqThf8CFpT7zo nXfVRdPD+uNpNN42AZxUxJ6rZhXPL9N6zSs4SNEYzaO5vYWLt27dO6PevXsNvCCSOh/ukT NN7OlLE5m37n59BwJQFOfbFHktHm0ennDIXbN1+jaR6PbmCvoosxL66Vxo2HMKhSo2QP/Q A00q7YdRPzwFeqBRIFEN6NAU15679M5g+/1OhriQXJVbB2nrks7s66DXjccCpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705616765; 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=fcBYAks5vEGi4TflzfXsJTz6KxyDg9GOwpuJL1S5hS8=; b=qOG2Y+K5T8DHqyIf3gFAXBqkGAFEA7UOgZBR85IcqQGIPTHoL3sGpQ1MQbk6ONi60TzVos pCQ2JBKhHdTprnToOesx8ZU3nmOSV4HctgwwP2ao5UHHo+pXmzV3Gw+qVfUva6BgLoNkIJ otK/S6P+Slqw84wMPM8kjJ4jYI5bW1/ZgJcihfKPrIeO8x9MLR147dGdSgV0VrmTEl67Er OL9nuDFJqS5Dozk2HaSmpvwBevQLgROKK9yXZcw018LrqoTAaapWACebFBWWwDbIbs0yEd YKO2KUWNBrPGVhrj3zAD5bEjQJQzsA77fYiGxV2dO4uh42W44cembfbG/aJNMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705616765; a=rsa-sha256; cv=none; b=pt2YuVt3Udll3aROGgr1YZ/SGTHm8qOIuirWFq2IqHg/1tyf4EK6mo7x49DxgepocSXP9R to0m1zqF0eDNDpsGHieDev7ZTVBNeEXO7qEk4OHAs+EmpYX72P2mCzIauHypihpB/RN4Tq 5IaHzY2eorG4iHA+Kx3qvttG19wMgzCm+75fA1I4MK+s/bkKILkVp7jyzIC/+dOyNAWKG4 DOGrrcnj4Nr9j4aQca1mukIn08+d0C1WLSNm6qPpoo3GSGcHWFcVfSlQjcuKTEX0PoK7RX JuPzIHtsU7Yse9OOL1ndwk39DcG35nWz+cuxN3c6x7mNFmi0E3lnNRXx1Mf7+Q== 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 4TGHQN6wgPzQG6; Thu, 18 Jan 2024 22:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40IMQ4nX089686; Thu, 18 Jan 2024 22:26:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40IMQ4HB089683; Thu, 18 Jan 2024 22:26:04 GMT (envelope-from git) Date: Thu, 18 Jan 2024 22:26:04 GMT Message-Id: <202401182226.40IMQ4HB089683@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: cec0bae09eae - stable/14 - kldxref: Workaround incorrect PT_DYNAMIC in existing powerpc kernels List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: cec0bae09eaedff61b4e296e662a1c87757b8af9 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cec0bae09eaedff61b4e296e662a1c87757b8af9 commit cec0bae09eaedff61b4e296e662a1c87757b8af9 Author: John Baldwin AuthorDate: 2024-01-09 18:57:48 +0000 Commit: John Baldwin CommitDate: 2024-01-18 21:32:12 +0000 kldxref: Workaround incorrect PT_DYNAMIC in existing powerpc kernels Existing powerpc kernels include additional sections beyond .dynamic in the PT_DYNAMIC segment. Relax the requirement for an exact size match of the section and segment for PowerPC files as a workaround. Reported by: jrtc27 Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43123 (cherry picked from commit 6631e2f9b49e08f53c7beb560ee8509c343b3927) --- usr.sbin/kldxref/ef.c | 11 ++++++++++- usr.sbin/kldxref/ef.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c index fd0782ff1dd0..1ef27f2bc54a 100644 --- a/usr.sbin/kldxref/ef.c +++ b/usr.sbin/kldxref/ef.c @@ -248,8 +248,17 @@ ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn) dynamic_idx = -1; for (i = 0; i < nshdr; i++) { if (shdr[i].sh_type == SHT_DYNAMIC) { + /* + * PowerPC kernels contain additional sections + * beyond .dynamic in PT_DYNAMIC due to a linker + * script bug. Permit a section with a smaller + * size as a workaround. + */ if (shdr[i].sh_offset != phdyn->p_offset || - shdr[i].sh_size != phdyn->p_filesz) { + ((elf_machine(ef->ef_efile) == EM_PPC || + elf_machine(ef->ef_efile) == EM_PPC64) ? + shdr[i].sh_size > phdyn->p_filesz : + shdr[i].sh_size != phdyn->p_filesz)) { warnx(".dynamic section doesn't match phdr"); error = EFTYPE; goto out; diff --git a/usr.sbin/kldxref/ef.h b/usr.sbin/kldxref/ef.h index 2909704bf2d1..25dc5216b169 100644 --- a/usr.sbin/kldxref/ef.h +++ b/usr.sbin/kldxref/ef.h @@ -100,6 +100,7 @@ struct elf_file { int ef_fd; }; +#define elf_machine(ef) ((ef)->ef_hdr.e_machine) #define elf_class(ef) ((ef)->ef_hdr.e_ident[EI_CLASS]) #define elf_encoding(ef) ((ef)->ef_hdr.e_ident[EI_DATA])