Re: Linux kernel 2.6.11 and external module error

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

 





On 2/3/06, Σωτήριο Κοντογιάννη <skontog@xxxxxxxxxx> wrote:


I tried to compile a small external module for my amd_64 2.6.11 kernel.
The module code is:
--------------------------ZIP
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>

MODULE_INFO(vermagic,VERMAGIC_STRING);
MODULE_AUTHOR("Sko");
MODULE_DESCRIPTION("NoP");
static int __init demo_init(void) {
               printk("initializing..\n");
                       return 0;
}

static void __exit demo_exit(void) {
               printk("goodbye!\n");
}

module_init(demo_init);
module_exit(demo_exit);
MODULE_LICENSE("GPL");
---------------------------------
and the Makefile I used:
obj-m := ex0.o
#ex0-y :=
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
-----------------------------
I module compiles succesfully but when I try to insmod it I get the following
message at the console:
#insmod -f ./ex0.o
insmod: error inserting 'ex0.o': -1 Invalid module format

and at /var/log/messages the following:
kernel: No module found in object
I use module-init-tools 3.2.2
#modprobe -V
module-init-tools version 3.2.2

Could anyone tell me what am I doing wrong..

Thanks in advance! :)



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

 
 
 
The kernel module should be compiled using the build files of the running kernel...compiling with anything else (i mean the kernel) will cause to this kind of error. system.map should match with the running kernel...AFAIK
 
for e.g if you are using Fedora Core 4 then the build directory will be /lib/modules/2.6.XXXXX/build/
 
then the output file of module will be file.ko in 2.6 kernel...
insmod file.ko should work
try it ...bye.

[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