insmod: no symbol version for module_layout

insmod: no symbol version for module_layout  

2011-03-21 11:24:25|  分类: 操作系统 |  标签: |字号 订阅

解决方法汇总:

The package kernel-default-devel was missing. To install it, run this command as root:
zypper in kernel-default-devel

The answer..... incorrect information to begin with.

The instructions I followed used the following make command:
make -C /usr/src/`uname -r` M=`pwd` modules
the code compiled... but I had the issues I reported.

using this:
make -C /lib/modules/`uname -r`/build M=`pwd` modules
allowed me to compile and insert my module with out any issues.

So apparently there is some difference in the configuration information provided in the modules/build directory ... when I have time I will investigate more.

I would still like to know what "no symbol version for module_layout" means... I'm curious that way, but I will take this as a small success and move on.

 

1.Invalid module format
编译环境:PC Ubuntu 9.10(Linux-2.6.31)
比如编译2.6.31下的usbserial.ko,当insmod之后出现
insmod: error inserting 'usbserial.ko': -1 Invalid module format
dmesg后有如下信息:
usbserial: no symbol version for module_layout
网络上查找信息,说是当前编译的源码版本跟系统内核的版本没有一致。这就无法理解了,我的源码是用Ubuntu自带的新立得下的,说版本不一致很让人费解。至于相关的信息可查看:内核模块加载时的版本检查
也有些人说是编译器版本不同造成的,觉得不太可能。而且也有高人指点,明确这跟编译器无关,就是源码问题。网上找的帖子确实未能解决掉这个问题。
解决办法:使用PC自带的头文件,首先用uname -a查看自己内核版本,比如我的是:
Linux Pro 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:54:29 UTC 2009 i686 GNU/Linux
于是在Makefile中将路径改为:
KERNELDIR := /usr/src/linux-headers-2.6.31-15-generic
或者KERNELDIR := /usr/src/linux-headers-$(uname -r)
再次编译,成功通过。
 
2.insmod时出现Unknown symbol in module
添加MODULE_LICENSE("GPL");

你可能感兴趣的:(linux,文档)