40 lines
593 B
Bash
Executable File
40 lines
593 B
Bash
Executable File
#!/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 "$@"
|