/opt/autorun # insmod board_config.ko
board_config: disagrees about version of symbol __class_create
board_config: Unknown symbol __class_create (err -22)
board_config: disagrees about version of symbol class_destroy
board_config: Unknown symbol class_destroy (err -22)
board_config: disagrees about version of symbol device_create
board_config: Unknown symbol device_create (err -22)
board_config: disagrees about version of symbol device_destroy
board_config: Unknown symbol device_destroy (err -22)
insmod: can’t insert ‘board_config.ko’: invalid parameter
用modinfo命令查看:modinfo board_config.ko后如下所示:
filename: board_config.ko
license: GPL
depends:
vermagic: 2.6.37 mod_unload modversions ARMv7 p2v8
wdove很好的解释了这个问题,在此感谢!原文http://blog.csdn.net/wdove/article/details/5329783
下面转载其解释:
最开始下载的内核源码和机子的kernel不匹配,参照http://blog.csdn.net/hecant/archive/2007/10/31/1859606.aspx:
static int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
const char *symname,
struct module *mod,
const unsigned long *crc,
const struct module *crc_owner)
{
unsigned int i, num_versions;
struct modversion_info *versions;
/* Exporting module didn't supply crcs? OK, we're already tainted. */
if (!crc)
return 1;
/* No versions at all? modprobe --force does this. */
if (versindex == 0)
return try_to_force_load(mod, symname) == 0;
versions = (void *) sechdrs[versindex].sh_addr;
num_versions = sechdrs[versindex].sh_size
/ sizeof(struct modversion_info);
for (i = 0; i < num_versions; i++) {
if (strcmp(versions[i].name, symname) != 0)
continue;
if (versions[i].crc == maybe_relocated(*crc, crc_owner))
return 1;
DEBUGP("Found checksum %lX vs module %lX\n",
maybe_relocated(*crc, crc_owner), versions[i].crc);
goto bad_version;
}
printk(KERN_WARNING "%s: no symbol version for %s\n",
mod->name, symname);
return 0;
bad_version:
printk("%s: disagrees about version of symbol %s\n",
mod->name, symname);
return 0;
}
static inline int check_modstruct_version(Elf_Shdr *sechdrs,
unsigned int versindex,
struct module *mod)
{
const unsigned long *crc;
if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
&crc, true, false))
BUG();
return check_version(sechdrs, versindex, "module_layout", mod, crc,
NULL);
}
/* First part is kernel version, which we ignore if module has crcs. */
static inline int same_magic(const char *amagic, const char *bmagic,
bool has_crcs)
{
if (has_crcs) {
amagic += strcspn(amagic, " ");
bmagic += strcspn(bmagic, " ");
}
return strcmp(amagic, bmagic) == 0;
}
static noinline struct module *load_module(void __user *umod,
unsigned long len,
const char __user *uargs)
{
/* Check module struct version now, before we try to use module. */
/*检查crc*/
if (!check_modstruct_version(sechdrs, versindex, mod)) {
err = -ENOEXEC;
goto free_hdr;
}
modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
/* This is allowed: modprobe --force will invalidate it. */
if (!modmagic) {
err = try_to_force_load(mod, "bad vermagic");
if (err)
goto free_hdr;
/*检查魔术字*/
} else if (!same_magic(modmagic, vermagic, versindex)) {
printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
mod->name, modmagic, vermagic);
err = -ENOEXEC;
goto free_hdr;
}
}
x
23
1
static int check_version(Elf_Shdr *sechdrs,
2
unsigned int versindex,
3
const char *symname,
4
struct module *mod,
5
const unsigned long *crc,
6
const struct module *crc_owner)
7
{
8
unsigned int i, num_versions;
9
struct modversion_info *versions;
10
11
/* Exporting module didn't supply crcs? OK, we're already tainted. */
12
if (!crc)
13
return 1;
14
15
/* No versions at all? modprobe --force does this. */
16
if (versindex == 0)
17
return try_to_force_load(mod, symname) == 0;
18
19
versions = (void *) sechdrs[versindex].sh_addr;
20
num_versions = sechdrs[versindex].sh_size
21
/ sizeof(struct modversion_info);
22
23
for (i = 0; i < num_versions; i++) {
24
if (strcmp(versions[i].name, symname) != 0)
25
continue;
26
27
if (versions[i].crc == maybe_relocated(*crc, crc_owner))
28
return 1;
29
DEBUGP("Found checksum %lX vs module %lX\n",
30
maybe_relocated(*crc, crc_owner), versions[i].crc);
31
goto bad_version;
32
}
33
34
printk(KERN_WARNING "%s: no symbol version for %s\n",
35
mod->name, symname);
36
return 0;
37
38
bad_version:
39
printk("%s: disagrees about version of symbol %s\n",
40
mod->name, symname);
41
return 0;
42
}
43
44
static inline int check_modstruct_version(Elf_Shdr *sechdrs,
45
unsigned int versindex,
46
struct module *mod)
47
{
48
const unsigned long *crc;
49
50
if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
51
&crc, true, false))
52
BUG();
53
return check_version(sechdrs, versindex, "module_layout", mod, crc,
54
NULL);
55
}
56
57
/* First part is kernel version, which we ignore if module has crcs. */
58
static inline int same_magic(const char *amagic, const char *bmagic,
59
bool has_crcs)
60
{
61
if (has_crcs) {
62
amagic += strcspn(amagic, " ");
63
bmagic += strcspn(bmagic, " ");
64
}
65
return strcmp(amagic, bmagic) == 0;
66
}
67
static noinline struct module *load_module(void __user *umod,
68
unsigned long len,
69
const char __user *uargs)
70
{
71
72
/* Check module struct version now, before we try to use module. */
73
/*检查crc*/
74
if (!check_modstruct_version(sechdrs, versindex, mod)) {
75
err = -ENOEXEC;
76
goto free_hdr;
77
}
78
79
modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
80
/* This is allowed: modprobe --force will invalidate it. */
81
if (!modmagic) {
82
err = try_to_force_load(mod, "bad vermagic");
83
if (err)
84
goto free_hdr;
85
/*检查魔术字*/
86
} else if (!same_magic(modmagic, vermagic, versindex)) {
87
printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
88
mod->name, modmagic, vermagic);
89
err = -ENOEXEC;
90
goto free_hdr;
91
}
92
}
解决方法: