One of the major differences between user-mode and kernel-mode programming is the complete absence of the familiar "library" concept in the latter. Libraries are essentially a collection or archive of APIs, conveniently allowing developers to meet the important goals, typically: do not reinvent the wheel, software reuse, modularity, and the like. But within the Linux kernel, libraries just do not exist.
The good news, though, is that broadly speaking, there are two techniques by which you can achieve a "library-like" functionality in kernel space for our kernel modules:
- The first technique: explicitly "link in" multiple source files – including the "library" code – to your kernel module object.
- The second is called module stacking.
Do read on as we discuss these techniques in more detail. A spoiler, perhaps, but useful to know right away: the first of the preceding...