多個源文件編譯生成一個內核模塊
例如,將hello.c和world.c兩個c文件編譯生成一個叫hello_world.o的目標文件,則在Makefile
中添加以下兩句:
obj-m:=hello_world.o
hello_world-objs=hello.cworld.c
內核污染
insmod
ko模塊時,可能出現如下提示:
loadingout-of-tree
module
taintskernel
幾個可能原因:
-
模塊沒有聲明
GPL
協議 - 當前linux內核版本和編譯模塊使用的內核版本不一致
- 使用內核源代碼未包含的樹外模塊
printk和printf
在內核中的打印函數是printk
,printk
和printf
的行為非常相似,但是通常printk不支持浮點數,例如要打印一個浮點變量,在編譯時通常會出現如下警告,并且模塊也不會加載成功:
WARNING:
"__extendsfdf2"
[/home/ubuntu/driver/user.ko]undefined!
WARNING:
"__truncdfsf2"
[/home/ubuntu/driver/user.ko]undefined!
WARNING:
"__divdf32"
[/home/ubuntu/driver/user.ko]undefined!
WARNING:
"__floatsidf"
[/home/ubuntu/driver/user.ko]undefined!
-
模塊
+關注
關注
7文章
2735瀏覽量
47750 -
內核
+關注
關注
3文章
1382瀏覽量
40425 -
Linux
+關注
關注
87文章
11345瀏覽量
210399 -
源文件
+關注
關注
0文章
30瀏覽量
4612
發布評論請先 登錄
相關推薦
評論