All of lore.kernel.org
 help / color / mirror / Atom feed
* Do you know the bug of EXPORT_SYMBOL()
@ 2015-07-24  5:49 Navy
  2015-07-24  8:18 ` Pranay Srivastava
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Navy @ 2015-07-24  5:49 UTC (permalink / raw)
  To: kernelnewbies

Hi
To my understanding, EXPORT_SYMBOL() is used to export a symbol in 
kernel/modules. The the address of the all sysbols is in /proc/kallsyms. 
Only symbols exported by EXPORT_SYMBOL() is listed its CRC information 
in Module.symvers. So I think the CRC is the key to export a symbol.
I do an experiment:
	
       ---mdir
           |
           |---Mod1
           |    |---mod1.c
           |    |---Makefile
           |
           |---Mod2
                |---mod2.c
                |---Makefile
		
mod1.c define function *void myfunc(void)* and exported by EXPORT_SYMBOL() 
and the CRC info is showed in Module.symvers. mod2.c reference *myfunc* and
compiled successfully. BUT when mod2.ko is insmoded, "unknown symbol" is 
complained. mod2.ko CAN'T BE INSMOD.
I solve this problem by the method in Documentation/kbuild/modules.txt and
heard this is a bug from kernel 2.6.

Why this bug is not be fixed?

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

* Do you know the bug of EXPORT_SYMBOL()
  2015-07-24  5:49 Do you know the bug of EXPORT_SYMBOL() Navy
@ 2015-07-24  8:18 ` Pranay Srivastava
  2015-07-24 12:40   ` Navy
  2015-07-24 17:10 ` Greg KH
  2015-07-24 17:41 ` Abhishek bist
  2 siblings, 1 reply; 6+ messages in thread
From: Pranay Srivastava @ 2015-07-24  8:18 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Jul 24, 2015 at 11:19 AM, Navy <navych@126.com> wrote:
> Hi
> To my understanding, EXPORT_SYMBOL() is used to export a symbol in
> kernel/modules. The the address of the all sysbols is in /proc/kallsyms.
> Only symbols exported by EXPORT_SYMBOL() is listed its CRC information
> in Module.symvers. So I think the CRC is the key to export a symbol.
> I do an experiment:
>
>        ---mdir
>            |
>            |---Mod1
>            |    |---mod1.c
>            |    |---Makefile
>            |
>            |---Mod2
>                 |---mod2.c
>                 |---Makefile
>
> mod1.c define function *void myfunc(void)* and exported by EXPORT_SYMBOL()
> and the CRC info is showed in Module.symvers. mod2.c reference *myfunc* and
> compiled successfully. BUT when mod2.ko is insmoded, "unknown symbol" is
> complained. mod2.ko CAN'T BE INSMOD.

Your Mod1 must be live before you load Mod2.

When you load your module, the exported symbols would be present in a
separate section in the elf file, you can see that using readelf,
something like __ksymtab_. When the module is loaded these symbols are
noted so that find_symbol can locate these.

When you load a module dependent on those symbols, the load_module
function would use the find_symbol to get that symbol.

CRC would be checked in check_version after the symbol has been found,
even then only if you have CONFIG_MODVERSIONS set in your config.


> I solve this problem by the method in Documentation/kbuild/modules.txt and
> heard this is a bug from kernel 2.6.
>
> Why this bug is not be fixed?
>
It's a long way from 2.6 now. can you send something about this "bug"?
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
        ---P.K.S

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

* Do you know the bug of EXPORT_SYMBOL()
  2015-07-24  8:18 ` Pranay Srivastava
@ 2015-07-24 12:40   ` Navy
  2015-07-24 14:20     ` Tal Shorer
  0 siblings, 1 reply; 6+ messages in thread
From: Navy @ 2015-07-24 12:40 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Jul 24, 2015 at 01:48:57PM +0530, Pranay Srivastava wrote:
> On Fri, Jul 24, 2015 at 11:19 AM, Navy <navych@126.com> wrote:
> > Hi
> > To my understanding, EXPORT_SYMBOL() is used to export a symbol in
> 
> > Why this bug is not be fixed?
> >
> It's a long way from 2.6 now. can you send something about this "bug"?
Hi Pranay,
The detail is below:
https://bugzilla.kernel.org/show_bug.cgi?id=12446#c11
Maybe other people think out-of-tree modules should not be supported.
I don't know How do the in-tree modules reference other symbols and be insmod
without this problem. If you can help me about this, I will deeply grateful.

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

* Do you know the bug of EXPORT_SYMBOL()
  2015-07-24 12:40   ` Navy
@ 2015-07-24 14:20     ` Tal Shorer
  0 siblings, 0 replies; 6+ messages in thread
From: Tal Shorer @ 2015-07-24 14:20 UTC (permalink / raw)
  To: kernelnewbies

