Let's architect a very simple proof-of-concept code for module stacking. To do so, we will build two kernel modules:
- The first we will call core_lkm; its job is to act as a "library" of sorts, making available to the kernel and other modules a couple of functions (APIs).
- Our second kernel module, user_lkm, is the 'user' (or consumer) of the 'library'; it will simply invoke the functions (and use some data) residing within the first.
To do so, our pair of kernel modules will need to do the following:
- The core kernel module must use the EXPORT_SYMBOL() macro to mark some data and functions as being exported.
- The user kernel module must declare the data and/or functions that it expects to use as being external to it, via the C extern keyword (remember, exporting data or functionality merely sets up the appropriate linkage; the compiler still needs to know about the data and/or functions...