Linux .ko模块的生成方式
来源:互联网 发布:centos没有桌面文件夹 编辑:程序博客网 时间:2024/06/01 10:03
#include "linux/init.h" #include "linux/module.h" #include "linux/kernel.h" //必选 //模块许可声明 MODULE_LICENSE("Dual BSD/GPL"); //模块加载函数 static int hello_init(void) { printk(KERN_ALERT "hello,I am edsionte/n"); return 0; } //模块卸载函数 static void hello_exit(void) { printk(KERN_ALERT "goodbye,kernel/n"); } //模块注册 module_init(hello_init); module_exit(hello_exit); //可选 MODULE_AUTHOR("edsionte Wu"); MODULE_DESCRIPTION("This is a simple example!/n"); MODULE_ALIAS("A simplest example");
Makefile
obj-m += helloworld.o #generate the path CURRENT_PATH:=$(shell pwd) #the current kernel version number LINUX_KERNEL:=$(shell uname -r) #the absolute path LINUX_KERNEL_PATH:=/usr/src/linux-headers-$(LINUX_KERNEL) #complie object all: make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #clean clean: make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean
make -C /usr/src/linux-headers-3.19.0-25-generic M=/home/caozilong/WorkSpace/helloworld modules make[1]: 正在进入目录 `/usr/src/linux-headers-3.19.0-25-generic'test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \ echo >&2; \ echo >&2 " ERROR: Kernel configuration is invalid."; \ echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\ echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ echo >&2 ; \ /bin/false)mkdir -p /home/caozilong/WorkSpace/helloworld/.tmp_versions ; rm -f /home/caozilong/WorkSpace/helloworld/.tmp_versions/*make -f ./scripts/Makefile.build obj=/home/caozilong/WorkSpace/helloworld gcc -Wp,-MD,/home/caozilong/WorkSpace/helloworld/.helloworld.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -m64 -mno-80387 -mno-fp-ret-in-387 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(helloworld)" -D"KBUILD_MODNAME=KBUILD_STR(helloworld)" -c -o /home/caozilong/WorkSpace/helloworld/.tmp_helloworld.o /home/caozilong/WorkSpace/helloworld/helloworld.c if [ "-pg" = "-pg" ]; then if [ /home/caozilong/WorkSpace/helloworld/helloworld.o != "scripts/mod/empty.o" ]; then ./scripts/recordmcount "/home/caozilong/WorkSpace/helloworld/helloworld.o"; fi; fi;(cat /dev/null; echo kernel//home/caozilong/WorkSpace/helloworld/helloworld.ko;) > /home/caozilong/WorkSpace/helloworld/modules.ordermake -f ./scripts/Makefile.modpost find /home/caozilong/WorkSpace/helloworld/.tmp_versions -name '*.mod' | xargs -r grep -h '\.ko$' | sort -u | sed 's/\.ko$/.o/' | scripts/mod/modpost -m -a -i ./Module.symvers -I /home/caozilong/WorkSpace/helloworld/Module.symvers -o /home/caozilong/WorkSpace/helloworld/Module.symvers -S -w -s -T - gcc -Wp,-MD,/home/caozilong/WorkSpace/helloworld/.helloworld.mod.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -m64 -mno-80387 -mno-fp-ret-in-387 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(helloworld.mod)" -D"KBUILD_MODNAME=KBUILD_STR(helloworld)" -DMODULE -c -o /home/caozilong/WorkSpace/helloworld/helloworld.mod.o /home/caozilong/WorkSpace/helloworld/helloworld.mod.c **ld -r -m elf_x86_64 -T ./scripts/module-common.lds --build-id -o /home/caozilong/WorkSpace/helloworld/helloworld.ko /home/caozilong/WorkSpace/helloworld/helloworld.o /home/caozilong/WorkSpace/helloworld/helloworld.mod.o**make[1]:正在离开目录 `/usr/src/linux-headers-3.19.0-25-generic'
0 0
- Linux .ko模块的生成方式
- linux 系统 ko模块编译
- linux 系统 ko模块编译
- linux 系统 ko模块编译
- Linux 模块(ko)签名
- linux 模块层叠技术和多个ko的编译
- Linux下hello.ko内核模块制作的全过程
- Linux下hello.ko内核模块制作的全过程
- 让 Linux 启动时加载自己的驱动模块 .ko
- Linux下hello.ko内核模块制作的全过程
- 让 Linux 启动时加载自己的驱动模块 .ko
- 嵌入式linux 内核模块调试ko的 insmod问题
- hello world及内核模块 && 生成.ko的驱动改生成.o
- Linux外部模块.ko建立流程
- Linux内核驱动模块测试 hello.ko
- 多个*.c文件编译生成一个模块驱动*.ko的makefile文件编写
- [ARM-Linux开发]Linux下加载.ko驱动模块的两种方法:insmod与modprobe
- 嵌入式 linux如何生成ko文件
- Tensorflow计算模型 —— 计算图
- react 指令封装
- Java Servelet API入门基础教程
- Android缓存源码分析(DiskLruCache,LruCache)
- 两种情况下将两个整形变量的值进行交换
- Linux .ko模块的生成方式
- JAVA多态性的理解
- uva455 Periodic Strings
- 新手易犯错误集
- [cpp]c++11学习笔记-moden c++
- 最简便的备份MySql数据库方法
- 浅谈webpack的重要功能——Plugins
- numpy中数组的布尔型索引
- 《深入理解linux内核》读书笔记 -- 第一章 绪论