Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EXPORT_SYMBOL in kernel module | undefined symbol during insmod

I have a exported functions foo() and foo1() from a.ko (a kernel module), foo1() takes input parameter, a function pointer. I invoke foo1() from b.ko, and pass foo() as the input parameter.

I see a insmod failure for b.ko (unknown symbol foo ), even though a.ko has been insmoded before b.ko.

Any explanations/solutions ?

Thanks, Lucky

like image 612
user2501484 Avatar asked Jun 19 '13 14:06

user2501484


People also ask

What happens when insmod is performed?

Insmod copies the module into the allocated space and relocates it so that it will run from the kernel address that it has been allocated. This must happen as the module cannot expect to be loaded at the same address twice let alone into the same address in two different Linux systems.

What does insmod command do?

The insmod command inserts a module into the Linux kernel. It's one way of adding functionality to the core of your Linux operating system.


1 Answers

There are two ways to solve this, 1) Compile both the kernel modules in the same Makefile i.e. objs-m := a.o b.o. 2) Include **KBUILD_EXTRA_SYMBOLS=<"absolute path to the Module.symvers of the kernel module which is exporting function or variable"> in the Makefile of the kernel module which will use exported function or variable.

like image 107
Gautham Kantharaju Avatar answered Nov 15 '22 10:11

Gautham Kantharaju