Re: insmod error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 07 December 2004 05:25, Karthik Subramanian wrote:

> On Mon, 6 Dec 2004 11:05:40 +0100, Fabio <fmdf@xxxxxxxxxx> wrote:

> > [root@localhost modules]# insmod hello-2.ko
> > insmod: error inserting 'hello-2.ko': -1 Invalid module format

[skip]

> Hi Fabio,
>
> I copied the same program from your email and compiled on my machine,
> it works without a whimper :-)
>
> I'm not a makefile expert, but I think that you're not passing the
> correct args to gcc when you invoke it in your makefile.
>
> Why don't you try compile it from the command line with something like
> this: gcc -I /usr/src/linux/include -DMODULE -D__KERNEL__ -o hello.o -c
> hello.c. (Make sure to replace /usr/src/linux/include by whatever makes
> sense on your system).
> If it works, then you know for sure that the problem is indeed with
> the makefile.
>
> If you do want a makefile, here's a simple one that I use. Warning:
> the email client would've probably messed up with the tabs, so you'll
> have to fix that.
>
> ---- snip ----
>
> default: hello
>
> SRC := hello.c
> MODULENAME := hello.ko
>
> INCDIR := /usr/src/linux/include
> CFLAGS := -DMODULE -D__KERNEL__ -DLINUX -Wall
>
> hello: $(SRC)
>     gcc $(CFLAGS)  -I $(INCDIR) -o $(MODULENAME) -c $(SRC)
>
> clean:
>     @ echo "cleaning up"
>     rm -f ./*.o
>
> ---- snip ----
>
> Hope this helps!
>
> Regards,
> Karthik.

Hi Karthik,

I thank you for you reply. However I found the solution just a few minutes 
ago, just going on reading the same on-line book. The problem is treated at  
http://www.tldp.org/LDP/lkmpg/2.6/html/x419.html where it is solved.

I report the solution here because I have noticed, while trying to get a hint 
from Google, that a lot of people face the very same issue.

After trying insmod and receiving "insmod: error inserting 'my_module.ko': -1 
Invalid module format", you have to look at /var/log/messages where you find 
a message that is like "Dec  6 11:46:54 localhost kernel: bsd_comp: version 
magic '2.6.5-1.358custom preempt PENTIUMII REGPARM 4KSTACKS gcc-3.4' should 
be '2.6.5-1.358custom preempt PENTIUMII REGPARM 4KSTACKS gcc-3.3'". As you 
can notice there is a subtle difference in version magic between the module 
and the kernel, that in my case showed that I compiled my kernel with gcc-3.3 
and my module with gcc-3.4.

So I re-compiled the kernel with gcc-3.4 and eventually insmod succeded also 
without module re-compilation.

Anyway, apart from this specific problem, I have modified my Makefile 
following your hints because I find that yours is better than mine.

Ciao,

Fabio De Francesco
 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux