2005-10-11 13:59:49

by vinay hegde

[permalink] [raw]
Subject: Regarding - unresolved symbol

Hi,
I am developing a device driver module related to the
real time clock on Linux 2.4 kernel. [This is done
with regard to changing one of the existing timer chip
on the system.] For some reason, I am getting into an
unresolved symbol.

I am following sequence of code in the module (not
necessarily in the sequential manner though).

----------
extern void *sys_call_table[];
static int (*timer_mknod)(const char *, ... );
timer_mknod = sys_call_table[__NR_mknod];
----------

Whenever I try to insert the module into the kernel, I
get the following error:
timer.o: unresolved symbol sys_call_table

All the necessary headers are present and I am able to
see the symbol 'sys_call_table' in System.map. I do
not see any error in this regard. Can somebody help me
in pointing out the flaw?

[I am able to fix this problem by simply using the
'sys_mknod()' call in my module, but I really would
like to know why the above piece of code can not
work!]

Thank you,
Vinay Hegde



__________________________________________________________
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com


2005-10-11 15:16:21

by linux-os (Dick Johnson)

[permalink] [raw]
Subject: Re: Regarding - unresolved symbol


On Tue, 11 Oct 2005, vinay hegde wrote:

> Hi,
> I am developing a device driver module related to the
> real time clock on Linux 2.4 kernel. [This is done
> with regard to changing one of the existing timer chip
> on the system.] For some reason, I am getting into an
> unresolved symbol.
>
> I am following sequence of code in the module (not
> necessarily in the sequential manner though).
>
> ----------
> extern void *sys_call_table[];
> static int (*timer_mknod)(const char *, ... );
> timer_mknod = sys_call_table[__NR_mknod];
> ----------
>
> Whenever I try to insert the module into the kernel, I
> get the following error:
> timer.o: unresolved symbol sys_call_table
>

sys_call_table isn't an exported symbol.

> All the necessary headers are present and I am able to
> see the symbol 'sys_call_table' in System.map. I do
> not see any error in this regard. Can somebody help me
> in pointing out the flaw?
>

The flaw is in attempting to modify the sys_call_table
with a module.

> [I am able to fix this problem by simply using the
> 'sys_mknod()' call in my module, but I really would
> like to know why the above piece of code can not
> work!]
>

Even sys_mknod() should not work from a module; Who's
context did you steal to create that device-file? What
happens next to that poor sucker? Who's data-space
did you corrupt for the file-name string? I note that,
from the names, it's likely that you intend to do this
dastardly deed from a timer-queue!!!

File operations require a process context. The kernel doesn't
have one. All file operations should (read must) be done
from user space. The kernel is designed to do things
on behalf of user-space callers. Executing sys_* from
a module will result in somebody saying; "See, you are
wrong... It works fine!". Later on mysterious errors
occur which are un-trackable.

> Thank you,
> Vinay Hegde
>
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13 on an i686 machine (5589.54 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

2005-10-11 15:21:58

by Jon Masters

[permalink] [raw]
Subject: Re: Regarding - unresolved symbol

On 10/11/05, vinay hegde <[email protected]> wrote:

> All the necessary headers are present and I am able to
> see the symbol 'sys_call_table' in System.map. I do
> not see any error in this regard. Can somebody help me
> in pointing out the flaw?

It's a *very bad* idea to start trying to jump around in the
sys_call_table from a module. In fact, the sys_call_table is not being
exported any more for that reason.

Jon.

2005-10-11 15:32:24

by Jon Masters

[permalink] [raw]
Subject: Re: Regarding - unresolved symbol

On 10/11/05, linux-os (Dick Johnson) <[email protected]> wrote:

> On Tue, 11 Oct 2005, vinay hegde wrote:

> > [I am able to fix this problem by simply using the
> > 'sys_mknod()' call in my module, but I really would
> > like to know why the above piece of code can not
> > work!]

> Even sys_mknod() should not work from a module; Who's
> context did you steal to create that device-file? What
> happens next to that poor sucker? Who's data-space
> did you corrupt for the file-name string? I note that,
> from the names, it's likely that you intend to do this
> dastardly deed from a timer-queue!!!

Yummy.

> File operations require a process context. The kernel doesn't
> have one. All file operations should (read must) be done
> from user space. The kernel is designed to do things
> on behalf of user-space callers. Executing sys_* from
> a module will result in somebody saying; "See, you are
> wrong... It works fine!". Later on mysterious errors
> occur which are un-trackable.

The fix is to call out to userland to get the device node cerated for
you - either allow udev/devfs to do this for you, use
call_usermode_helper to do it, send a message up to userland via
NETLINK or whatever. There's more than one way to do it.

Jon.