O'Reilly logo

Understanding the Linux Kernel, 3rd Edition by Marco Cesati, Daniel P. Bovet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Module Implementation

Modules are stored in the filesystem as ELF object files and are linked to the kernel by executing the insmod program (see the later section, "Linking and Unlinking Modules"). For each module, the kernel allocates a memory area containing the following data:

  • A module object

  • A null-terminated string that represents the name of the module (all modules must 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 doubly linked circular list collects all module objects; the list head is stored in the modules variable, while the pointers to the adjacent elements are stored in the list field of each module object.

Table B-1. The module object

Type

Name

Description

enum module_state

state

The internal state of the module

struct list_head

list

Pointers for the list of modules

char [60]

name

The module name

struct

module_kobject

mkobj

Includes a kobject data structure and a pointer to this module object

struct

module_param_attrs *

param_attrs

Pointer to an array of module parameter descriptors

const struct

kernel_symbol *

syms

Pointer to an array of exported symbols

unsigned int

num_syms

Number of exported symbols

const unsigned long *

crcs

Pointer to an array of CRC values for the exported symbols

const struct

kernel_symbol *

gpl_syms

Pointer to an array of GPL-exported symbols

unsigned int

num_gpl_syms

Number of GPL-exported symbols

const unsigned long *

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required