LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to change the vermagic of a module (http://www.linuxquestions.org/questions/linux-kernel-70/how-to-change-the-vermagic-of-a-module-728387/)

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

How to change the vermagic of a module
 
Hello,

I've got a binary only module build for kernel 2.6.25.9-76.fc9.i686, and I would like to use it on a '2.6.26.8-57.fc8.i686' kernel.

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

Code:

version magic '2.6.25.9-76.fc9.i686 SMP mod_unload 686 4KSTACKS ' should be '2.6.26.8-57.fc8 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:

2.6.26.8-57.fc8 SMP mod_unload 686 4KSTACKS
and on the driver I want to use:
Code:

2.6.25.9-76.fc9.i686 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:
Code:

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:
Code:

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

but the original driver have:
Code:

4 .modinfo      00000077  00000000  00000000  0000044c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

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...

regards

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 11:40 PM.