2000-11-06 19:33:52

by forop066

[permalink] [raw]
Subject: Calling module symbols from inside the kernel !


Is it possible to access symbols exported by modules from inside the kernel ?

I put a funtion call inside the kernel code but this funtion must be implemented in a module. I tried export as a module symbol but when i tried to recompile the kernel.. :-(

Warning: implicit declaration of my_funtion
.
.
.
Error: Undefined reference to my_funtion.

How can i fix this mistake!????

Thanks in advance,
Cris Amon.


2000-11-06 19:54:41

by Brian Gerst

[permalink] [raw]
Subject: Re: Calling module symbols from inside the kernel !

[email protected] wrote:
>
> Is it possible to access symbols exported by modules from inside the kernel ?
>
> I put a funtion call inside the kernel code but this funtion must be implemented in a module. I tried export as a module symbol but when i tried to recompile the kernel.. :-(
>
> Warning: implicit declaration of my_funtion
> .
> .
> .
> Error: Undefined reference to my_funtion.
>
> How can i fix this mistake!????
>
> Thanks in advance,
> Cris Amon.

You will need to use a function pointer hook that the module fills in
when it is loaded. For an example look at devpts_upcall_new and
devpts_upcall_kill in fs/devpts/inode.c. The hooks are resident in the
kernel and are exported so the module can see them. The caller then
needs to check if the hook is null and optionally request the module be
loaded.

--

Brian Gerst

2000-11-07 03:12:02

by Keith Owens

[permalink] [raw]
Subject: Re: Calling module symbols from inside the kernel !

On Mon, 6 Nov 2000 16:24:13 -0300,
[email protected] wrote:
>Is it possible to access symbols exported by modules from inside the kernel ?

Not via symbol name, the linkage goes module => kernel, not the other
way round. Your module needs to register its data when it loads, then
any code can use the registration "get" function to access the data.
This works kernel <=> kernel, kernel <=> module, module <=> module. Be
careful that you lock the module down while you are using its data.

See ftp://ftp.ocs.com.au/pub/2.4.0-test10-pre6-module-symbol.gz for
sample registration code.

2000-11-07 09:42:46

by Richard J Moore

[permalink] [raw]
Subject: Re: Calling module symbols from inside the kernel !



We have a generic way of doing this which we are about to release - called
GKHI (Generalised Kernel Hooks Interface) would you like a copy to test?


Richard Moore - RAS Project Lead - Linux Technology Centre (PISC).

http://oss.software.ibm.com/developerworks/opensource/linux
Office: (+44) (0)1962-817072, Mobile: (+44) (0)7768-298183
IBM UK Ltd, MP135 Galileo Centre, Hursley Park, Winchester, SO21 2JN, UK


2000-11-07 14:42:50

by David Woodhouse

[permalink] [raw]
Subject: Re: Calling module symbols from inside the kernel !


[email protected] said:
> You will need to use a function pointer hook that the module fills in
> when it is loaded. For an example look at devpts_upcall_new and
> devpts_upcall_kill in fs/devpts/inode.c. The hooks are resident in
> the kernel and are exported so the module can see them. The caller
> then needs to check if the hook is null and optionally request the
> module be loaded.

get_module_symbol() does this for you without having to use such a hook

/me runs


:)


--
dwmw2


2000-11-08 11:53:37

by Ingo Oeser

[permalink] [raw]
Subject: Re: Calling module symbols from inside the kernel !

On Tue, Nov 07, 2000 at 02:41:42PM +0000, David Woodhouse wrote:
> get_module_symbol() does this for you without having to use such a hook
>
> /me runs

So I guess you know already, that it died in 2.4.0-test11-pre1
and you are suggesting dead code? ;-)

Regards

Ingo Oeser
--
To the systems programmer, users and applications
serve only to provide a test load.
<esc>:x