PDA

View Full Version : Error inserting './hello.ko': -1 Invalid module format



Nishant
11-29-2006, 12:51 AM
Dear All,

I am somewhat new to the Linux programmig.

I have created one program new.c and compile it to make new.o, when i tried to insert the new.o through command 'insmod new.o', it gives me an error that:

"Error inserting './hello.ko': -1 Invalid module format"

I know that this error is because of my kernel version is not the one on which i am running the insmod command, but i dont know what to do to sort out this problem?

Please action i should take to sort out this problem?

Thanks,
Nishant

cmn
11-29-2006, 07:50 AM
Hi Nishant,

A few questions related to your problem:

What does the `uname -r` command output?

What does /(path to your kernel source)/include/version.h say?

What is the return code from insmod? (`echo $?`)

-C

Salem
11-29-2006, 01:38 PM
So can we take it that you've read http://tldp.org/HOWTO/Module-HOWTO/
and compiled it as a kernel module?

Mad_guy
11-30-2006, 11:28 PM
I have created one program new.c and compile it to make new.o, when i tried to insert the new.o through command 'insmod new.o', it gives me an error that:

"Error inserting './hello.ko': -1 Invalid module format"
First, you can't just compile an application and expect it to load into the kernel if that's what you're trying to do. Second, a .o file as such from a straight compile is just an object file; even if you did load it your kernel somehow would probably crash because your object file hasn't been relocated and linked properly (meaning you'll do things like "call 00000000" in your driver's assembly depending on compiler implementation, etc..) You need a particular makefile and a make command to get your code to build into a proper .ko file that's loadable by the kernel, check out Linux Device Drivers, 3rd Ed. (http://lwn.net/Kernel/LDD3/) for more info on this (if you're still using the 2.4 kernel then find the second edition, it's also free online.)


I know that this error is because of my kernel version is not the one on which i am running the insmod command, but i dont know what to do to sort out this problem?
? I don't quite understand this question, are you saying that your kernel version isn't the same one of the driver or something (2.4 and 2.6 use slightly different driver models.)