How to Open Kernel?

Linux Kernel: How are loadable modules dependent on Linux kernel source?

  • When we compile an external module we have to specify the path of the built kernel in which we want to insert the module. So what all things exactly does the loadable modules looks for in the built kernel ?

  • Answer:

    The LKM is an object file not an executable which means that the functions/symbols are not relocated yet. So, why is this happening? Because we dont have the idea of a shared library in the linux kernel. So if a LKM wants to make use of a function say "X" which is part of the linux kernel, then the symbol needs to be exported using EXPORT_SYMBOL macro which adds the function to the kernel symbol table. The previous step is done in the linux kernel code not in the custom LKM. The module loader fixes the relocation and if it encounters a symbol that is not part of the kernel but part of another known LKM, it loads that LKM first, this is what the modprobe does . Also, if you want to verify what all functions/symbols are exported by the linux kernel from user space, you can view the /proc/kallsyms! To answer your question short, symbols exported by the linux kernel "acts" as shared library for the LKM so that you can reuse the code! These relocations are fixed by the LKM loader which is part of the kernel!

Sebas Sujeen at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.