MIPS32 router: module_init not called for kernel module

前端 未结 1 1626
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 03:09

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

相关标签:
1条回答
  • 2021-01-21 03:52

    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!

    0 讨论(0)
提交回复
热议问题