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

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    1

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

    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

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    1
    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

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So can we take it that you've read http://tldp.org/HOWTO/Module-HOWTO/
    and compiled it as a kernel module?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    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. 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.)
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Flood of errors when include .h
    By erik2004 in forum C++ Programming
    Replies: 14
    Last Post: 12-07-2002, 07:37 AM
  5. Function basics
    By sjleonard in forum C++ Programming
    Replies: 15
    Last Post: 11-21-2001, 12:02 PM