public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* makeing a loadable module
@ 2004-11-08  4:28 Gene Heskett
  2004-11-08  6:08 ` Eric Gaumer
  2004-11-08 22:37 ` Sam Ravnborg
  0 siblings, 2 replies; 3+ messages in thread
From: Gene Heskett @ 2004-11-08  4:28 UTC (permalink / raw)
  To: linux-kernel

Greetings;

I found some code I can play with/hack/etc, in the form of a loadable 
module and some testing driver programs, in 'dpci8255.tar.gz'.

Unforch its for a slightly different card than the one I have, and 
once I've hacked the code to suit, I need to rebuild it.

So whats the gcc command line to make just a bare, loadable module for 
say a 2.4.25 kernel?   Obviously I'm missing something when it 
complains and quits, claiming there is no 'main' defined, which I 
don't think modules actually have one of those?

What I'm trying to do (hey, no big dummy jokes please :)

[root@coyote dist]# cc -o dpci8255.o dpci8255lib.c
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): 
In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

The gcc manpage isn't that helpfull and I've now read thru it twice.

-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
99.28% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attorneys please note, additions to this message
by Gene Heskett are:
Copyright 2004 by Maurice Eugene Heskett, all rights reserved.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: makeing a loadable module
  2004-11-08  4:28 makeing a loadable module Gene Heskett
@ 2004-11-08  6:08 ` Eric Gaumer
  2004-11-08 22:37 ` Sam Ravnborg
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Gaumer @ 2004-11-08  6:08 UTC (permalink / raw)
  To: gene.heskett; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]

On Sun, 2004-11-07 at 23:28 -0500, Gene Heskett wrote:
> Greetings;
> 
> I found some code I can play with/hack/etc, in the form of a loadable 
> module and some testing driver programs, in 'dpci8255.tar.gz'.
> 
> Unforch its for a slightly different card than the one I have, and 
> once I've hacked the code to suit, I need to rebuild it.
> 
> So whats the gcc command line to make just a bare, loadable module for 
> say a 2.4.25 kernel?   Obviously I'm missing something when it 
> complains and quits, claiming there is no 'main' defined, which I 
> don't think modules actually have one of those?
> 
> What I'm trying to do (hey, no big dummy jokes please :)
> 
> [root@coyote dist]# cc -o dpci8255.o dpci8255lib.c
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): 
> In function `_start':
> : undefined reference to `main'
> collect2: ld returned 1 exit status
> 
> The gcc manpage isn't that helpfull and I've now read thru it twice.

This should work for a single source file 

]$ gcc -O2 -D__KERNEL__ -DMODULE -DHAVE_CONFIG_H -I/usr/src/linux/include -c dcpi8255.c

If your using SMP then you'll need to define that as well.

-- 
Eric Gaumer <gaumerel@ecs.fullerton.edu>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: makeing a loadable module
  2004-11-08  4:28 makeing a loadable module Gene Heskett
  2004-11-08  6:08 ` Eric Gaumer
@ 2004-11-08 22:37 ` Sam Ravnborg
  1 sibling, 0 replies; 3+ messages in thread
From: Sam Ravnborg @ 2004-11-08 22:37 UTC (permalink / raw)
  To: Gene Heskett; +Cc: linux-kernel

On Sun, Nov 07, 2004 at 11:28:48PM -0500, Gene Heskett wrote:
> Greetings;
> 
> I found some code I can play with/hack/etc, in the form of a loadable 
> module and some testing driver programs, in 'dpci8255.tar.gz'.
> 
> Unforch its for a slightly different card than the one I have, and 
> once I've hacked the code to suit, I need to rebuild it.
> 
> So whats the gcc command line to make just a bare, loadable module for 
> say a 2.4.25 kernel?   Obviously I'm missing something when it 
> complains and quits, claiming there is no 'main' defined, which I 
> don't think modules actually have one of those?
> 
> What I'm trying to do (hey, no big dummy jokes please :)
> 
> [root@coyote dist]# cc -o dpci8255.o dpci8255lib.c
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): 
> In function `_start':
> : undefined reference to `main'
> collect2: ld returned 1 exit status

Create a small Makefile:
echo obj-m := dpci8255.o > Makefile

And use:
make -C $PATH_TO_KERNEL_SRC SUBDIRS=$PWD modules

This will give you the correct gcc commandline - adopted to actual
configuration of the kernel.
Any other way to compile a module is br0ken.

For 2.6 the above syntax works as well, but simpler versions exists.

	Sam

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-08 22:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-08  4:28 makeing a loadable module Gene Heskett
2004-11-08  6:08 ` Eric Gaumer
2004-11-08 22:37 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox