开发者

module_layout version incompatibility

I t开发者_如何学Gory to insmod a linux kernel legacy module being ported by me. The following errors appear:

> sudo insmod camac-mx.ko
insmod: error inserting 'camac-mx.ko': -1 Invalid module format
dmesg |tail -n 1
[1312783.938299] camac_mx: disagrees about version of symbol module_layout

How do I fix this?


This indicates you have compiled the module against a different version of the kernel than is running. Note that even if the running kernel and kernel source have the same numerical value (e.g. both are 2.6.31-20-server), if the two use different configuration options, you may see this error. Also check if there are multiple versions of this module on the machine and ensure you are loading the correct one.


For those working on systems without access to kernel, kernel-config or ksyms, if you have a working.ko and your built, non-working, broken.ko.

Chances are it probably will not load, but if you are desperate enough to try;

# modprobe --dump-modversions working.ko
0x0b11e775      module_layout
# modprobe --dump-modversions broken.ko
0x2719d41e      module_layout

Then using your favourite hex editor, change it to match:

00016c70  75 e7 11 0b 6d 6f 64 75  6c 65 5f 6c 61 79 6f 75  |u...module_layou|

(Value is in reverse due to endian ordering) There will most likely be a whole bunch you have to match. Someone could write a perl script to do this....


To resolve that (was hard).

First, you need kernel sources and headers.

Go to your kernel base dir, here /usr/src/linux-source-2.6.35

Check uname -r , here 2.6.35-27-generic

make -C /lib/modules/2.6.35-27-generic/build \
SUBDIRS=/usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k modules

/lib/modules/2.6.35-27-generic/build -> /usr/src/linux-headers-2.6.35-27-generic

Check the module dependencies with modinfo or lsmod and load them in a script :

modprobe -r ath5k
modprobe cfg80211
modprobe led_class
modprobe mac80211
modprobe ath
insmod /usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k/ath5k.ko

With this method, vermagic could also be different.... the make modules_install was useless, but maybe because modules are present in 2 different places (/lib/modules/extra and .../kernel/drivers), not replaced...

modinfo -F vermagic /usr/src/linux-source-2.6.35/drivers/net/wireless/ath/ath5k/ath5k.ko

I dont really understand why it's so difficult in ubuntu 10.10 to fix/debug a module :(


Fast and working solution was found here.

Just use modules/build directory in your makefile, NOT /usr/src/linux-source.

    make -C /lib/modules/`uname -r`/build ...


I have android system with one binary module (pvrsrvkm for graphics). I have been building kernels from source for this system. In general all works fine, but with some kernel .config options (for kgdb), the pvrsrvkm module would not load with "disagrees about version of symbol" error.

The pvrsrvkm module is loaded by android early and when it fails the system is unusable with no GUI.

Since I was already building kernel, my quick fix was to disable version checking by adding one line (versindex = 0;) to kernel source file kernel/module.c:

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. */
versindex = 0; // I added this line
if (versindex == 0)
    return try_to_force_load(mod, symname) == 0;


Before in your source kernel

make clean ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

Edit the file in source kernel : Module.symvers change "Module_layout" with worked one, you can search this file on your device

Recompile driver example : make -C ~/source-kernel ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- DIR=/source-kernel M=/modules/example modules

Check module_layout in you XXX.ko with : sudo modprobe --dump-modversions XXX.ko

NB

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