7

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

user2501484
  • 73
  • 1
  • 3
  • Did you build the modules in different directories? Did you use the .symvers file when building b.ko? See also: http://stackoverflow.com/questions/12311867/ – Eugene Jun 21 '13 at 08:10
  • Minimal working example: https://stackoverflow.com/questions/12311867/how-to-call-exported-kernel-module-functions-from-another-module/44614246#44614246 – Ciro Santilli OurBigBook.com Jun 18 '17 at 10:58

1 Answers1

6

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.

Gautham Kantharaju
  • 1,735
  • 1
  • 21
  • 24
  • What is the format for the KBUILD_EXTRA_SYMBOLS line? Make is telling me "mixed implicit and normal rules: deprecated syntax" – jeremiah Aug 05 '15 at 13:56
  • 1
    @jeremiah, KBUILD_EXTRA_SYMBOLS is a make variable and I guess there is no format as such. GNU make throwing "mixed implicit and normal rules: deprecated syntax" is because of the usage of newer GNU make version (4.0). Try using GNU make version (3.8.1) to compile the module. Go through the link http://blog.melski.net/2015/01/12/whats-new-in-gnu-make-4-1/ – Gautham Kantharaju Aug 05 '15 at 16:04