Linux kernel porting (iv)--makefile and link scripting analysis

Source: Internet
Author: User

1:makefile Analysis

(1) Kernel makefile writing and rules and so on Uboot makefile is the same, even makefile a lot of content is the same.

(2) The makefile of kernel is more complicated than the makefile of Uboot, here we do not have a detailed analysis of the line.

(3) There are only a few things in the makefile that I would emphasize that other places of non-emphasis can be temporary.

(4) The kernel version number of the kernel has just been defined in makefile. This version number is very important (in the modular drive installation will need to use), you should pay attention to check, will change.

(5) When make compiles the kernel, it is also possible to give the kernel makefile via the command line (as with the Uboot Configuration compilation Shishun). For example, make o=xxx can specify not to compile in the source code directory, but to compile under a separate folder.

(6) It is important to define 2 variables in the top-level makefile of kernel, one is arch and the other is cross_compile. Arch determines the current configuration of the compiled path, such as Arch = arm, in the future in the source directory to operate the Arch/arm directory. The cross_compile is used to specify the path and prefix of the cross-compilation toolchain.

(7) Cross_compile = xxx and arch = xxx and o=xxx These can be passed to the top-level makefile by command-line arguments at make.

So sometimes you see someone compiling the kernel: Make O=/tmp/mykernel arch=arm cross_compile=/usr/local/arm/arm-2009q3/bin/ arm-none-linux-gnueabi-


2: Link Script analysis

(1) The purpose of analyzing the connection script is to find the entry of the whole program.

(2) The kernel connection script is not provided directly, but instead provides a compilation file Vmlinux.lds.s, and then compiles the assembly file at compile time to get the real link script vmlinux.lds.

(3) VMLINUX.LDS.S in the arch/arm/kernel/directory.

(4) Think: Why does the Linux kernel not provide vmlinux.lds directly and provide a VMLINUX.LDS.S and then dynamically generate vmlinux.lds at compile time?

Guess: the. lds file can only be written to death and cannot be compiled with conditions. But we do have conditional compilation requirements in kernel, but the LDS format doesn't support it, so kernel workers find an opportunistic approach, is to write Vmlinux.lds into a compilation format, and then the assembler processes the conditional compilation to deal with, get a vmlinux.lds that does not need conditional compilation.

(5) Where is the starter? Entry (stext) from Vmlinux.lds can know that the entry symbol is stext, searching for this symbol in SI and discovering the head in the arch/arm/kernel/directory. Both in S and Head-nommu.s.

(6) head. S is the kernel boot file with the MMU enabled, which is equivalent to start in Uboot. S Head-nommu. S is a kernel boot file that is not in use of the MMU case.


Linux kernel porting (iv)--makefile and link scripting analysis

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.