SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Construction of the 
Linux kernel image 
Embedded Linux Course 
4-1
Linux Kernel Organization 
• Linux supports numerous architectures this 
means that it can be run on many types of 
processors, which include alpha, arm, i386, 
ia64, ppc, ppc64, and s390x. 
• Most of the source code is written in C and is 
hardware independent 
• A portion of the code is heavily hardware 
dependent and is written in a mix of C and 
assembly for the particular architecture. 
• The heavily machine-dependent portion is 
wrapped by a long list of system calls that serve 
as an interface. 
Embedded Linux Course
vmlinux image 
components 
Embedded Linux Course
make zImage V=1 
arm-linux-ld -EL -p --no-undefined -X -o vmlinux -T 
arch/arm/kernel/vmlinux.lds arch/arm/kernel/head.o 
arch/arm/kernel/init_task.o init/built-in.o --start-group 
usr/built-in.o arch/arm/kernel/built-in.o arch/arm/mm/built-in. 
o arch/arm/common/built-in.o arch/arm/mach-s3c2410/ 
built-in.o arch/arm/nwfpe/built-in.o kernel/built-in.o 
mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o 
crypto/built-in.o lib/lib.a arch/arm/lib/lib.a lib/built-in.o 
arch/arm/lib/built-in.o drivers/built-in.o sound/built-in.o 
net/built-in.o --end-group .tmp_kallsyms2.o 
0xC0008000 
Embedded Linux Course
Low-Level Architecture Objects 
Embedded Linux Course
Embedded Linux Course
Vmlinux 
(ELF object)objcopy 
Image 
(binary 
object) 
Embedded Linux Course 
gzip 
Asm wrapper around 
piggy.gz contains kernel 
image 
piggy.gz 
asm 
piggy.o 
Kernel 
proper 
Stipped 
binary 
kernel image 
compressed 
binary 
kernel 
misc.o 
head.o 
Bootable 
Kernel 
image 
Composite kernel image 
construction 
make zImage V=1
make zImage V=1 
make -f scripts/Makefile.build obj=arch/arm/boot MACHINE=arch/arm/mach-s3c2410/ 
arch/arm/boot/zImage 
arm-linux-objcopy -O binary -R .note -R .comment -S vmlinux 
arch/arm/boot/Image 
Kernel: arch/arm/boot/Image is ready 
------------------------------------------------------------------------------------------------------------- 
make -f scripts/Makefile.build obj=arch/arm/boot/compressed 
arch/arm/boot/compressed/vmlinux 
gzip -f -9 < arch/arm/boot/compressed/../Image > 
arch/arm/boot/compressed/piggy.gz 
arm-linux-gcc -Wp,-MD,arch/arm/boot/compressed/.piggy.o.d -nostdinc - 
isystem /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/include -D__KERNEL__ - 
Iinclude -mlittle-endian -D__ASSEMBLY__ -mapcs-32 -mno-thumb-interwork - 
D__LINUX_ARM_ARCH__=4 -march=armv4 -mtune=arm9tdmi -msoft-float -c - 
o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/piggy.S 
Embedded Linux Course
make zImage V=1 (cont.) 
arm-linux-ld -EL --defsym zreladdr=0x30008000 --defsym 
params_phys=0x30000100 -p --no-undefined -X 
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a -T 
arch/arm/boot/compressed/vmlinux.lds 
arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o 
arch/arm/boot/compressed/misc.o -o 
arch/arm/boot/compressed/vmlinux 
arm-linux-objcopy -O binary -R .note -R .comment -S 
arch/arm/boot/compressed/vmlinux arch/arm/boot/zImage 
Kernel: arch/arm/boot/zImage is ready 
refers to: arch/arm/mach-s3c2410/Makefile.boot 
Embedded Linux Course
Bootstrap Loader 
• Not to be confused with a bootloader, many 
architectures use a bootstrap loader (or second-stage 
loader) to load the Linux kernel image into 
memory. 
• Some bootstrap loaders perform checksum 
verification of the kernel image, and most 
perform decompression and relocation of the 
kernel image. 
• The bootloader controls the board upon power-up 
and does not rely on the Linux kernel in any 
way 
Embedded Linux Course
Bootstrap Loader (cont.) 
• In contrast, the bootstrap loader's primary 
purpose in life is to act as the glue between a 
board-level bootloader and the Linux kernel 
• It is the bootstrap loader's responsibility to 
provide a proper context for the kernel to run in, 
as well as perform the necessary steps to 
decompress and relocate the kernel binary 
image 
• It is similar to the concept of a primary and 
secondary loader found in the PC architecture. 
Embedded Linux Course
Composite kernel image : vmlinux 
Piggy.o Binary Kernel image 
misc.o 
head.o 
arm-linux-ld -EL --defsym zreladdr=0x30008000 
--defsym params_phys=0x30000100 -p --no-undefined -X 
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a -T 
arch/arm/boot/compressed/vmlinux.lds 
arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o 
arch/arm/boot/compressed/misc.o -o arch/arm/boot/compressed/vmlinux 
Embedded Linux Course 
Bootstrap Loader
ARM boot control flow 
Uboot 
Embedded Linux Course 
head.o 
head.o 
main.o 
start 
start 
start_kernel 
Power On 
Boot loader Bootstrap 
loader 
Kernel 
vmlinux 
Kernel 
arch/arm/boot/compressed/head.S main.o 
arch/arm/kernel/head.S
Kernel Entry Point: head.o 
• arch/<ARCH>/kernel/head.S 
• The head.o module performs architecture- and 
often CPU-specific initialization in preparation for 
the main body of the kernel. CPU-specific tasks 
are kept as generic as possible across 
processor families 
• Machine-specific initialization is performed 
elsewhere 
Embedded Linux Course
head.o performs the following tasks 
• Checks for valid processor and architecture 
• Creates initial page table entries 
• Enables the processor's memory management 
unit (MMU) 
• Establishes limited error detection and reporting 
• Jumps to the start of the kernel proper, main.c 
Embedded Linux Course
Kernel Startup: main.c 
• Every architecture's head.o module has a similar 
construct for passing control to the kernel 
proper. 
– b start_kernel 
• start_kernel() located in .../init/main.c. 
• main.c does all the startup work for the Linux 
kernel, from initializing the first kernel thread all 
the way to mounting a root file system and 
executing the very first user space Linux 
application program. 
Embedded Linux Course
Further Study 
• See the architecture-dependent portions of the 
linux source code, for example, system 
initialization and bootstrapping, exception vector 
handling, address translation, and device I/O. 
• Cross-Referencing Linux 
– http://lxr.linux.no 
To create a device driver, the programmer must have a 
register-leve specification for a given piece of hardware 
Embedded Linux Course

