How external kernel module look for exported symbol during modpost

61 views Asked by At

I have 3 external kernel modules that have dependency from each other. More specifically, C contains symbol from B, which contains symbol from A.

I try to build module in the following orders.

make -C <Kernel dir> 
make -C <kernel dir> KERNELRELEASE=$(KERNEL_VER) modules
make -C <kernel dir> KERNELRELEASE=$(KERNEL_VER) INSTALL_MOD_PATH=$(INSTALL_PATH) modules_install

make -C <kernel_dir> M=<module_A_dir> modules;
make -C <kernel_dir> M=<module_A_dir> INSTALL_MOD_PATH=$(INSTALL_PATH) modules_install;

make -C <kernel_dir> M=<module_B_dir> modules;
make -C <kernel_dir> M=<module_B_dir> INSTALL_MOD_PATH=$(INSTALL_PATH) modules_install;

make -C <kernel_dir> M=<module_C_dir> modules;
make -C <kernel_dir> M=<module_C_dir> INSTALL_MOD_PATH=$(INSTALL_PATH) modules_install;

When compile module B, during modpost, it cannot recognize the exported symbols from module A, claiming they were undefined.

The message is the following:

make[2]: Entering directory '/home/user/workingdir/kernel/linux-5.4.x'
  Building modules, stage 2.
  MODPOST 1 modules
ERROR: "backport_dependency_symbol" [/home/user/workingdir/extModB/moduleB.ko] undefined!
ERROR: "cfg80211_moduleA_cmd" [/home/user/workingdir/extModB/moduleB.ko] undefined!

I understand that I can simply include Module.symvers from A into B, but there is one problem. The license for module A is (GPL), while B's module license is (BSD/GPL), but license C is (Proprietary). If simply configure KBUILD_EXTRA_SYMBOLS to include Module.symvers from other module directory, I will run into license issue when compiling.

So my question is, is there anyway to install external module A, so when compiling kernel module B, during modpost stage, it will automatically identify the module A within the INSTALL_MOD_PATH?

1

There are 1 answers

0
Tommy Lin On

After checking with openwrt, it did something different, which is removing include/mac80211-backport/linux/module.h that existed within module A, when compiing module B, somehow magically modpost won't be complaining for "backport_dependency_symbol" not defined because such function calls no longer existed within the header file, so modpost won't look for actual symbol.

It's a different approach that Openwrt takes since as system engineer, we tend to include all functions definitions rather than removing partially.