Uboot Link Script (why link script required)

Source: Internet
Author: User
Tags bind
Uboot Link Script (why link script required)

The linker has two main functions, one is to combine several input files (. o files) into an output file (such as an elf-formatted executable file) according to certain rules; One is to bind the symbol to the address (the loader also does this part of the work)

The program from the source code to the binary executable file needs to go through:

Preprocessing with preprocessor, compilation with compilers, assembler, linker with linker

The linker has two functions, one is to combine several input files (. o files) into an output file (such as an elf-formatted executable file) according to certain rules; One is to bind the symbol to the address (the loader also does this part of the work). The linker has a default link script compiled into the binary code, which in most cases uses it to link the input file and generate the target file

We can also write our own merge rules, that is, our own link script. Uboot need more rules, because it involves relocation, the relocation of the relevant code must be placed before the first 16KB. (in addition, the link script can also define its own segment implementation in the order of the execution of the program, the source code is supported by related codes)

uboot Link Script Simple analysis:

When designing a program, it assigns a run address (link address) to the program. That is, in the process of compiling the program is actually aware of the program will be run at the time of the address (running address), and must give the compiler linker to specify this address (link address) only line. The resulting binary program is theoretically related to the specified run address, which must be placed at the address (link address) given at the time the link was compiled, otherwise it cannot run (location-related code). But there are specific instructions that he can have with the specified address (the link address), which means that the code will run normally wherever it is run (location-related code)

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.