More Related Content

PDF
U-Boot - An universal bootloader
PPTX
Linux Initialization Process (2)
PPT
U boot porting guide for SoC
PDF
Jagan Teki - U-boot from scratch
PDF
Bootloaders
PDF
Arm device tree and linux device drivers
PPTX
Memory model
PPTX
Linux Memory Management
U-Boot - An universal bootloader
Linux Initialization Process (2)
U boot porting guide for SoC
Jagan Teki - U-boot from scratch
Bootloaders
Arm device tree and linux device drivers
Memory model
Linux Memory Management

What's hot (20)

PDF
Spi drivers
PDF
Making Linux do Hard Real-time
PPTX
Linux Device Tree
PDF
Memory management in Linux kernel
PPTX
Linux Initialization Process (1)
PPT
Linux memory consumption
PDF
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
PPTX
Linux Kernel MMC Storage driver Overview
PDF
Kdump and the kernel crash dump analysis
PDF
I2C Subsystem In Linux-2.6.24
PDF
Uboot startup sequence
PDF
Linux kernel debugging
PPTX
Introduction Linux Device Drivers
PDF
netfilter and iptables
PDF
Linux Porting
PDF
BeagleBone Black Bootloaders
PPTX
Linux Memory Management with CMA (Contiguous Memory Allocator)
PPT
Linux memory
PDF
Network Drivers
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Spi drivers
Making Linux do Hard Real-time
Linux Device Tree
Memory management in Linux kernel
Linux Initialization Process (1)
Linux memory consumption
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
Linux Kernel MMC Storage driver Overview
Kdump and the kernel crash dump analysis
I2C Subsystem In Linux-2.6.24
Uboot startup sequence
Linux kernel debugging
Introduction Linux Device Drivers
netfilter and iptables
Linux Porting
BeagleBone Black Bootloaders
Linux Memory Management with CMA (Contiguous Memory Allocator)
Linux memory
Network Drivers
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Ad

Similar to Linux Kernel Image (20)