With in-tree modules, the compilation process can determine
dependencies and that's why modprobe works with them (insmod doesn't).
How do you want the kernel to know where the symbol comes from? Why
load your mod1 and not my mod3 that also defines myfunc()? Who's going
to call init_module on your mod1? Where in the filesystem should it
look for it?

On Fri, Jul 24, 2015 at 3:40 PM, Navy <navych@126.com> wrote:
> On Fri, Jul 24, 2015 at 01:48:57PM +0530, Pranay Srivastava wrote:
>> On Fri, Jul 24, 2015 at 11:19 AM, Navy <navych@126.com> wrote:
>> > Hi
>> > To my understanding, EXPORT_SYMBOL() is used to export a symbol in
>>
>> > Why this bug is not be fixed?
>> >
>> It's a long way from 2.6 now. can you send something about this "bug"?
> Hi Pranay,
> The detail is below:
> https://bugzilla.kernel.org/show_bug.cgi?id=12446#c11
> Maybe other people think out-of-tree modules should not be supported.
> I don't know How do the in-tree modules reference other symbols and be insmod
> without this problem. If you can help me about this, I will deeply grateful.
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Do you know the bug of EXPORT_SYMBOL()
  2015-07-24  5:49 Do you know the bug of EXPORT_SYMBOL() Navy
  2015-07-24  8:18 ` Pranay Srivastava
@ 2015-07-24 17:10 ` Greg KH
  2015-07-24 17:41 ` Abhishek bist
  2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2015-07-24 17:10 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Jul 24, 2015 at 01:49:42PM +0800, Navy wrote:
> Hi
> To my understanding, EXPORT_SYMBOL() is used to export a symbol in 
> kernel/modules. The the address of the all sysbols is in /proc/kallsyms. 
> Only symbols exported by EXPORT_SYMBOL() is listed its CRC information 
> in Module.symvers. So I think the CRC is the key to export a symbol.
> I do an experiment:
> 	
>        ---mdir
>            |
>            |---Mod1
>            |    |---mod1.c
>            |    |---Makefile
>            |
>            |---Mod2
>                 |---mod2.c
>                 |---Makefile
> 		
> mod1.c define function *void myfunc(void)* and exported by EXPORT_SYMBOL() 
> and the CRC info is showed in Module.symvers. mod2.c reference *myfunc* and
> compiled successfully. BUT when mod2.ko is insmoded, "unknown symbol" is 
> complained. mod2.ko CAN'T BE INSMOD.

Use 'modprobe' after "properly" installing the kernel modules to the
correct location, and then all will be fine.

greg k-h

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

* Do you know the bug of EXPORT_SYMBOL()
  2015-07-24  5:49 Do you know the bug of EXPORT_SYMBOL() Navy
  2015-07-24  8:18 ` Pranay Srivastava
  2015-07-24 17:10 ` Greg KH
@ 2015-07-24 17:41 ` Abhishek bist
  2 siblings, 0 replies; 6+ messages in thread
From: Abhishek bist @ 2015-07-24 17:41 UTC (permalink / raw)
  To: kernelnewbies

Hi,
    This is the place where modprobe comes into play .If you have dependent
module the on your module then it is recommended to use modprobe .
After compiling your module run :
1. depmod -a
2. modprobe mod1
3. modprobe mod2

And as far as i know CONFIG_MODVERSION is basically for the module
signature according to which you can't directly insert a .ko file compiled
in another system.


On 24 July 2015 at 11:19, Navy <navych@126.com> wrote:

> Hi
> To my understanding, EXPORT_SYMBOL() is used to export a symbol in
> kernel/modules. The the address of the all sysbols is in /proc/kallsyms.
> Only symbols exported by EXPORT_SYMBOL() is listed its CRC information
> in Module.symvers. So I think the CRC is the key to export a symbol.
> I do an experiment:
>
>        ---mdir
>            |
>            |---Mod1
>            |    |---mod1.c
>            |    |---Makefile
>            |
>            |---Mod2
>                 |---mod2.c
>                 |---Makefile
>
> mod1.c define function *void myfunc(void)* and exported by EXPORT_SYMBOL()
> and the CRC info is showed in Module.symvers. mod2.c reference *myfunc* and
> compiled successfully. BUT when mod2.ko is insmoded, "unknown symbol" is
> complained. mod2.ko CAN'T BE INSMOD.
> I solve this problem by the method in Documentation/kbuild/modules.txt and
> heard this is a bug from kernel 2.6.
>
> Why this bug is not be fixed?
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150724/6bd56661/attachment.html 

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

end of thread, other threads:[~2015-07-24 17:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-24  5:49 Do you know the bug of EXPORT_SYMBOL() Navy
2015-07-24  8:18 ` Pranay Srivastava
2015-07-24 12:40   ` Navy
2015-07-24 14:20     ` Tal Shorer
2015-07-24 17:10 ` Greg KH
2015-07-24 17:41 ` Abhishek bist

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.