Understanding the Linux Kernel Initcall Mechanism
Creating Dynamic Function-Pointer Call Tables
Abstract
While browsing through the Linux kernel, I came upon a technique for creating a segment of function pointers which can be called at a later time in the order that they are inserted into the segment. The kernel uses this mechanism to call device driver initialization routines at boot-up. I had a hard time finding clear information about what was going on and how it worked. After much googling (and some code doodling) I understand what is happening. This paper is an attempt at putting what I understand of this process down on paper so others may hopefully find it useful.
NOTE: This technique depends on, and requires the use of, the GNU compiler and linker tools. Additionally, the ELF binary executable format must be used. This is not a general-purpose ANSI-C compliant technique.