d*******o 发帖数: 5897 | 1 刚学内核模块编程不久,照着网上的Linux Kernel Module Programming学的。现在有
个问题,如果我的kernel source code要调用非linux kernel source的函数,应该怎
么做呢?比如我现在的目录结构是:
/usr/src/linux 放的是linux kernel source
/usr/src/xenomai 放的是一个第三方的kernel patch和source,上面的linux kernel
source已经被这个目录下的source patch过,
我自己要写的kernel module放在
/home/pcuser/mymodule下,就一个文件,mymod.c,init函数里调用了/usr/src/
xenomai的kernel space API。
通过加-I -L选项,我能编译mymod.c,得到mymod.ko。但是insmod mymod.ko时,报错
,说有Undefined symbol,就是这个第三方的函数。这个第三方的source code有自己
的Makefile,在它的顶层目录里make是可以make出给用户用的libraries的。可是在我
自己的module source目录里,我怎么能和这个第三方的source联系起来呢? |
x****s 发帖数: 921 | 2 insmod 是安装。你当前运行的kernel是patch的?
kernel
【在 d*******o 的大作中提到】 : 刚学内核模块编程不久,照着网上的Linux Kernel Module Programming学的。现在有 : 个问题,如果我的kernel source code要调用非linux kernel source的函数,应该怎 : 么做呢?比如我现在的目录结构是: : /usr/src/linux 放的是linux kernel source : /usr/src/xenomai 放的是一个第三方的kernel patch和source,上面的linux kernel : source已经被这个目录下的source patch过, : : 我自己要写的kernel module放在 : /home/pcuser/mymodule下,就一个文件,mymod.c,init函数里调用了/usr/src/ : xenomai的kernel space API。
|
d*******o 发帖数: 5897 | 3 对的,我已经编译了patch过的内核,现在系统运行的就是这个新内核。
【在 x****s 的大作中提到】 : insmod 是安装。你当前运行的kernel是patch的? : : kernel
|
x****s 发帖数: 921 | 4 then if the kernel not stripped, you can double check your running kernel
indeed has the new method by grep name on the kernnel image
after this, i don,t have too much ideas, try google
【在 d*******o 的大作中提到】 : 对的,我已经编译了patch过的内核,现在系统运行的就是这个新内核。
|
x****o 发帖数: 21566 | 5 static library?
If so, make sure they all appear in Makefile
e.g, in Makefile
...
obj-m := foo.o
foo-objs := yourcode.o xenomai.a
...
google "kernel module static library" or something similar maybe |
S*A 发帖数: 7142 | 6 You need to make sure your module is using the
the xenomai kernel as the Kbuild source kernel.
Also you need to make sure the symbol you used in
the xenomai kernel is exported as kernel symbols.
You can try to locate the symbol in /proc/kallsyms.
If it is not in there, then you need to export those symbol
in the kernel first before they can be used in the module. |
b*****n 发帖数: 482 | 7 嗯,看着象是没有export symbol的样子
【在 S*A 的大作中提到】 : You need to make sure your module is using the : the xenomai kernel as the Kbuild source kernel. : Also you need to make sure the symbol you used in : the xenomai kernel is exported as kernel symbols. : You can try to locate the symbol in /proc/kallsyms. : If it is not in there, then you need to export those symbol : in the kernel first before they can be used in the module.
|
g*****n 发帖数: 44 | 8 用nm查看一下哪些symbols没有undefined, 然后看看内核export没有。
kernel
【在 d*******o 的大作中提到】 : 刚学内核模块编程不久,照着网上的Linux Kernel Module Programming学的。现在有 : 个问题,如果我的kernel source code要调用非linux kernel source的函数,应该怎 : 么做呢?比如我现在的目录结构是: : /usr/src/linux 放的是linux kernel source : /usr/src/xenomai 放的是一个第三方的kernel patch和source,上面的linux kernel : source已经被这个目录下的source patch过, : : 我自己要写的kernel module放在 : /home/pcuser/mymodule下,就一个文件,mymod.c,init函数里调用了/usr/src/ : xenomai的kernel space API。
|