tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: library in kernel space



On Sun, 23 Mar 2025, Peter Skvarka wrote:


You can only load other kernel modules from a kernel module (or the main
kernel).

In this case
when I have two modules where module_1 needs exported functions from module_2.
Module_2 must be loaded first (i.e. with modload from shell)
and after it I can load module_1. (if I understand it good)
Is needed to use something special when compiling both modules to be able to recognize that some function is exported and to recognize that this function is present in module_2 ? (linker switches or some macros, etc.)

In module_1 you simply add module_2 to the required list in the
MODULE() macro.

I think you can look at dk_subr module as an example of module_2
to export symbols for the run-time linker to resolve.


+---------------------+--------------------------+----------------------+
| Paul Goyette (.sig) | PGP Key fingerprint:     | E-mail addresses:    |
| (Retired)           | 1B11 1849 721C 56C8 F63A | paul%whooppee.com@localhost    |
| Software Developer  | 6E2E 05FD 15CE 9F2D 5102 | pgoyette%netbsd.org@localhost  |
| & Network Engineer  |                          | pgoyette99%gmail.com@localhost |
+---------------------+--------------------------+----------------------+


Home | Main Index | Thread Index | Old Index