-   Linux - Distributions (
-   -   'Invalid module format' loading simple module on Suse Linux Professional 9.1 (

rocketdude 07-27-2004 07:56 AM

'Invalid module format' loading simple module on Suse Linux Professional 9.1
--- I actually have 2 issues ---

1) Whenever I try to load a simple module on Suse Linux Professional 9.1 I get the following message:

insmod: error inserting 'mydev.o': -1 Invalid module format

2) In my source why do I have to have CONFIG_M486 defined? With my RedHat installation at the office I do not have to do this.



Below is the source for the simple module followed by the gcc command line:

#include <linux/kernel.h>
#define CONFIG_M486
#include <linux/module.h>
int init_module()
/* code to init the module */
return 0;
void cleanup_module()
/* code to close the module */

gcc -D__KERNEL__ -DMODULE -c mydev.c

Vlad-A 07-27-2004 10:25 AM

The error message indicates that your module was not build properly.
The compiler call like you have given it, is the one used for 2.4.x kernels.

With the 2.6.x kernels (SuSE 9.1 has an 2.6.x kernel) things are a little bit different, although easier.

The kernel modules with 2.6.x have a .ko (Kernel Object) ending, and
not .o .

First of all you shall add the Licence Macro to your module source.


Otherwise you will get a error message when loading the module, telling that the
module is tainted.

You *need* to have write access to the kernel source tree. So compile as root.

cd into the directory with the module source

Create a Makefile

with following entry:

obj-m := mydev.o

cat "obj-m := mydev.o" > Makefile

then compile the module with

make -C /lib/modules/$(uname -r)/build SUBDIRS=$PWD modules

After that you can try to load the module with
insmod mydev.ko

Check with lsmod if the module is loaded.

modprobe -r mydev
you can remove the module.

rocketdude 07-27-2004 09:46 PM

Hi Vlad,

You're my hero! Thanks!

I searched a couple of days for this answer before posting. Can you point me to where this is documented?



Vlad-A 07-28-2004 12:40 AM

the kernel build system documentation shall be a good start

Check also:

All times are GMT -5. The time now is 11:12 PM.