交叉编译内核模块:无效的模块格式 [英] Cross compiling a kernel module: invalid module format

查看:37
本文介绍了交叉编译内核模块:无效的模块格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试交叉编译具有规范的 helloworld 内核模块:

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

  • 主机:intel x86 32 位,linux-3.0.0
  • 目标:ARM 机器(Parrot AR.Drone),linux-2.6.27.47

我正在使用生成文件:

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

其中 arm-none-linux-gnueabi- 是 arm 工具链的前缀.

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

作为内核,我尝试使用来自 git://github.com/CyanogenMod/cm-kernel.git 的克隆作为内核.这是一个 2.6 内核分支.使用这个内核,编译成功.尝试插入模块时,出现错误:

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.

推荐答案

感谢Eugene提示使用dmesg,发现错误:

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.

如果您不想重新配置所有内容,一个快速(丑陋)的解决方法是编辑 include/generated/autoconf.h

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

这篇关于交叉编译内核模块:无效的模块格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