Undefined errno reference while compiling loadable module

Submitted by Anonymous
on April 9, 2006 - 2:21pm

I think I'm gonna kill myself. This is so stupid... Of course I've looked for a solution all over the net and beyond. No luck, except for the fact that it could be somehow related to linux/unistd.h. I've modified such file and no luck again.



Here is my Makefile:


obj-m += deiso.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



Here is the make output:



make -C /lib/modules/2.6.12-9-386/build M=/home/kesher/proyectos/deiso modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.12-9-386'
CC [M] /home/kesher/proyectos/deiso/deiso.o
Building modules, stage 2.
MODPOST
*** Warning: "errno" [/home/kesher/proyectos/deiso/deiso.ko] undefined!
CC /home/kesher/proyectos/deiso/deiso.mod.o
LD [M] /home/kesher/proyectos/deiso/deiso.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.12-9-386'




And of course insmod refuses to load deiso.ko because of the undefined reference.

Any help appreciated

THANKS

Oops

Anonymous (not verified)
on
April 9, 2006 - 2:24pm

I forgot to comment that I make NO USE of errno in my code.

Errno

Anonymous (not verified)
on
April 9, 2006 - 2:51pm

Sounds like you may be trying to use a userspace library function that references errno.

I don't think so, these are m

Anonymous (not verified)
on
April 9, 2006 - 3:02pm

I don't think so, these are my headers:

#include
#include
#include /* este contiene los numeros de las llamadas al sistema __NR_... */
#include /* para los semaforos */
#include /* para la estructura "current" */
#include
#include

Sorry, these are: #include

Anonymous (not verified)
on
April 9, 2006 - 3:03pm

Sorry, these are:

#include linux/module.h
#include linux/errno.h
#include linux/unistd.h /* este contiene los numeros de las llamadas al sistema __NR_... */
#include linux/rwsem.h /* para los semaforos */
#include linux/sched.h /* para la estructura "current" */
#include linux/proc_fs.h
#include linux/syscalls.h

Weird

Anonymous (not verified)
on
April 9, 2006 - 5:44pm

I have fixed it by adding this line to my source:

int errno;

Does this make any sense?

Maybe you are using syscalls

on
April 9, 2006 - 9:12pm

Maybe you are using syscalls in your code (defined by using _syscallN or by using execve(), defined in asm/unistd.h, at least for i386)? They refer to errno.

Adding errno variable to module will work, but it is not a good idea to use value of it, if this is not done with some sort of lock held.

You're right, I use _syscal

Anonymous (not verified)
on
April 10, 2006 - 7:48am

You're right, I use _syscalls! Thanks, I won't use errno

Maybe you are using syscalls

on
April 9, 2006 - 9:12pm

Maybe you are using syscalls in your code (defined by using _syscallN or by using execve(), defined in asm/unistd.h, at least for i386)? They refer to errno.

Adding errno variable to module will work, but it is not a good idea to use value of it, if this is not done with some sort of lock held.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.