PDF
Linux kernel driver tutorial vorlesung
PDF
Building
PPT
The-Linux-Kernel-Introduction-cs251-2001.ppt
PDF
Introduction To Linux Kernel Modules
PDF
Module 4 Embedded Linux
PPT
Basic Linux Internals
PPTX
Lect 1_Embedded Linux Embedded RTOS ppt
PPTX
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
PPT
U Boot or Universal Bootloader
PDF
Portin g
PPT
Linux kernel modules
ODP
Kernel compilation
PDF
Embedded Linux Kernel - Build your custom kernel
PDF
Building Embedded Linux Full Tutorial for ARM
PDF
Android memory analysis Debug slides.pdf
PDF
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
PDF
Part 02 Linux Kernel Module Programming
PPTX
Linux Kernel Tour
PPT
Linuxdd[1]
PDF
Linux kernel
Linux kernel driver tutorial vorlesung
Building
The-Linux-Kernel-Introduction-cs251-2001.ppt
Introduction To Linux Kernel Modules
Module 4 Embedded Linux
Basic Linux Internals
Lect 1_Embedded Linux Embedded RTOS ppt
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
U Boot or Universal Bootloader
Portin g
Linux kernel modules
Kernel compilation
Embedded Linux Kernel - Build your custom kernel
Building Embedded Linux Full Tutorial for ARM
Android memory analysis Debug slides.pdf
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Part 02 Linux Kernel Module Programming
Linux Kernel Tour
Linuxdd[1]
Linux kernel
Ad

More from 艾鍗科技 (20)

PPTX
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
PDF
TinyML - 4 speech recognition
PPTX
Appendix 1 Goolge colab
PPTX
Project-IOT於餐館系統的應用
PPTX
02 IoT implementation
PPTX
Tiny ML for spark Fun Edge
PDF
Openvino ncs2
PDF
Step motor
PDF
2. 機器學習簡介
PDF
5.MLP(Multi-Layer Perceptron)
PDF
3. data features
PPTX
心率血氧檢測與運動促進
PPTX
利用音樂&情境燈幫助放鬆
PPTX
IoT感測器驅動程式 在樹莓派上實作
PPTX
無線聲控遙控車
PPT
最佳光源的研究和實作
PPTX
無線監控網路攝影機與控制自走車
PPTX
Reinforcement Learning
PPTX
人臉辨識考勤系統
PPTX
智慧家庭Smart Home
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
TinyML - 4 speech recognition
Appendix 1 Goolge colab
Project-IOT於餐館系統的應用
02 IoT implementation
Tiny ML for spark Fun Edge
Openvino ncs2
Step motor
2. 機器學習簡介
5.MLP(Multi-Layer Perceptron)
3. data features
心率血氧檢測與運動促進
利用音樂&情境燈幫助放鬆
IoT感測器驅動程式 在樹莓派上實作
無線聲控遙控車
最佳光源的研究和實作
無線監控網路攝影機與控制自走車
Reinforcement Learning
人臉辨識考勤系統
智慧家庭Smart Home

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
System and Network Administration Chapter 2
PPTX
history of c programming in notes for students .pptx
PDF
top salesforce developer skills in 2025.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
L1 - Introduction to python Backend.pptx
PDF
Nekopoi APK 2025 free lastest update
PPTX
Introduction to Artificial Intelligence
PPTX
ai tools demonstartion for schools and inter college
PDF
Digital Strategies for Manufacturing Companies
PPTX
ISO 45001 Occupational Health and Safety Management System
Navsoft: AI-Powered Business Solutions & Custom Software Development
ManageIQ - Sprint 268 Review - Slide Deck
Upgrade and Innovation Strategies for SAP ERP Customers
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
System and Network Administration Chapter 2
history of c programming in notes for students .pptx
top salesforce developer skills in 2025.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Odoo POS Development Services by CandidRoot Solutions
CHAPTER 2 - PM Management and IT Context
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How to Migrate SBCGlobal Email to Yahoo Easily
L1 - Introduction to python Backend.pptx
Nekopoi APK 2025 free lastest update
Introduction to Artificial Intelligence
ai tools demonstartion for schools and inter college
Digital Strategies for Manufacturing Companies
ISO 45001 Occupational Health and Safety Management System

