From nobody Thu Jan 18 22:26:36 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 4TGHR05pMVz578lD; Thu, 18 Jan 2024 22:26:36 +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 4TGHR02VVRz42Mk; Thu, 18 Jan 2024 22:26:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705616796; 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=wN/zGov7dk3rEOEU1s53pY8hJzp7eamlFgtHvQREpK4=; b=fZebfE1fer9kdtjHQtM9PzQegNavTwwVhhJjyho9ZkxRLqCoB+CLrmo+vRcQ5yAv40kALN mWOvTmMT4MnrbZRFNxREA2zYGIjzRYRnkeSk41bxQmWRVhZXGG2q1SWMwtAIE/wEFEtZ+t zZDlSqro7SeI3J03eKHaHq2P8AWiNVLX6wach5dMooIWPpxRnLJsiePyKkR2BLMxTyjvN+ UOasHOnHBmLTq3RnR481+PCs1oYiEb5rYYDHbs2pHuXChz3WR83YcRYW8ZqT4L8EUA7/ic f2FjmgRo9qiNeaPhSnFfLpgoLYRtmhUGQG5kibzqWip4ZXCnxZzY3EIzw41QZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705616796; 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=wN/zGov7dk3rEOEU1s53pY8hJzp7eamlFgtHvQREpK4=; b=PWKBjY3VL9qacr7gSATBVNVi2IMf8xxKft25i8l6Rx6HEO+qVSpXiUVCcBg6Jo0qca6CF+ g+ClWKMpbeLMNwjCuJqX1LE195zStrRcFMj6blBK2dQiF2sLBmiZ28Kir0Je3vItSzZBXU I+TFNmxoGSjEZg3sLBFvYjEEVnb6vJYATcXKQu3GRFnRfi2b1AUrgRfI//IOMUb4AcrMTp H4hjXTW4aw2PlUeCAGGgQMtFtJ95vDRcAYeodV+JXSWshrNqClw5ANXAi8lUfrbMDjsKhU FQokKMdBttX9sEGT7Nt8i0qnuDVPsMVR5Mzmktl7I4p7Fhmx2Z6g/2+cOTNgwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705616796; a=rsa-sha256; cv=none; b=uyLpKlnVkbgEJrgzSvknTT5G/v6VPCMHN9Rbnl6Mw0LaJcULUHNryzTwxb0BI3tIdChkUl 8XGDgTQs0+aTLie4TFPq4jmg51ZUMvxJO3BTeygeY9ap1sTZjmMVunZrwq87LQteiAtYgH AdHnAPqWMse2NIbyK4dgFM4UsfcI2KjX+9XbYH+pmg6NkPCD0zy3/jOckKJTO9DTPHOr1u M3Q1+zDxw2MOCcuU1eN4z+AR+n2+wvTucXzTEgAb4K28TBBZcQEETzkww4ZJ/UTwIlJ3EZ eC8NfLyRaYiXoapFx8jyWPRTrRSDRHqC/SpKsvfVERCqrRV5qY3XML8YrPhcAg== 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 4TGHR01WZbzQ4d; Thu, 18 Jan 2024 22:26:36 +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 40IMQaBY090820; Thu, 18 Jan 2024 22:26:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40IMQaXr090817; Thu, 18 Jan 2024 22:26:36 GMT (envelope-from git) Date: Thu, 18 Jan 2024 22:26:36 GMT Message-Id: <202401182226.40IMQaXr090817@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: cad6775d969e - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: cad6775d969e66bfff46669f55f3b0def8efc0ca Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cad6775d969e66bfff46669f55f3b0def8efc0ca commit cad6775d969e66bfff46669f55f3b0def8efc0ca Author: John Baldwin AuthorDate: 2024-01-09 18:57:48 +0000 Commit: John Baldwin CommitDate: 2024-01-18 21:32:10 +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])