Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamic linking for a kernel module

That is, can a driver try to import a symbol for another driver, and if the symbol doesn’t exist can the driver continue to load without resolving the import? And even if possible is it even allowed for an upstream driver ? i.e a driver already out there in the lnux kernel?

like image 530
user1724691 Avatar asked Oct 06 '12 07:10

user1724691


People also ask

How are kernel modules linked?

A user can link a module into the running kernel by executing the insmod external program. This program performs the following operations: Reads from the command line the name of the module to be linked. Locates the file containing the module's object code in the system directory tree.

What is static and dynamic module linking in Linux kernel?

Static modules are those which are compiled as part of the base kernel and it is available at any time. Dynamic Modules are compiled as modules separately and loaded based on user demand. These are also called as Loadable Kernel Modules(LKM).

How do I debug a Linux kernel module?

To debug the module, you first have to load the module, then tell GDB where the symbol file is, then set any breakpoints you need. So, first things first, load the module. Included in the source code is a simple shell script called loadModule that loads the module and creates the devices if they do not already exist.

How does Linux support kernel module?

They extend the functionality of the kernel without the need to reboot the system. Custom codes can be added to Linux kernels via two methods. The basic way is to add the code to the kernel source tree and recompile the kernel. A more efficient way is to do this is by adding code to the kernel while it is running.


1 Answers

symbols exported by EXPORT_SYMBOL or EXPORT_SYMBOL_GPL(if the importing module does have GPL-compatible license) in any kernel modules can be used by other modules.

if the symbol doesn’t exist can the driver continue to load without resolving the import?

I am not sure about it. But you can verify if a symbol is exported from the output of cat /proc/kallsyms. exported symbols will have two entries. One with symbol name and another with _ksymtab prefixed.

For example, for printk.

ffffffff814fd1e2 T printk ffffffff81812550 r __ksymtab_printk

like image 188
Minto Joseph Avatar answered Nov 10 '22 13:11

Minto Joseph