Linux Kernel Learning (9) kernel image structure

Source: Internet
Author: User

There was a lot of content during the startup process, so I had to analyze it slowly. Before that, I also collected a lot of information and added some understanding here. It's hard to get started with the kernel.Source codeWe will cherish this hard-won moment.

To get the kernel structure, we have many methods, such as viewing kbuild makefile and documentation, but I chose to find it on the network, because we focus on how to analyze the source.Code, Especially the device driver.

Me
Taking bzimage as an example, it consists of setup. Elf and vmlinux, while vmlinux is composed of the binary file setup. Bin and
Vmlinux.bingroup, and vmlinux.binwill be Compressed Storage and changed to vmlinux.bin.gz. Therefore, bzimage consists of three parts:
Setup.elf?setup.bin=vmlinux.bin.gz.

Let's take a look at their distribution chart, which is described in text here:

0x00007c00 -- bootloader loads the Program , which is located in the hard disk MBR
0x00090000 -- 0x00090000 -- setup. elf startup sector 512b
0x00090200 -- setup. elf setup
0x00100000 -- vmlinux
(this is a big kernel)

Now, let's briefly introduce the following parts:
1. Bootloader:
The boot loader of the PC follows the Linux boot protocol 2.03, And the boot loader in the PC is run by the BIOS (
And the Operating System Boot Loader (such as Lilo and grub) located in the hard disk MBR. Bios
After hardware detection and resource allocation, read the boot loader in the hard disk MBR to the system ram, and then give the control to the operating system boot.
Loader. Boot Loader reads the kernel image from the hard disk to ram, and then jumps to the kernel entry point to run, that is, start the operating system.
2. setup. Elf:
It can be divided into the Boot Sector and setup sector. The first part of the Boot Sector (bootsect) is the first 512 bytes of bzimage, and the previous version is used to boot Linux from a floppy disk. The current version does not support booting from a floppy disk,
Otherwise, the error message "direct booting from floppy is no longer will be printed.
Supported. ", which will be seen in the code. The second part is the setup sector, which is a program that starts from 512 bytes. It runs in real mode and prepares the environment for Linux kernel startup in protection mode. This part will switch to the protection mode and jump to the kernel execution in the protection mode, that is, the vmlinux at 0x10000.
3. vmlinux:
This part is the code after entering the protection mode, which consists of the decompression program and the kernel image package.

Good
After a perceptual knowledge of the kernel image structure and the structure of the loaded memory, it will be of great help for us to discuss the following content, followed by source code analysis to understand the entire process of startup, this recognition will be even more
Profound. We hope that we can overcome the difficulties to the end. I will speed up the pace of analysis, and you are also the same. It is best to share some important things with me and make progress together. Such learning is the most harmonious and happy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.