is_rust_module.sh 565 B

12345678910111213141516
  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. set -e
  8. # Using the `16_` prefix ensures other symbols with the same substring
  9. # are not picked up (even if it would be unlikely). The last part is
  10. # used just in case LLVM decides to use the `.` suffix.
  11. #
  12. # In the future, checking for the `.comment` section may be another
  13. # option, see https://github.com/rust-lang/rust/pull/97550.
  14. ${NM} "$*" | grep -qE '^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'