mkkmod/build-module.sh

40 lines
593 B
Bash
Raw Permalink Normal View History

2024-07-12 22:56:47 +00:00
#!/bin/bash
#
# Usage: ./build-module.sh path-to-my-embed-binary
set -eu
main() {
local embedbin="$1"
if [[ ! -f $embedbin ]] ; then
echo "Can't find '$embedbin' to embed" >&2
exit 1
fi
# Generate asm include file
cat > eprog_user_blob.S <<EOF
.section .init.rodata, "a"
.global embedded_umh_start
embedded_umh_start:
.incbin "$(realpath "$embedbin")"
.global embedded_umh_end
embedded_umh_end:
EOF
# Build the kernel module
make clean
make
# Finished
test -f eprog.ko
echo "Build complete."
}
main "$@"