-   Linux - Kernel (
-   -   How does one export a symbol from a module built outside the kernel source tree? (

opsimath 02-23-2009 01:08 AM

How does one export a symbol from a module built outside the kernel source tree?
I am writing this code outside the kernel source tree. In fact up to now I have not needed the kernel source tree on my machine. I'd like to find a way to do this without movign my source tree under the kernel tree.

My driver (loadable module) receives a data stream via a USB endpoint. This module includes a facility for 3rd parties to extend the data processing by writing their own modules which they can register via a registration framework I have implemented in my module.

For example, my customer might write a module that has the following line in their init() method:


My understanding is that I need to export the symbol my_framework_register via the EXPORT_SYMBOL() macro. When I do this, and make my module, I get a file named Module.symvers in the folder where the module .ko file is. When I load the module, I see the exported symbols in /proc/kallsyms tagged with 'T'. So far so good.

I then reference the exported routines via an include file containing
extern int my_framework_register( struct my_fops *);

When it builds, I get a WARNING about this symbol being unresolved. When I try to insmod the module I get an error. The dmesg buffer tells me two things: There is mo symbol version information for that symbol and the symbol did not load.

So, I try concatenating the Module.symvers file onto the one in /lib/modules/<version>/build. I reboot and try to build/load the module. The build works without any warnings, but now I get an error telling me "operation no permitted". However, this time there is nothing in the dmesg buffer.

I suspect the documentation that I was reading about EXPORT_DYMBOL and #define EXPORT_SYMTAB applies when the module is installed. But I cannot figure out everything I need to do to install my module. I presume that if I built the module inside the main kernel tree and added a Kconfig/Makefile pair to connect it all to the kernel build system this would probably just work. For lots of reasons I do not want to do this.

So the real question is how do I manually "install" a module into a precompiled kernel tree when that module was built using only the headers. Or, is there some other way to get an externally built module's symbols to be published (made available to other modules subsequently loaded)? I'll deal with the dependency issues later I just want to prove the concept is possible first.

Thanks a million for your help!


ashok449 02-23-2009 07:35 AM

Try this ...

Module 1:

int ash_test(int, int);

int ash_test(int a, int b)
{ int c;

printk("this is test export_symbol %s\n", __FUNCTION__);
return c;

static int __init hello_init(void)
printk(KERN_ALERT "Module successfully inserted\n");

return 0;
static void __exit hello_exit(void)
printk(KERN_ALERT "Module removed ");


Module successfully inserted


int ash_test(int, int);
static int __init hello_init(void)

int i=0;
printk("ash_test=%d\n", i);

return 0;
static void __exit hello_exit(void)
printk(KERN_ALERT " Module removed ");


Module successfully inserted
this is test export_symbol ash_test

ashok@ashok-linux:~/ashok> cat /proc/kallsyms | grep ash_test
f90f4000 u ash_test [sample_module1]
f90f40a4 r __ksymtab_ash_test [sample_module]
f90f40b0 r __kstrtab_ash_test [sample_module]
f90f40ac r __kcrctab_ash_test [sample_module]
f90f4000 t ash_test [sample_module]
140697fc a __crc_ash_test [sample_module]

opsimath 02-23-2009 12:38 PM

RE: How does one export a symbol from a module built outside the kernel source tree

I was able to manually install the module by the following few steps:

1) Copy the .ko file to a location beneath /lib/modules/<version>/kernel
2) Add the exported symbols to /lib/modules/<version>/build/Module.symvers

That's it. There are other databases in the /lib/modules/<version> folder but it seems to work without updating those.

I'd really like to know if there is some other way to publush the exported symbols, besides putting entries in this one file. I can imagine it will be a maintenance problem long term to edit this by hand/awk-script.

The 'Operation not permitted' message was originated from the _init rountine's non-zero return value. Thanks for the helpful error message.


Ondiiik 09-15-2011 11:56 AM

Kernel config can maybe solve this problem
I had also such problem and soved it by bit another way. The reason why exported symbols from externel kernel module are not visible is that they does not pass throught versioning check if they are not part of kernel. Disabling of versionning check in kernel configuration has solved it:

  • Enable loadable modules support -->
    • Module versionnig support [ ]


All times are GMT -5. The time now is 01:38 AM.