Linux Kernel Development
  • Introduction
  • Linux Kernel Development Environment
    • Git Source Code Management
    • Docker
  • Linux Kernel Development Process
    • A Guide To The Linux Kernel Development Process
  • Linux Kernel Compilation
  • Linux Kernel Modules
  • Linux Kernel Build System
    • Compilation Kernel Object
    • Compilation Built-In
  • Linux Kernel Patch
    • Patchset
  • Linux Kernel Developer
Powered by GitBook
On this page
  1. Linux Kernel Build System

Compilation Kernel Object

PreviousLinux Kernel Build SystemNextCompilation Built-In

Last updated 7 years ago

A loadable kernel module (LKM) is a mechanism for adding code to, or removing code from, the Linux kernel at run time. They are ideal for device drivers, enabling the kernel to communicate with the hardware without it having to know how the hardware.

In computing, a loadable kernel module (or LKM) is an object file that contains code to extend the running kernel, or so-called base kernel, of an operating system. LKMs are typically used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. When the functionality provided by a LKM is no longer required, it can be unloaded in order to free memory and other resources.

Now compile your Hello World Module both as module and built-in into the Kernel image making sure you boot your system twice to confirm your changes using dmesg command

As Module (M)

user@workstation:~/linux$ make
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  LD      drivers/helloworld/built-in.o
  CC [M]  drivers/helloworld/helloworld.o
Kernel: arch/x86/boot/bzImage is ready  (#2)
  Building modules, stage 2.
  MODPOST 2255 modules
  CC      drivers/helloworld/helloworld.mod.o
  LD [M]  drivers/helloworld/helloworld.ko
root@workstation:~/linux# make modules_install
root@workstation:~/linux# make install
root@workstation:~/linux# shutdown -r now
<reboot>
root@workstation:~# modprobe helloworld
root@workstation:~# dmesg
DerekMolloy
Wikipedia