我在自己的電腦上編譯 kernel module
kernel 4.15.0-36-generic
程式碼僅有
static int driver_entry(void) {
printk(KERN_INFO "eeeentry");
return 0;
}
static void driver_exit(void) {
printk(KERN_INFO "Good bye");
}
module_init(driver_entry);
module_exit(driver_exit);
MODULE_LICENSE("GPL");
但我不知道為何 insmod 和 rmmod 時,印出的順序是相反的XD,insmod 印出 Good bye
rmmod 印出eeeentry
[ 131.604421] sayHello: loading out-of-tree module taints kernel.
[ 131.604458] sayHello: module verification failed: signature and/or
required key missing - tainting kernel
[ 131.606243] eeeentry
[ 151.454288] Good bye
[ 324.322405] eeeentry
[ 372.027624] Good bye
[ 430.550556] eeeentry