Posts

Showing posts from June, 2015

Linux Device Drivers Part 9 - More about Symbol tables

Image
In this part we will discuss about following topics About undefined symbol error and steps to solve it Is it mandatory to export the symbols ? Location of symbol table About system.map file in Linux 1. About undefined symbol error and steps to solve it The most common and most frustrating failure in loading an LKM is unresolved symbol, like this: insmod: error inserting 'helloworld.ko': -1 Unknown symbol in module To debug this error, 1. Use nm utility 2. Know symbol definitions (in next slide) Lets say my module is helloworld.ko In order to display symbol table, we use following command. $nm helloworld.ko. Output of this command is 00000000 r ____versions 0000002c r __mod_author22 00000000 r __mod_description24 00000020 r __mod_license23 00000040 r __mod_srcversion30 00000080 r __mod_vermagic5 00000063 r __module_depends 00000000 D __this_module 00000000 r _rheldata 00000000 T cleanup_module 00000000 B g_valu

Linux Device Drivers - Part 8 : Kernel Symbol Tables

Image
In this session we learn about 1. A symbol in Linux 2. How it is exported ? 3. Symbol and Symbol Table relationship 4. Idea behind exporting a Symbol 1. A Symbol in Linux In Linux, symbols are nothing but variables and functions that are needed to implement modularised drivers. Note that each and every symbol has its address in the memory. To make our understanding clear, lets draw a small diagram which shows a Linux Kernel Module with symbols ( Variables and functions ) in it. So in short, symbol is nothing but a variable or function in LKM How Symbols are Exported ? Exporting Kernel Symbols is typically done with  EXPORT_SYMBOL() EXPORT_SYMBOL_GPL() EXPORT_SYMBOL(), which exports a given symbol to all loadable modules  EXPORT_SYMBOL_GPL(), which exports a given symbol to only those modules that have a GPL-compatible license. (The first variation is far more common). GPL here is General Public License is widely used for free software license.

Linux Device Drivers Part -7 : Kernel Modules vs Applications

Image
In this part, we are going to discus about , The difference between Kernel Modules (KM) and Applications (APs) in brief . Before proceeding further, I strongly recommend to watch my earlier videos from "Linux Device Drivers Part -1 to Part 6". Though there are many differences, to keep it simple and to explain in brief , I have hand picked few differences and listed them as topics form, which can be easily remembered and recollected when required We compare below 6 topics between Kernel Modules (KM) and Applications (APs) 1. Initialisation 2. Which are Event Driven KM's or AP’s     3. About Exit Procedure in  KM's or AP’s   4. Ability to unload a module    5. Linking stage    6. Handling faults    This tutorial covers only brief description of all topics listed. This will help us to understand upcoming sessions with ease Lets start with our first topic, 1. Initialisation When we invoke a application, it starts and proceed ahead till end . Mo

Linux Device Drivers Part - 6 : Loading Listing and Unloading Kernel Modules

Image
In this part , we are going to discuss about 1. Loading Kernel modules 2. Listing  kernel modules 3. Unloading kernel modules Before going ahead with these topics, I strongly recommend you to watch my earlier videos on Linux Device Driver Part 1 to 5. Fine, lets start with our first topic 1. Loading Kernel modules  In earlier session " Linux Device Drivers Part-5 ", we learnt how to build a sample helloworld Linux Kernel module. In this session we will see how to load that sample module into the kernel. We have two kernel utilities which does the trick of loading modules into the kernel. We have two utilities to perform this task 1. insmod 2. modprobe In following slides we will discuss about these utilities, their syntax and usage So,What is insmod and what does it do ? Insmod is a kernel utility that installs loadable Kernel modules into kernel.         It actually loads the module code and data into the kernel land, it links any unresolved sym