linux compile source to ko(kernel object) successfully!
来源:互联网 发布:linux安装分区方案 编辑:程序博客网 时间:2024/05/18 17:04
source:
#include <linux/module.h>#include <linux/kernel.h>#include <linux/init.h>//模块许可证声明(必须)MODULE_LICENSE("Dual BSD/GPL");//模块加载函数(必须)static int hello_init(void){ printk(KERN_ALERT "Hello World enter\n"); return 0;}//模块卸载函数(必须)static void hello_exit(void){ printk(KERN_ALERT "Hello World exit\n");}//模块的注册module_init(hello_init);module_exit(hello_exit);//声明模块的作者(可选)MODULE_AUTHOR("xiuye");//声明模块的描述(可选)MODULE_DESCRIPTION("This is a simple example!/n");//声明模块的别名(可选)MODULE_ALIAS("A simplest example");Makefile:(note: UpperCase first letter file name)
obj-m += hello_linux_module.oall:$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modulesclean:$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) cleanterminal:
make
register ko file
sudo insmod ./hello_linux_module.ko
lsmod | grep hello
unregister ko file
sudo rmmod ./hello_linux_module.kohave a look at "ko" output:
tail /var/log/kern.log
0 0
- linux compile source to ko(kernel object) successfully!
- Compile linux kernel source
- How to Compile Linux Kernel from Source to Build Custom Kernel
- compile only one kernel module *.ko in linux
- How to Compile the Linux Kernel
- How to: Compile Linux kernel 2.6
- How to: Compile Linux kernel 2.6
- How to: Compile Linux kernel modules
- How to: Compile Linux kernel 2.6
- How to: Compile Linux kernel 2.6
- how to compile the linux kernel
- how to compile kernel
- how to compile kernel
- Compile Linux Kernel Modules
- Compile Linux kernel
- linux kernel compile
- Cross compile linux kernel
- How to Create, Compile, Load Linux LKM Loadable Kernel Modules
- golang获取命令行参数
- elasticsearch之更新文档
- 利用归并排序求逆序数对
- FreeCodeCamp学习--Chunky Monkey
- springmvc—AbstractWizardController
- linux compile source to ko(kernel object) successfully!
- 【进阶】MySQL中的连接查询
- Python Test使用
- 项目之从用户软件问题处理中论封装
- 1040. Longest Symmetric String (25)
- 子类无法修改父类的变量!!!
- 4.08,linux初学:基本的linux操作和vim操作
- visual studio 2017 update 1 出来了
- JavaAnnotation注解定义与使用