Insert linux kernel module statically
When building the Linux kernel from sources one could decide if a certain functionality is statically built into the kernel or packed into a module for dynamic insertion by .config.
If on the other hand I have sources for any 3rd p开发者_如何学编程arty module, like for example a packaged device driver, is it possible to programmatically integrate this code into the kernel statically instead? And not load the kernel module from the root filesystem?
Sure, you just need to do a bit of hacking to move the external module into the kernel source tree, tweak the Makefiles/Kconfig a bit so that the code is built-in, and then build your kernel image. For example, let's say you move the module source into drivers/blah
. Then you should add a line to then end of drivers/Makefile
like
obj-y += blah/
and you should make sure that drivers/blah/Makefile
is set up to build your module in, with something like
obj-y += mymodule.o
mymodule-objs := src.o other.o
and so on, where your Makefile is set up however it needs to be to build the particular module you're working on. Note: You have to use the output file name for mymodule-objs and not the input filename!
精彩评论