From nobody Thu Sep 18 20:20:43 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E5E1C4708D for ; Sun, 4 Dec 2022 17:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbiLDR50 (ORCPT ); Sun, 4 Dec 2022 12:57:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbiLDR4y (ORCPT ); Sun, 4 Dec 2022 12:56:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73CA140D2; Sun, 4 Dec 2022 09:56:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4E74AB80B89; Sun, 4 Dec 2022 17:56:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A10D7C433D6; Sun, 4 Dec 2022 17:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670176611; bh=sX7eLjihdTEqkiDlYvFCMfPbXYIdW7Xa2twESHG3S88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/2ud02wVj3AntrLDgXV0TMafTMGjJrHrjz5M4xq+uqbVe/3omaXZ1udWvlW9BlZ6 PAsPswuWOvZCfFNV51kdLJhjjbzbfAGbCVA/v69EBkbq4RVACpxzWdQfvl0qAV+Wrn lMtZplOrd4VdW/VMlBEDQoUrj+w8U06eYf3ILjqtUwn1BfR3fG4u6uXEZndvhD5Qlf eSMasLReRUDLwGVhKMuGcO9aOCVzZUdeGpVO3zLq81Qg7vLiQt6tmfdAAoFd8kC9Lt STVfGVxOH//GN9xM6onwtQwRbYrhwZjMjHU7BowoE6fudNHf4jIatgeaNoJukKyeJp HNxCB0PN8Vzwg== From: Jisheng Zhang To: Palmer Dabbelt , Paul Walmsley , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner , Andrew Jones Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: [PATCH v2 08/13] riscv: module: move find_section to module.h Date: Mon, 5 Dec 2022 01:46:27 +0800 Message-Id: <20221204174632.3677-9-jszhang@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221204174632.3677-1-jszhang@kernel.org> References: <20221204174632.3677-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move it to the header so that the implementation can be shared by the alternatives code. Signed-off-by: Jisheng Zhang Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley --- arch/riscv/include/asm/module.h | 15 +++++++++++++++ arch/riscv/kernel/module.c | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/riscv/include/asm/module.h b/arch/riscv/include/asm/modul= e.h index 76aa96a9fc08..78722a79fc59 100644 --- a/arch/riscv/include/asm/module.h +++ b/arch/riscv/include/asm/module.h @@ -111,4 +111,19 @@ static inline struct plt_entry *get_plt_entry(unsigned= long val, =20 #endif /* CONFIG_MODULE_SECTIONS */ =20 +static inline const Elf_Shdr *find_section(const Elf_Ehdr *hdr, + const Elf_Shdr *sechdrs, + const char *name) +{ + const Elf_Shdr *s, *se; + const char *secstrs =3D (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; + + for (s =3D sechdrs, se =3D sechdrs + hdr->e_shnum; s < se; s++) { + if (strcmp(name, secstrs + s->sh_name) =3D=3D 0) + return s; + } + + return NULL; +} + #endif /* _ASM_RISCV_MODULE_H */ diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index 91fe16bfaa07..76f4b9c2ec5b 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -429,21 +429,6 @@ void *module_alloc(unsigned long size) } #endif =20 -static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, - const Elf_Shdr *sechdrs, - const char *name) -{ - const Elf_Shdr *s, *se; - const char *secstrs =3D (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; - - for (s =3D sechdrs, se =3D sechdrs + hdr->e_shnum; s < se; s++) { - if (strcmp(name, secstrs + s->sh_name) =3D=3D 0) - return s; - } - - return NULL; -} - int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *me) --=20 2.37.2