linux驱动备忘录

驱动签名

1
2
3
4
5
CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
 
${KERNEL_SRC}/scripts/sign-file sha512 ${KERNEL_SRC}/certs/signing_key.pem ${KERNEL_SRC}/certs/signing_key.x509 hello.ko

驱动调试

debugee

1
2
3
4
5
6
7
MOD_NAME=simple_mod
insmod ./${MOD_NAME}.ko
MOD_TEXT=`cat /sys/module/${MOD_NAME}/sections/.text`
MOD_DATA=`cat /sys/module/${MOD_NAME}/sections/.data`
MOD_BSS=`cat /sys/module/${MOD_NAME}/sections/.bss`
MOD_ADD="add-symbol-file /path/to/${MOD_NAME}.ko ${MOD_TEXT} -s .data ${MOD_DATA} -s .bss ${MOD_BSS}"
echo ${MOD_ADD}

debugger

1
(gdb) ${MOD_ADD}

refer to:
https://www.cnblogs.com/rivsidn/p/9481037.html
https://www.cnblogs.com/powerrailgun/p/12161295.html
https://blog.csdn.net/chdhust/article/details/8820628