編譯一個內核時,習慣性的在install目標下加了命令:
$(STRIP)? --strip-all --remove-section=.note --remove-section=.comment? test.ko
結果在insmod test.ko時出現錯誤:
test: module has no symbols (stripped?)
..................
?上網查了以下,發現內核模塊在插入時,insmod會使用模塊的一些符號信息。那是不是內核模塊不可以被stip呢?答案是可以strp 但不能strip太多東西,應該使用:
$(STRIP)? --strip-debug test.ko
另外:內核模塊的version magic的問題:
插入模塊出現錯誤:
test: version magic '2.6.15 gcc-3.4' should be '2.6.14 gcc-3.4'
內核模塊對應的內核版本不對,可以修改內核版本代號試一試:
修改liunx源碼下的Makefile 前面的版本定義,然后重新編譯內核,再編譯內核模塊。當然這樣做可能會有副作用。
查看一個模塊的version magic信息:
$modinfo test.ko
file test.ko 也可以用于查看ko文件的信息