Skip to content

Commit e4b69cb

Browse files
danobiojeda
authored andcommitted
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 <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Co-developed-by: Alex Gaynor <[email protected]> Signed-off-by: Alex Gaynor <[email protected]> Co-developed-by: Wedson Almeida Filho <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]> Signed-off-by: Daniel Xu <[email protected]> Co-developed-by: Miguel Ojeda <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 78521f3 commit e4b69cb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

scripts/is_rust_module.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:]]*$'

0 commit comments

Comments
 (0)