* basic module bug
@ 2001-08-25 5:59 Bob McElrath
2001-08-25 11:21 ` Evgeny Polyakov
0 siblings, 1 reply; 6+ messages in thread
From: Bob McElrath @ 2001-08-25 5:59 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]
What's wrong with this minimal module?
/* test module */
#ifndef __KERNEL__
#define __KERNEL__
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/malloc.h>
#ifdef MODULE
int init_module(void)
#else
int test_init(void)
#endif
{
return 0;
}
#ifdef MODULE
void cleanup_module(void)
{
}
#endif
#endif
both egcs 2.91.66 and redhat's gcc 2.96-85 barf on it:
In file included from /usr/src/linux/include/asm/semaphore.h:11,
from /usr/src/linux/include/linux/fs.h:198,
from /usr/src/linux/include/linux/capability.h:17,
from /usr/src/linux/include/linux/binfmts.h:5,
from /usr/src/linux/include/linux/sched.h:9,
from /usr/src/linux/include/linux/mm.h:4,
from /usr/src/linux/include/linux/slab.h:14,
from /usr/src/linux/include/linux/malloc.h:4,
from test.c:11:
/usr/src/linux/include/asm/current.h:4: global register variable follows a function definition
/usr/src/linux/include/asm/current.h:4: warning: call-clobbered register used for global register variable
What have I done wrong?
Thanks,
-- Bob
Bob McElrath (rsmcelrath@students.wisc.edu)
Univ. of Wisconsin at Madison, Department of Physics
[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: basic module bug
2001-08-25 5:59 basic module bug Bob McElrath
@ 2001-08-25 11:21 ` Evgeny Polyakov
2001-08-25 15:27 ` Bob McElrath
0 siblings, 1 reply; 6+ messages in thread
From: Evgeny Polyakov @ 2001-08-25 11:21 UTC (permalink / raw)
To: Bob McElrath; +Cc: linux-kernel
Hello.
On Sat, 25 Aug 2001 00:59:57 -0500
Bob McElrath <mcelrath@draal.physics.wisc.edu> wrote:
BM> both egcs 2.91.66 and redhat's gcc 2.96-85 barf on it:
BM> In file included from /usr/src/linux/include/asm/semaphore.h:11,
BM> from /usr/src/linux/include/linux/fs.h:198,
<...>
BM> used for global register variable
BM> What have I done wrong?
How do you compile this module?
I've just trying to do this with the following command and all is OK:
gcc ./test.c -c -o ./test.o -D__KERNEL__ -DMODULE.
BM> Thanks,
BM> -- Bob
---
WBR. //s0mbre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: basic module bug
2001-08-25 11:21 ` Evgeny Polyakov
@ 2001-08-25 15:27 ` Bob McElrath
2001-08-25 15:56 ` Bob McElrath
2001-08-25 19:04 ` Evgeny Polyakov
0 siblings, 2 replies; 6+ messages in thread
From: Bob McElrath @ 2001-08-25 15:27 UTC (permalink / raw)
To: Evgeny Polyakov; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
Evgeny Polyakov [johnpol@2ka.mipt.ru] wrote:
> Hello.
>
> On Sat, 25 Aug 2001 00:59:57 -0500
> Bob McElrath <mcelrath@draal.physics.wisc.edu> wrote:
>
> BM> both egcs 2.91.66 and redhat's gcc 2.96-85 barf on it:
>
> BM> In file included from /usr/src/linux/include/asm/semaphore.h:11,
> BM> from /usr/src/linux/include/linux/fs.h:198,
> <...>
> BM> used for global register variable
>
> BM> What have I done wrong?
>
> How do you compile this module?
> I've just trying to do this with the following command and all is OK:
> gcc ./test.c -c -o ./test.o -D__KERNEL__ -DMODULE.
That's because if you -D__KERNEL__ the whole file is ifdef'ed out. ;)
Remove the #ifdef __KERNEL__ stuff if you want to compile it that way.
> BM> Thanks,
> BM> -- Bob
>
> ---
> WBR. //s0mbre
-- Bob
Bob McElrath (rsmcelrath@students.wisc.edu)
Univ. of Wisconsin at Madison, Department of Physics
[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: basic module bug
2001-08-25 15:27 ` Bob McElrath
@ 2001-08-25 15:56 ` Bob McElrath
2001-08-25 19:04 ` Evgeny Polyakov
1 sibling, 0 replies; 6+ messages in thread
From: Bob McElrath @ 2001-08-25 15:56 UTC (permalink / raw)
To: Evgeny Polyakov; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1809 bytes --]
Also I don't know if I mentioned this is on the alpha architecture.
I've tried egcs 2.91.66, gcc-2.96-85 (redhat), binutils-2.10.91.0.2-3.
All kernel versions I've tried (2.4.4, 2.4.5, 2.4.7, 2.4.9, 2.2.19)
generate the same message. What am I doing wrong?
Where can I find a "skeleton" kernel module for comparison?
Bob McElrath [mcelrath@draal.physics.wisc.edu] wrote:
> Evgeny Polyakov [johnpol@2ka.mipt.ru] wrote:
> > How do you compile this module?
> > I've just trying to do this with the following command and all is OK:
> > gcc ./test.c -c -o ./test.o -D__KERNEL__ -DMODULE.
>
> That's because if you -D__KERNEL__ the whole file is ifdef'ed out. ;)
>
> Remove the #ifdef __KERNEL__ stuff if you want to compile it that way.
Here's a simpler case more compatible with the options passed to gcc
when the kernel is compiled:
/* test module. Compile with: gcc -c -I/usr/src/linux/include
* -D__KERNEL__ -DMODULE test.c */
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/current.h>
#ifdef MODULE
int init_module(void)
#else
int test_init(void)
#endif
{
return 0;
}
#ifdef MODULE
void cleanup_module(void)
{
}
#endif
(0)<mcelrath@draal:/home/mcelrath> gcc -c -I/usr/src/linux/include -D__KERNEL__ -DMODULE test.c
In file included from test.c:5:
/usr/src/linux/include/asm/current.h:4: warning: call-clobbered register used for global register variable
Yet a simpler case:
#include <asm/current.h>
int main() {}
Generates the same warning message. Why does this message not occur
when compiling the kernel?
Cheers,
-- Bob
Bob McElrath (rsmcelrath@students.wisc.edu)
Univ. of Wisconsin at Madison, Department of Physics
[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: basic module bug
2001-08-25 15:27 ` Bob McElrath
2001-08-25 15:56 ` Bob McElrath
@ 2001-08-25 19:04 ` Evgeny Polyakov
2001-08-25 21:03 ` Bob McElrath
1 sibling, 1 reply; 6+ messages in thread
From: Evgeny Polyakov @ 2001-08-25 19:04 UTC (permalink / raw)
To: Bob McElrath; +Cc: linux-kernel
Hello.
On Sat, 25 Aug 2001 10:56:45 -0500
Bob McElrath <mcelrath@draal.physics.wisc.edu> wrote:
BM> Where can I find a "skeleton" kernel module for comparison?
You wrote it some strins below.
BM> Here's a simpler case more compatible with the options passed to gcc
BM> when the kernel is compiled:
BM> /* test module. Compile with: gcc -c -I/usr/src/linux/include
BM> * -D__KERNEL__ -DMODULE test.c */
BM> #include <linux/module.h>
BM> #include <linux/kernel.h>
BM> #include <asm/current.h>
BM> #ifdef MODULE
BM> int init_module(void)
BM> #else
BM> int test_init(void)
BM> #endif
BM> {
BM> return 0;
BM> }
BM> #ifdef MODULE
BM> void cleanup_module(void)
BM> {
BM> }
BM> #endif
BM> (0)<mcelrath@draal:/home/mcelrath> gcc -c -I/usr/src/linux/include
-D__KERNEL__
BM> -DMODULE test.c
BM> In file included from test.c:5:
BM> /usr/src/linux/include/asm/current.h:4: warning: call-clobbered
register
BM> used for global register variable
[s0mbre@Sombre /tmp]$ gcc ./test.c -c -o ./test.o -D__KERNEL__ -DMODULE
-I/usr/src/linux/include
[s0mbre@Sombre /tmp]$
All is OK.
BM> Yet a simpler case:
BM> #include <asm/current.h>
BM> int main() {}
[s0mbre@Sombre /tmp]$ gcc ./test1.c -o ./test1
[s0mbre@Sombre /tmp]$ cat ./test1.c
#include <asm/current.h>
int main()
{}
[s0mbre@Sombre /tmp]$
BM> Generates the same warning message. Why does this message not occur
BM> when compiling the kernel?
I have no problem.
But if i would have this problem, i
a) rewrite include dir and check symlink
b) reinstall system :)
BM> Cheers,
BM> -- Bob
---
WBR. //s0mbre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: basic module bug
2001-08-25 19:04 ` Evgeny Polyakov
@ 2001-08-25 21:03 ` Bob McElrath
0 siblings, 0 replies; 6+ messages in thread
From: Bob McElrath @ 2001-08-25 21:03 UTC (permalink / raw)
To: Evgeny Polyakov; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 593 bytes --]
Evgeny Polyakov [johnpol@2ka.mipt.ru] wrote:
> Hello.
>
> On Sat, 25 Aug 2001 10:56:45 -0500
> Bob McElrath <mcelrath@draal.physics.wisc.edu> wrote:
>
> BM> Where can I find a "skeleton" kernel module for comparison?
>
> You wrote it some strins below.
Aha! It was caused by not passing the right compiler options. There
are some compiler options (CFLAGS) in arch/{arch}/Makefile that should
be included for modules, and some in the top level Makefile.
Cheers,
-- Bob
Bob McElrath (rsmcelrath@students.wisc.edu)
Univ. of Wisconsin at Madison, Department of Physics
[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-08-25 21:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-25 5:59 basic module bug Bob McElrath
2001-08-25 11:21 ` Evgeny Polyakov
2001-08-25 15:27 ` Bob McElrath
2001-08-25 15:56 ` Bob McElrath
2001-08-25 19:04 ` Evgeny Polyakov
2001-08-25 21:03 ` Bob McElrath
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).