[x] Welcome to LinuxSolved.com Linux help forums, here we are a community of Linux users helping each other. It is helpful to both ie. new linux users as well experienced one. We always have our experts to help you and ofcourse members help each other, so you can ask for help any time by Registering.: Click to Register

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Linux Forums - Linux Help,Advice & support community:LinuxSolved.com  |  Forum  |  Linux in General  |  Linux Development & Programming  |  Topic: Cannot Load Kernel Loadable MOdule...
The LinuxSolved.com GNU/Linux User Communit - Forum
Welcome to LinuxCommunity You have just arrived to a friendly linux community which is helping Linux Users from Years.. You can be its part if you have not already joined it. Registration is FREE and is gateway to unlimited help and support to all your linux related needs. If you are an GNU/Linux supporter then you have come to the right place.
Pages: [1]
  Print  
Author Topic: Cannot Load Kernel Loadable MOdule...  (Read 279 times)
0 Members and 1 Guest are viewing this topic.
mohit.saha
Linux Noob !
*
Offline Offline

Posts: 10


View Profile
« on: April 18, 2008, 07:39:36 AM »

hi everybody,

I tried to create a new module as given in http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html, hello-1.c.

Code:
/* 
 *  hello-1.c - The simplest kernel module.
 */
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");

/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}

and then created the Makefile as

Code:
obj-m += hello-1.o

all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

and then make that... but the following errors are coming:

Code:
[root@dhcp-ptp2-10-177-142-249 LKM]# make
make -C /lib/modules/2.6.22.5/build M=/root/Desktop/LKM modules
make[1]: Entering directory `/usr/src/linux-2.6.22.5'
  Building modules, stage 2.
  MODPOST 0 modules
WARNING: vmlinux(.text+0xc040116f): Section mismatch: reference to .init.text:start_kernel (between 'is386' and 'check_x87')
WARNING: vmlinux(.text+0xc061fc70): Section mismatch: reference to .init.text: (between 'rest_init' and 'alloc_node_mem_map')
WARNING: vmlinux(.text+0xc062460a): Section mismatch: reference to .init.text: (between 'iret_exc' and '_etext')
WARNING: vmlinux(.text+0xc0624616): Section mismatch: reference to .init.text: (between 'iret_exc' and '_etext')
WARNING: vmlinux(.text+0xc0624622): Section mismatch: reference to .init.text: (between 'iret_exc' and '_etext')
WARNING: vmlinux(.text+0xc062462e): Section mismatch: reference to .init.text: (between 'iret_exc' and '_etext')
WARNING: vmlinux(.text+0xc061fcf0): Section mismatch: reference to .init.text:__alloc_bootmem_node (between 'alloc_node_mem_map' and 'zone_wait_table_init')
WARNING: vmlinux(.text+0xc061fd96): Section mismatch: reference to .init.text:__alloc_bootmem_node (between 'zone_wait_table_init' and 'setup_cpu_cache')
WARNING: vmlinux(.text+0xc061fe11): Section mismatch: reference to .init.text: (between 'setup_cpu_cache' and 'schedule')
WARNING: vmlinux(.text+0xc061fe4b): Section mismatch: reference to .init.text: (between 'setup_cpu_cache' and 'schedule')
WARNING: vmlinux(.text+0xc05066f2): Section mismatch: reference to .init.text:__alloc_bootmem (between 'vgacon_startup' and 'vgacon_scrolldelta')
WARNING: vmlinux(.text+0xc0624dc2): Section mismatch: reference to .init.text: (between 'iret_exc' and '_etext')
make[1]: Leaving directory `/usr/src/linux-2.6.22.5'

can u suggest what is the problem?
Also if anyone can suggest me gd book on Kernel Module Programming for LInux 2.6..

Thanks in advance...Smiley
Logged
mohit.saha
Linux Noob !
*
Offline Offline

Posts: 10


View Profile
« Reply #1 on: April 18, 2008, 10:02:17 AM »

I inserted the code:

Code:
/* 
 *  hello-1.c - The simplest kernel module.
 */
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");

/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}


module_init(init_module);
module_exit(cleanup_module);

but it is still giving some error...

Code:
[mohit@dhcp-ptp2-10-177-142-249 LKM]$ make
make -C /lib/modules/2.6.22.5/build M=/home/mohit/Desktop/LKM modules
make[1]: Entering directory `/usr/src/linux-2.6.22.5'
  CC [M]  /home/mohit/Desktop/LKM/hello-1.o
/home/mohit/Desktop/LKM/hello-1.c:23: error: redefinition of ‘init_module’
/home/mohit/Desktop/LKM/hello-1.c:8: error: previous definition of ‘init_module’ was here
/home/mohit/Desktop/LKM/hello-1.c:24: error: redefinition of ‘cleanup_module’
/home/mohit/Desktop/LKM/hello-1.c:18: error: previous definition of ‘cleanup_module’ was here
make[2]: *** [/home/mohit/Desktop/LKM/hello-1.o] Error 1
make[1]: *** [_module_/home/mohit/Desktop/LKM] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.22.5'
make: *** [all] Error 2

Now tell me what is the problem....
Logged
Linux Forums - Linux Help,Advice & support community:LinuxSolved.com
   

 Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Linux kernel debugging and Linux kernel module programming Linux Kernel Agent007 0 1086 Last post August 12, 2005, 01:54:39 PM
by Agent007
IPV6 load balance in 2.6 kernel how to Linux Kernel prasadeapen 1 874 Last post November 22, 2005, 06:50:44 AM
by Ricky
Load Balancing Linux Servers Support gauravbajaj 2 539 Last post December 06, 2005, 11:27:44 PM
by taraj
load balancing in linux General Networking Support in Linux jitender33 4 579 Last post December 27, 2005, 05:21:49 AM
by jitender33
System Callvia loadable module Linux Kernel shubhro2 0 833 Last post February 15, 2006, 11:10:26 AM
by shubhro2
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 12:48:45 AM

Login with username, password and session length
Navigation
Recent Discussions
[November 20, 2008, 11:30:52 PM]

[November 19, 2008, 07:52:41 PM]

[November 19, 2008, 07:52:36 PM]

[November 17, 2008, 10:42:59 AM]

[November 16, 2008, 12:49:47 AM]

[November 16, 2008, 12:48:58 AM]

[November 15, 2008, 08:29:02 AM]

[November 15, 2008, 08:24:41 AM]

[November 14, 2008, 05:11:50 AM]

[November 13, 2008, 03:28:22 AM]
Members
Total Members: 6222
Latest: shule
Stats
Total Posts: 8269
Total Topics: 2253
Online Today: 13
Online Ever: 111
(June 28, 2007, 06:47:29 AM)
Users Online
Users: 0
Guests: 8
Total: 8
Privacy Policy| Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks
Theme & TinyPortal v0.9.8 © Bloc