Search code examples
clinux-kernelstatic-librariesdynamic-library

How to link a LKM (loadable kernel module) to static or dynamic libraries?


After searching I couldn't find any example that a LKM uses a static or dynamic libraries.

I want to create static and dynamic libraries (may be use standard C library or any other libraries), then develop a LKM that uses my own static and dynamic libraries.

How to link a LKM (loadable kernel module) to static or dynamic libraries?


Solution

  • I'm afraid you have a major misconception - Linux kernel modules cannot be linked with standard user space libraries, such as the C library, either static or dynamic. This is because the C library and the dynamic linker (that implements dynamic linking) actually calls the kernel to do its job.

    You can write a static C library and link it to a kernel module and an LKML is actually a form of a kernel dynamic library. See the Documentation/kbuild/ directory for details