Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp995747rwb; Tue, 27 Sep 2022 07:11:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GMdBmNYtnOiC5Lo7m7B2ejK42e+2lhk0OwLAHau+m+Tna5Uq3tLeUU1v3qZ+qDIqB4cLp X-Received: by 2002:a05:6402:42c2:b0:457:99eb:cb84 with SMTP id i2-20020a05640242c200b0045799ebcb84mr2957911edc.3.1664287911947; Tue, 27 Sep 2022 07:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664287911; cv=none; d=google.com; s=arc-20160816; b=Pgvx5GFS4cfmS2jxxPCKcijWXM24q7SBukp0H4307xAMg4KgggP3KoFh0s9FS+yhAl mpr5TKL/79PpITAhuY83l7lFMWOfbDtHaQAldSwmAz8jWOXM5DjxR4K/+Kcu5lcHJdty uXkCN3kAR0Wgsr1UNJbN3fF7KkC+0y66tORpodXxqcr7YJr4emmh51nXikz2YktA15US C6Wi+GSzYDZ1VXq1CcwcjPHbIM63Uk8lSW7ysG/f85L51AmzuWpNz+yTmEqEhMdt4l59 as21yGAjN1aK+xgVr7gwH90NpVpN/IKzgSRhxJGWnAgpUq+A68yoqiHRmyPuHEBhDPEg ccZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nG3DFDpR8eEVqCYgp6fdjUXCPRAolJB0lLDk+7ZmuP0=; b=cMSkUmPltKlgPePHtpJwat4ZDcJg0JvkOOWwZNJVPRZK3H/YYfCKSO01vEtePAVDSR SMJxFIqR2NqN51FnNKNioKhkMOOBwAYRctr4bWOb85z4Yi8h9taDkqOuOp8u5ZMJt01E UgvXWWuPgTIGCQ2KbY9IruwQGNIVgEuef1BSvrxgWp4HNeJt5bfcjZNKH90qXbfUr7Ef YcM9tnrqIy5RuBbhKIEtMYIVuwqTHQdxtTLtvTJkOBw8W99u7gnXXTnZxJAPyO+B+dXy jAO50rmqkpFZICyAzhA6TnysCfpeDLhVkTY2xH1BI3zR9z5iCfmx+nRqPOLxW5FLWvlk nRPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=prAHLc75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gy23-20020a170906f25700b00780f495d6bdsi1228312ejb.215.2022.09.27.07.11.16; Tue, 27 Sep 2022 07:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=prAHLc75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232810AbiI0NUt (ORCPT + 99 others); Tue, 27 Sep 2022 09:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232439AbiI0NTM (ORCPT ); Tue, 27 Sep 2022 09:19:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D651818B49E; Tue, 27 Sep 2022 06:17:36 -0700 (PDT) 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 ACD2861993; Tue, 27 Sep 2022 13:17:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0B7CC433D7; Tue, 27 Sep 2022 13:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284649; bh=FVapCLCMBFHoRGadwccT/R6zj9iqxDxY8mFOufu6k/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=prAHLc750vnY4t9ZCgdqGMIYpFyZoa6GPpixK7E3xUYjkRjrASv6dEqpdvilkRk3G wzY/QPzGQsaMWYftQ8vMJi5kXYpaWk2vrbZ4PBm7YBtEjs1krVTUQiRe7oqkOVyW92 HpmgEDKYS4I6KfLr4MEn3atGzQyDVgNF40V2UEpnxRuZPOcLJcH9J5k17VOOUELiw7 cYZZUCt7y7Pj8Tp2FWRmqiJ2DARJ0dr40TQi4NJnP0245O+KGnobon0IV0xrCVtxOg 4gdVHGDjTDZfbzFnt2HPHMzwjOD/32NX1cvI2tLztdccThdxnWrRTi45wduTsCUMAm Lpimkv84GPNIw== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Daniel Xu , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= Subject: [PATCH v10 21/27] scripts: add `is_rust_module.sh` Date: Tue, 27 Sep 2022 15:14:52 +0200 Message-Id: <20220927131518.30000-22-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Xu This script is used to detect whether a kernel module is written in Rust. It will later be used to disable BTF generation on Rust modules as BTF does not yet support Rust. Reviewed-by: Kees Cook Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Signed-off-by: Daniel Xu Co-developed-by: Miguel Ojeda Signed-off-by: Miguel Ojeda --- scripts/is_rust_module.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 scripts/is_rust_module.sh diff --git a/scripts/is_rust_module.sh b/scripts/is_rust_module.sh new file mode 100755 index 000000000000..28b3831a7593 --- /dev/null +++ b/scripts/is_rust_module.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# is_rust_module.sh module.ko +# +# Returns `0` if `module.ko` is a Rust module, `1` otherwise. + +set -e + +# Using the `16_` prefix ensures other symbols with the same substring +# are not picked up (even if it would be unlikely). The last part is +# used just in case LLVM decides to use the `.` suffix. +# +# In the future, checking for the `.comment` section may be another +# option, see https://github.com/rust-lang/rust/pull/97550. +${NM} "$*" | grep -qE '^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$' -- 2.37.3