Module Implementation
Modules are stored in the filesystem as ELF object files. The kernel considers only modules that have been loaded into RAM by the /sbin/insmod program (see Section B.3) and for each of them it allocates a memory area containing the following data:
A module object
A null-terminated string that represents the name of the module (all modules should have unique names)
The code that implements the functions of the module
The module object describes a module; its fields are shown in Table B-1. A simply linked list collects all module objects, where the next field of each object points to the next element in the list. The first element of the list is addressed by the module_list variable. But actually, the first element of the list is always the same: it is named kernel_module and refers to a fictitious module representing the statically linked kernel code.
Type | Name | Description |
---|---|---|
unsigned long | size_of_struct | Size of module object |
struct module * | next | Next list element |
const char * | name | Pointer to module name |
unsigned long | size | Module size |
atomic_t | uc.usecount | Module usage counter |
unsigned long | flags | Module flags |
unsigned int | nsyms | Number of exported symbols |
unsigned int | ndeps | Number of referenced modules |
struct module_symbol * | syms | Table of exported symbols |
struct module_ref * | deps | List of referenced modules |
struct module_ref * | refs | List of referencing modules |
int (*)(void) | init | Initialization method |
void (*)(void) | cleanup | Cleanup method |
Get Understanding the Linux Kernel now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.