LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-29-2006, 08:29 PM   #1
sancho1980
Member
 
Registered: May 2006
Location: Leipzig, Germany
Distribution: Kanotix 64
Posts: 45

Rep: Reputation: 15
building a hello world module


hi
i'm trying to get into module hacking
now, i've found this hello module in an online book

it looks like this

//start hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
//end hello.c

The Makefile is

obj-m := hello.o

I can build and load the module WITH KERNEL VERSION 2.6.14:

root@KanotixBox:/home/sancho/Programming/ldd/1# make -C /usr/src/linux-2.6.14-kanotix64-9/ M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.14-kanotix64-9'
CC [M] /home/sancho/Programming/ldd/1/hello.o
Building modules, stage 2.
MODPOST
CC /home/sancho/Programming/ldd/1/hello.mod.o
LD [M] /home/sancho/Programming/ldd/1/hello.ko
make: Leaving directory `/usr/src/linux-headers-2.6.14-kanotix64-9'
root@KanotixBox:/home/sancho/Programming/ldd/1# insmod ./hello.ko


However, as soon as I re-logon WITH MY NEWLY COMPILED kernel version 2.6.18, I get the following:

root@KanotixBox:/home/sancho/Programming/ldd/1# make -C /usr/src/linux-2.6.18-slh64-smp-2/ M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.18-slh64-smp-2'
CC [M] /home/sancho/Programming/ldd/1/hello.o
Building modules, stage 2.
MODPOST
CC /home/sancho/Programming/ldd/1/hello.mod.o
LD [M] /home/sancho/Programming/ldd/1/hello.ko
make: Leaving directory `/usr/src/linux-headers-2.6.18-slh64-smp-2'
root@KanotixBox:/home/sancho/Programming/ldd/1# insmod ./hello.ko
Error inserting './hello.ko': -1 Invalid module format


Is there any particular reason why this simple module works with version .14 but not .18?
I mean, I would understand this error if I had compiled the module against .18 while still running .14 and viceversa but as you can see, I'm always compiling against the source I'm actually running so this error shouldn't occur, should it?

Thanx,

Martin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in building world: warning: operand 1 missing mode? henkelarsson12 *BSD 0 04-14-2006 02:14 PM
problems with Hello World kernel2.6 module Ralc Programming 0 03-10-2006 04:59 PM
hello world module the_uplink2x Programming 19 04-12-2005 02:14 PM
building a module pessanimahi Programming 17 10-06-2003 11:10 AM
hello world module aliyildiz Linux - General 1 12-09-2001 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration