In The Beginning...

The Linux boot process begins with the kernel's _stext function, located in arch/<host>/kernel/head.S. This function is called _start in some versions. Interrupts are disabled at this point, and only minimal memory accesses may be possible depending on the capabilities of the host hardware.

The code to invoke _stext is found in the host's bootloader, code that is technically not part of Linux itself. In most kernel implementations the bootloader is a standalone program that drags the kernel image from the storage media (flash memory, hard disk, floppy, CD, etc.) into RAM, decompresses it, and jumps to _stext.

The bootloader extracts the compressed kernel image to a predefined location that is appropriate for the target architecture; _stext is, by convention, located 0x1000 bytes after the begininning of the image.

In the Hitachi SH Linux kernel, the linker places the start of the kernel image at the address 0x80000000 and defines a symbol called _text there. Once the kernel image is decompressed, the bootloader jumps to the address (_text + 0x1000). Figure 3 shows the relevent portions of the bootloader's command file and startup code. The excerpts shown are taken from arch/sh/vmlinux.lds.S and arch/sh/boot/compressed/head.S.

/* linker configuration script */
SECTIONS
{
  . = 0x80000000 + CONFIG_MEMORY_START + 0x1000;
  _text = .;                    /* Text and read-only data */
  ...
}


/* bootloader code */
startup:
  ...
 
  /* Jump to the start of the decompressed kernel */
  mov.l   kernel_start_addr, r0
  jmp     @r0
  nop

kernel_start_addr:
        .long   _text+0x1000

Figure 3. The Hitachi SH kernel's linker configuration script and bootloader code.