From patchwork Sun Jan 15 15:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13102319 X-Patchwork-Delegate: palmer@dabbelt.com 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90866C67871 for ; Sun, 15 Jan 2023 16:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W5/octVSO1hqBS8iT5Tx5Z+XxZQhjEfgJxp3wrcPkGo=; b=pOzAm9CKw0x94e lXistMDp/60eGjLBB5CL0yLqGj6y6l8pGlUlzQd9F6y9i1mYMizP4YQkALWmWlGuuzetTmpoVyAlh W0GXaHwgqyhdNva06/72OZ+FwWsaIoQ7ZD/tlAZPfvoCTH6fj0IfgYGwzooPKJBdvGNQfBW6Y/1aT hmW3Ejb0rKyFKXcY/52aocwuIPsfJruz8VIMqQx7OqAWRb3tISrVFeSrVQQi7/cZ4SCx0PjWVQuNT w8KZEfqx8dxkHcsljp92TwtMwi4Yj1JtECJPYukJteXka36ZKBiH9ghN2iUCELX+Cs9gogCzIfHEQ Bs5WgEoNiaRnVREFETmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pH5RA-007c43-A1; Sun, 15 Jan 2023 16:00:48 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pH5Qz-007brW-EK; Sun, 15 Jan 2023 16:00:38 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id 0109160D3F; Sun, 15 Jan 2023 16:00:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43799C433EF; Sun, 15 Jan 2023 16:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673798436; bh=W6NwJoOq7fauyX3aaR9QaMpoEnd1BqGf85SXKRegHDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l3ZMopPg6BFnnBD/5+xEcZF1xa7jtVo/hap4f7i+yMP/9rH0k4HSsU6+atkMpN8jM p9AqMWHjyDAcF+E0e1VRvKBbiS+5qWlAxseoKQtcV534bLw0z6jQbOQ9nYD8jv8Gk6 9n9gdac7yh1u4Ax8W/VzyB4gB/NJvh86iib1GdaO6A8WCyVz9jj/QwvNf/Mj5wT7Rz VvAm/zKiCz9pefMla16trqU18F4BIyaUzVdvmK9GYfjFwcEglxKd9FO/qrWRSAahvY 6uvfm0aTgB3SouBrkc3hEErbkom1MdotO7XqXGFEDmQ4ljNrHIuiRAzljClFH988+Y mIRCuO/eW4IWg== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Heiko Stuebner , Conor Dooley , Andrew Jones Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: [PATCH v4 08/13] riscv: module: move find_section to module.h Date: Sun, 15 Jan 2023 23:49:48 +0800 Message-Id: <20230115154953.831-9-jszhang@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230115154953.831-1-jszhang@kernel.org> References: <20230115154953.831-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230115_080037_563733_28A7522A X-CRM114-Status: GOOD ( 12.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move find_section() to module.h so that the implementation can be shared by the alternatives code. This will allow us to use alternatives in the vdso. Reviewed-by: Conor Dooley Reviewed-by: Andrew Jones Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/module.h | 16 ++++++++++++++++ arch/riscv/kernel/module.c | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/riscv/include/asm/module.h b/arch/riscv/include/asm/module.h index 76aa96a9fc08..0f3baaa6a9a8 100644 --- a/arch/riscv/include/asm/module.h +++ b/arch/riscv/include/asm/module.h @@ -5,6 +5,7 @@ #define _ASM_RISCV_MODULE_H #include +#include struct module; unsigned long module_emit_got_entry(struct module *mod, unsigned long val); @@ -111,4 +112,19 @@ static inline struct plt_entry *get_plt_entry(unsigned long val, #endif /* CONFIG_MODULE_SECTIONS */ +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 = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; + + for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { + if (strcmp(name, secstrs + s->sh_name) == 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 -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 = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; - - for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { - if (strcmp(name, secstrs + s->sh_name) == 0) - return s; - } - - return NULL; -} - int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *me)