File tree Expand file tree Collapse file tree 3 files changed +17
-14
lines changed Expand file tree Collapse file tree 3 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -503,6 +503,15 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
503
503
/// Used by the printing macros, e.g. [`info!`].
504
504
const __LOG_PREFIX: &[u8] = b\" {name}\\ 0\" ;
505
505
506
+ /// The \" Rust loadable module\" mark, for `scripts/is_rust_module.sh`.
507
+ //
508
+ // This may be best done another way later on, e.g. as a new modinfo
509
+ // key or a new section. For the moment, keep it simple.
510
+ #[cfg(MODULE)]
511
+ #[doc(hidden)]
512
+ #[used]
513
+ static __IS_RUST_MODULE: () = ();
514
+
506
515
static mut __MOD: Option<{type_}> = None;
507
516
508
517
// SAFETY: `__this_module` is constructed by the kernel at load time and will not be freed until the module is unloaded.
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ quiet_cmd_btf_ko = BTF [M] $@
41
41
cmd_btf_ko = \
42
42
if [ ! -f vmlinux ]; then \
43
43
printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
44
- elif $(srctree)/scripts/is_rust_module.sh $@; then \
44
+ elif [ -n "$(CONFIG_RUST)" ] && $(srctree)/scripts/is_rust_module.sh $@; then \
45
45
printf "Skipping BTF generation for %s because it's a Rust module\n" $@ 1>&2; \
46
46
else \
47
47
LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
# SPDX-License-Identifier: GPL-2.0
3
3
#
4
- # is_rust_module.sh MOD .ko
4
+ # is_rust_module.sh module .ko
5
5
#
6
- # Returns 0 if MOD .ko is a rust module, 1 otherwise.
6
+ # Returns `0` if `module .ko` is a Rust module, `1` otherwise.
7
7
8
8
set -e
9
- module=" $* "
10
9
11
- while IFS= read -r line
12
- do
13
- # Any symbol beginning with "_R" is a v0 mangled rust symbol
14
- if [[ $line =~ ^[0-9a-fA-F]+[[:space:]]+[uUtTrR][[:space:]]+_R[^[:space:]]+$ ]]; then
15
- exit 0
16
- fi
17
- done < < (nm " $module " )
18
-
19
- exit 1
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
+ ${NM} " $* " | grep -qE ' ^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'
You can’t perform that action at this time.
0 commit comments