Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts: add `is_rust_module.sh`

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 <keescook@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Co-developed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Daniel Xu and committed by
Miguel Ojeda
e4b69cb9 78521f33

+16
+16
scripts/is_rust_module.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # is_rust_module.sh module.ko 5 + # 6 + # Returns `0` if `module.ko` is a Rust module, `1` otherwise. 7 + 8 + set -e 9 + 10 + # Using the `16_` prefix ensures other symbols with the same substring 11 + # are not picked up (even if it would be unlikely). The last part is 12 + # used just in case LLVM decides to use the `.` suffix. 13 + # 14 + # In the future, checking for the `.comment` section may be another 15 + # option, see https://github.com/rust-lang/rust/pull/97550. 16 + ${NM} "$*" | grep -qE '^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'