分享

insmod error

 hginvent 2014-05-13

During kernel development one often encounters these 2 frustrating errors upon insmod ing locally built ko modules.


Error1: <module-name> no symbol version for module_layout

Why?
This means that the Kernel source is NOT built. Once the entire kernel source is built, then a file Modules.symvers will be generated in the top-level directory of the Linux Kernel source. This will contain the address of the symbol module_layout. Henceforth, this will be used when any kernel modules are built.

Fix
Build the complete Kernel source. Ensure that Modules.symvers is generated and it contains a line with the symbol module_layout. Following this, build the kernel module.


Error2: <module-name> disagrees about version of symbol module_layout

Why?
The error means that the kernel source being used differs significantly from the one used to build the kernel image used to boot.

Fix
Manually modifying the ko module file to match the value of module_layout in the ko file with the value in the kernel image being used to boot.

To do so we first need to determine the valid value of module_layout. This is essentially present in each of the valid working ko files present on the system. A quick way to obtain this info is from a valid ko file that successfully loads. Use lsmod to get a list of potential "working.ko" files.

# modprobe --dump-modversions <working.ko> | grep module_layout
0x0b11e775      module_layout
# modprobe --dump-modversions <your.ko> | grep module_layout
0x2719d41e      module_layout

NOTE: IF there is no instance of module_layout symbol in your ko file then first follow steps to fix ERROR1 before proceeding below.

Using your favorite hex editor, find and replace the value (4 bytes) in your ko file with the value from the working ko file.

Before Modification:
00016c701e d4 19 276d 6f 64 75 6c 65 5f 6c 61 79 6f 75 |u...module_layou|

After Modification:
00016c7075 e7 11 0b6d 6f 64 75 6c 65 5f 6c 61 79 6f 75 |u...module_layou|


With the above changes, insmod ing the locally built ko file should be successfull.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多