2010年12月14日 星期二

How to link pre-built kernel module

有些情況下
你會希望額外寫的kernel module會用到另一個pre-built好的ko
可是在原先build procedure裡頭
linux並不知道你事先pre-built好的module symbol
因此它在link之前會發現symbol undefine
WARNING: "abc_xxx_yyy_set" [drivers/net/abc/xxx.ko] undefined!

比較簡單的解決方法如下:
在linux-2.6.x/scripts/Makefile.modpost裡頭
加上
KBUILD_MODPOST_WARN := 1

這樣還是會出現原先那些WARNING
因為在這次的build procedure它的確還是不知道這幾個symbol在哪
但是它可以讓你繼續編過

詳細的部分可以參考linux文件目錄下面的Document/kbuild/kbuild.txt

165 KBUILD_MODPOST_WARN
166 --------------------------------------------------
167 KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
168 symbols in the final module linking stage. It changes such errors
169 into warnings.
170
171 KBUILD_MODPOST_NOFINAL
172 --------------------------------------------------
173 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
174 This is solely useful to speed up test compiles.
175
176 KBUILD_EXTRA_SYMBOLS
177 --------------------------------------------------
178 For modules that use symbols from other modules.
179 See more details in modules.txt.


沒有留言:

張貼留言