Cross compiling a kernel module: invalid module format

送分小仙女□ 提交于 2019-12-19 09:05:09

问题


I'm trying to cross compile a helloworld kernel module with specifications:

  • host: intel x86 32 bit, linux-3.0.0
  • target: ARM machine (Parrot AR.Drone), linux-2.6.27.47

I'm using the makefile:

PWD := $(shell pwd)
obj-m := test.o
all:
    $(MAKE) -C /path/to/kernel M=$(PWD) CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm  modules

Where arm-none-linux-gnueabi- is the prefix of the arm toolchain.

As kernel, I tried using a clone from git://github.com/CyanogenMod/cm-kernel.git as kernel. This is a 2.6 kernel fork. Using this kernel, compilation was successfull. When trying to insert the module, it gives the error:

invalid module format

Which, sadly, says very little.


回答1:


Thanks to the hint of Eugene to use dmesg, I found the error:

version magic '2.6.37.6 mod_unload modversions ARMv5 ' should be '2.6.27.47-parrot preempt mod_unload ARMv5 '

Conclusion: when compiling a kernel module, not only versions need to match, but also some config-parameters. My problem was solved by using the right version and editing the configuration.

If you don't want to reconfigure everything, a quick (ugly) fix is to edit include/generated/autoconf.h




回答2:


my ugly fix is modifing script file "scripts/setlocalversion"

170         if test "${LOCALVERSION+set}" != "set"; then
171                 scm=$(scm_version --short)
172 #               res="$res${scm:++}"
173                 res="${res}"
174         fi

Hi, everyone.. I did found simple soulution.

just modify envirionment vairable

export LOCALVERSION=

that's all



来源:https://stackoverflow.com/questions/9341701/cross-compiling-a-kernel-module-invalid-module-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!