[问题] build kernel module

楼主: summerdog ( . 人 .)   2014-04-02 19:54:26
在进行android embedded system开发时
遇到了kernel module编译的小问题, 还请各位指教, 谢谢!
Q1 :
假如我只想要单build kernel module ,
我需要完整的kernel source tree吗?
还是只需要kernel source 的 header file package?
A1 :
有些部落格提到是下载整个kernel source tree,
然后还要把这个kernel source tree给build过一次 ...
可是我从国外网站查到的答案如下,
简单来说就是不需要kernel source tree, 只需要kernel headers
请问各位是如何处理的呢 @@?
ref - http://ppt.cc/Tl91
In order to build a kernel module, we need the kernel headers
(or kernel source) that match the binary image.
The headers provide vital definitions that are needed
in order to compile the source code for the module.
The compressed source code is about 110MBytes in size.
This is the full source for the kernel including all of the headers.
Strictly speaking, we just need the headers, but you might want to
explore the kernel, other kernel modules, ARM-specific support code,
or the PERF subsystem. It’s all there.
ref - http://ppt.cc/Fuy8
To be frank you do not need a new full source tree in order to
just compile or build module against the running kernel
i.e an exploded source tree is not required to build kernel driver or module.
Please note that to work with this hack you just need the Linux kernel
headers
and not the full kernel source tree.
也就是说
通常下载的 kernel source code 会在 /usr/src/linux-xxx
/lib/modules/3.6.11+/build 这边的build 会 ln 到 上面的位址
如果没有 就手动建立link
ln -s /usr/src/linux /lib/modules/3.6.11+/build
note.
上面那个build你可以连到 kernel source header only
或 kernel full source
================================================================================
Q2.
一般我们build一个c程式, 在link 其他 library 时有两种case:
a. standard c library , 这不需要特别指定路径,
gcc 会去 /usr/include 找header ,
去 /usr/lib 找 libc.a libc.so
b. 3rd party library, 这就要指定
header file 及 library binary(*.a / *.so) 的位置
然而在build kernel module的时候,
怎没看到需要去指定library的动作呢 ?
我的意思是, 自订的 kernel module 中会include 到
platform.h init.h 之类非standard c 的 部份 ,
这些部份在build kernel module的时候是如何处理的?
文长请多包含 谢谢!
作者: leveler   2014-04-04 08:36:00
1.这要看你的module 是否能够 out of tree compile2.kernel_src 变量指定

Links booklink

Contact Us: admin [ a t ] ucptt.com