-   Linux - Kernel (
-   -   How to change the vermagic of a module (

jf.argentino 05-25-2009 12:07 PM

How to change the vermagic of a module

I've got a binary only module build for kernel, and I would like to use it on a '' kernel.

When I try to "insmod" the module, I've got the following error:


version magic ' SMP mod_unload 686 4KSTACKS ' should be ' SMP mod_unload 686 4KSTACKS '
If I make a "modinfo -F vermagic" on one of the driver I'm using on my system, I've got:
Code: SMP mod_unload 686 4KSTACKS
and on the driver I want to use:
Code: SMP mod_unload 686 4KSTACKS
So to change this vermagic, I:
-create a file with the closed module .modsection contents,
-into this file I'm changing the vermagic with thhe target one
-then I "objcopy" like this:

objcopy --remove-section=.modinfo --add-section .modinfo=modinfo_file $MODULE
Then when I try to insmod the module, I've got an "Invalid module format" error, but dmesg say nothing more...

If I make an "objdump -h" on the module I can see that the .modinfo section now have following info:

10 .modinfo      00000072  00000000  00000000  0000165a  2**0
                  CONTENTS, READONLY

but the original driver have:

4 .modinfo      00000077  00000000  00000000  0000044c  2**2

I think that why I'm not able to load the modified module, but after some googling, I can't found any way how to adjust these section parameters. Can anybody tell me if:
-it's possible to do what I want to do since the kernels version are really close
-if it's the good way to do this
-how I can specify the section information to force its index, its offset, the alignment and add the "ALLOC", "LOAD", and "DATA" parameters...


Valery Reznic 05-26-2009 05:14 AM

You can use 'modprobe --force', so all version information will be ignored.

But version inserted (and checked) in the kernel modules for the reason:
if you force module loading kernel crash is likely.

All times are GMT -5. The time now is 07:45 PM.