Linux Kernel Image

  • 1. Construction of the Linux kernel image Embedded Linux Course 4-1
  • 2. Linux Kernel Organization • Linux supports numerous architectures this means that it can be run on many types of processors, which include alpha, arm, i386, ia64, ppc, ppc64, and s390x. • Most of the source code is written in C and is hardware independent • A portion of the code is heavily hardware dependent and is written in a mix of C and assembly for the particular architecture. • The heavily machine-dependent portion is wrapped by a long list of system calls that serve as an interface. Embedded Linux Course
  • 3. vmlinux image components Embedded Linux Course
  • 4. make zImage V=1 arm-linux-ld -EL -p --no-undefined -X -o vmlinux -T arch/arm/kernel/vmlinux.lds arch/arm/kernel/head.o arch/arm/kernel/init_task.o init/built-in.o --start-group usr/built-in.o arch/arm/kernel/built-in.o arch/arm/mm/built-in. o arch/arm/common/built-in.o arch/arm/mach-s3c2410/ built-in.o arch/arm/nwfpe/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o lib/lib.a arch/arm/lib/lib.a lib/built-in.o arch/arm/lib/built-in.o drivers/built-in.o sound/built-in.o net/built-in.o --end-group .tmp_kallsyms2.o 0xC0008000 Embedded Linux Course
  • 5. Low-Level Architecture Objects Embedded Linux Course
  • 7. Vmlinux (ELF object)objcopy Image (binary object) Embedded Linux Course gzip Asm wrapper around piggy.gz contains kernel image piggy.gz asm piggy.o Kernel proper Stipped binary kernel image compressed binary kernel misc.o head.o Bootable Kernel image Composite kernel image construction make zImage V=1
  • 8. make zImage V=1 make -f scripts/Makefile.build obj=arch/arm/boot MACHINE=arch/arm/mach-s3c2410/ arch/arm/boot/zImage arm-linux-objcopy -O binary -R .note -R .comment -S vmlinux arch/arm/boot/Image Kernel: arch/arm/boot/Image is ready ------------------------------------------------------------------------------------------------------------- make -f scripts/Makefile.build obj=arch/arm/boot/compressed arch/arm/boot/compressed/vmlinux gzip -f -9 < arch/arm/boot/compressed/../Image > arch/arm/boot/compressed/piggy.gz arm-linux-gcc -Wp,-MD,arch/arm/boot/compressed/.piggy.o.d -nostdinc - isystem /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/include -D__KERNEL__ - Iinclude -mlittle-endian -D__ASSEMBLY__ -mapcs-32 -mno-thumb-interwork - D__LINUX_ARM_ARCH__=4 -march=armv4 -mtune=arm9tdmi -msoft-float -c - o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/piggy.S Embedded Linux Course
  • 9. make zImage V=1 (cont.) arm-linux-ld -EL --defsym zreladdr=0x30008000 --defsym params_phys=0x30000100 -p --no-undefined -X /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a -T arch/arm/boot/compressed/vmlinux.lds arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/misc.o -o arch/arm/boot/compressed/vmlinux arm-linux-objcopy -O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinux arch/arm/boot/zImage Kernel: arch/arm/boot/zImage is ready refers to: arch/arm/mach-s3c2410/Makefile.boot Embedded Linux Course
  • 10. Bootstrap Loader • Not to be confused with a bootloader, many architectures use a bootstrap loader (or second-stage loader) to load the Linux kernel image into memory. • Some bootstrap loaders perform checksum verification of the kernel image, and most perform decompression and relocation of the kernel image. • The bootloader controls the board upon power-up and does not rely on the Linux kernel in any way Embedded Linux Course
  • 11. Bootstrap Loader (cont.) • In contrast, the bootstrap loader's primary purpose in life is to act as the glue between a board-level bootloader and the Linux kernel • It is the bootstrap loader's responsibility to provide a proper context for the kernel to run in, as well as perform the necessary steps to decompress and relocate the kernel binary image • It is similar to the concept of a primary and secondary loader found in the PC architecture. Embedded Linux Course
  • 12. Composite kernel image : vmlinux Piggy.o Binary Kernel image misc.o head.o arm-linux-ld -EL --defsym zreladdr=0x30008000 --defsym params_phys=0x30000100 -p --no-undefined -X /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/libgcc.a -T arch/arm/boot/compressed/vmlinux.lds arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/misc.o -o arch/arm/boot/compressed/vmlinux Embedded Linux Course Bootstrap Loader
  • 13. ARM boot control flow Uboot Embedded Linux Course head.o head.o main.o start start start_kernel Power On Boot loader Bootstrap loader Kernel vmlinux Kernel arch/arm/boot/compressed/head.S main.o arch/arm/kernel/head.S
  • 14. Kernel Entry Point: head.o • arch/<ARCH>/kernel/head.S • The head.o module performs architecture- and often CPU-specific initialization in preparation for the main body of the kernel. CPU-specific tasks are kept as generic as possible across processor families • Machine-specific initialization is performed elsewhere Embedded Linux Course
  • 15. head.o performs the following tasks • Checks for valid processor and architecture • Creates initial page table entries • Enables the processor's memory management unit (MMU) • Establishes limited error detection and reporting • Jumps to the start of the kernel proper, main.c Embedded Linux Course
  • 16. Kernel Startup: main.c • Every architecture's head.o module has a similar construct for passing control to the kernel proper. – b start_kernel • start_kernel() located in .../init/main.c. • main.c does all the startup work for the Linux kernel, from initializing the first kernel thread all the way to mounting a root file system and executing the very first user space Linux application program. Embedded Linux Course
  • 17. Further Study • See the architecture-dependent portions of the linux source code, for example, system initialization and bootstrapping, exception vector handling, address translation, and device I/O. • Cross-Referencing Linux – http://lxr.linux.no To create a device driver, the programmer must have a register-leve specification for a given piece of hardware Embedded Linux Course