I\'m developing a kernel module that I want to run on my router. The router model is DGN2200v2 by Netgear. It\'s running Linux 2.6.30 on MIPS. My problem is that when I load my
It turns out that the problem was related to a different kernel configuration between my development environment and the router. Specifically, my kernel was using CONFIG_UNUSED_SYMBOLS
whereas the router's was not.
The reason this caused a problem even in a trivial module is that when the kernel loads a module it doesn't only look up the module_init
symbol in the module's symbol table. Rather, it reads the module
struct from the module (from the .gnu.linkonce.this_module
section), and then calls the init
module through that struct.
The offset of the init
function pointer inside the module
struct depends on the kernel configuration, which explains why the kernel can't find the init
function if the configuration is different.
Thanks to Sam Protsenko for investing a lot of time in helping me crack this!