17.5.2. Kernel module dependencies

One module can depend on symbols of another module that are exported with EXPORT_SYMBOL:

./dep.sh
echo $?

Outcome: the test passes:

0

Sources:

The kernel deduces dependencies based on the EXPORT_SYMBOL that each module uses.

Symbols exported by EXPORT_SYMBOL can be seen with:

insmod dep.ko
grep lkmc_dep /proc/kallsyms

sample output:

ffffffffc0001030 r __ksymtab_lkmc_dep   [dep]
ffffffffc000104d r __kstrtab_lkmc_dep   [dep]
ffffffffc0002300 B lkmc_dep     [dep]

This requires CONFIG_KALLSYMS_ALL=y.

Dependency information is stored by the kernel module build system in the .ko files' MODULE_INFO, e.g.:

modinfo dep2.ko

contains:

depends:        dep

We can double check with:

strings 3 dep2.ko | grep -E 'depends'

The output contains:

depends=dep

Module dependencies are also stored at:

cd /lib/module/*
grep dep modules.dep

Output:

extra/dep2.ko: extra/dep.ko
extra/dep.ko:

TODO: what for, and at which point point does Buildroot / BusyBox generate that file?