linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vineet Joglekar" <vintya@excite.com>
To: linux-c-programming@vger.kernel.org
Subject: Modules Spanning Multiple Files?
Date: Wed, 25 Feb 2004 21:57:56 -0500 (EST)	[thread overview]
Message-ID: <20040226025756.1B4473DD9@xprdmailfe8.nwk.excite.com> (raw)


Hi all,

I am trying to learn to write a kernel module in which functions are present in more than 1 file.

With ref. to the information available on web, the code looks like:

/***************** file 1 *******************/
/* hello2_start.c */

#if defined(CONFIG_MODVERSIONS)  && ! defined(MODVERSIONS)
   #include <linux/modversions.h> /* Will be explained later */
   #define MODVERSIONS
#endif
#include <linux/kernel.h>       /* We're doing kernel work */
#include <linux/module.h>       /* Specifically, a module */

int init_module(void)
{
  printk("Hello, world - this is the kernel speaking\n");
  return 0;
}

/***************** file 1 *******************/
/*  stop.c  */

#if defined(CONFIG_MODVERSIONS) && ! defined(MODVERSIONS)
   #include <linux/modversions.h> /* Will be explained later */
   #define MODVERSIONS
#endif        
#include <linux/kernel.h>  /* We're doing kernel work */
#include <linux/module.h>  /* Specifically, a module  */
#define __NO_VERSION__     /* It's not THE file of the kernel module */
#include <linux/version.h> /* Not included by module.h because of
	                                      __NO_VERSION__ */
	
void cleanup_module()
{
   printk("<1>Short is the life of a kernel module\n");
}

/********************* Makefile *******************/

CC=gcc
MODCFLAGS = -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes
   	
hello.o:	hello2_start.o hello2_stop.o
	ld -m elf_i386 -r -o hello2.o hello2_start.o hello2_stop.o

start.o:	hello2_start.c
	${CC} ${MODCFLAGS} -c hello2_start.c

stop.o:	hello2_stop.c
	${CC} ${MODCFLAGS} -c hello2_stop.c

/********************* ************************/

when I do make, it doesnt give me any warnings/errors, but when I try to do
insmod -f hello2.o

it gives me error like:
"hello2.o: couldn't find the kernel version the module was compiled for"

What do I do regarding this?

Thanks and regards,

Vineet


_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

             reply	other threads:[~2004-02-26  2:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-26  2:57 Vineet Joglekar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-02-26 18:22 Modules Spanning Multiple Files? Vineet Joglekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040226025756.1B4473DD9@xprdmailfe8.nwk.excite.com \
    --to=vintya@excite.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).