This guide, when complete, will give you the background information necessary to build kernel modules.
Symbols in the kernel are visible to kernel modules. This excludes debug symbols which are stripped typically. However, one may need to share a symbol with another kernel module. There are two mechanisms in place for doing so. The first is called EXPORT_SYMS and may be found in sys/conf/kmod.mk. The second is called MODULE_DEPEND.
Using EXPORT_SYMS, one can make every symbol or select symbols visible. This approach is not typically used because it can pollute the namespace. If two modules expose the same symbols, bad things can happen including kernel panics and other insanity. EXPORT_SYMS can be set to "YES", "NO", or a list to expose.
MODULE_DEPEND is used after declaring a kernel module. It can be used to define a relationship between two modules. More than one statement can be used when there are multiple dependancies. For example, zfs has a dependancy on opensolaris. Thus, a MODULE_DEPEND has been included defining this relationship. When one loads the ZFS module, a copy of the opensolaris module is loaded if it is not already in memory.
In summary, objcopy(1) makes all symbols local by default. Either EXPORT_SYMS or MODULE_DEPEND must be used to make them visible. It is almost never the right thing to make a module's symbols globally visible via EXPORT_SYMS. MODULE_DEPEND is the preferred choice.blog comments powered by Disqus