U-boot Link Script Analysis

Source: Internet
Author: User

Eclipse 64-bit: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/kepler/SR1/ Eclipse-standard-kepler-sr1-win32-x86_64.zip

If starting from NAND Flash, the 0 address corresponds to NAND flash, NAND flash can not be written like memory, through this to determine whether it is from the NAND flash boot

U-boot Most fundamental goal: start the kernel
1. Read the kernel from flash
2. Boot the kernel

A series of initialization such as single board initialization

Environment variables, see if there are no environment variables on flash, do not use the default environment variables

Start_armboot
Flash_init
Nand_init

-->main_loop

One: Boot kernel:
s = getenv ("Bootcmd")
Run_command (S ...)

U-boot Interface:
ReadLine (read in serial data)
Run_command

The heart of u-boot: Command! )

U-boot command:
1. Enter the command string, action (function name), and there will be a command structure.

Some environment variables or macros are generated when downloading files from the USB port to memory

Analysis of the U-boot link script:

Output_format ("Elf32-littlearm", "Elf32-littlearm", "Elf32-littlearm")
Output_arch (ARM)//Specify the platform for the output executable file to be arm
ENTRY (_start)
SECTIONS
{
. = 0x34000;
. = ALIGN (4);

. Text:
{
ARCH/START.O (. Text)
* (. Text)
}

. = ALIGN (4);
. Data:
{
* (. Data)
}

. = ALIGN (4);

. Rodata:
{
* (. Rodata)
}


. = ALIGN (4);

_bss_start =.;
. BSS:
{
* (. BSS)
}
_bss_end =.;

}


Meaning of the link script:
An executable img (image) file must have an entry point, and there can be only one global entry point, usually the address of the entry point is placed in the 0x0000000 location of the ROM (Flash),
So we have to get the compiler to know the portal address, and the process is done by modifying the connection script file.

Output_format ("Elf32-littlearm", "Elf32-littlearm", "Elf32-littlearm"): Specifies that the executable file output format is ELF32, small end and arm architecture

Output_format (default,big,little): The purpose of this line is to specify the output file format of output target file, altogether three kinds, the default is the first default if there is a command line option-eb, use
2nd BFD format; If you have a command-line option-el, use the 3rd BFD format. Otherwise, the first BFD format is selected by default.

Three output executable formats specified in default, big-endian, and small-ended cases, u-boot-1.1.6 here (default is first, i.e. elf32-littlearm)
Specifies that the executable file output format is ELF32, small end and arm architecture

Output_arch (ARM)//Specify the platform for the output executable file to be arm

ENTRY (_start)
ENTRY (_start) Here means--Specify the function entry address at startup, _start defined in the START.S of each CPU directory, and the actual startup run
The address segment is defined by the Text_base macro in/u-boot-1.1.6/board/smdk2410/config.mk at compile time, that is, text_base?=?0x33f80000

The following begins the analysis of sections:
SECTIONS
{
. = 0x00000000;
Here the dot ".", is the locator symbol (a typical GNU style).
Set the locator symbol to 0x00000000 (if not specified, the initial value of the symbol is 0).
The system starts at offset address 0. Note that this is just a code address offset value, and the true start address is specified by the cflags specified at compile time.
. = ALIGN (4);
4-byte alignment adjustment, then align (0x10) is 16-byte aligned

. text
{
CPU/ARM920T/START.O (. Text)/*.text segment space */
* (. Text)/* follow. The assignment of the contents of the text section */
}

The meaning of this script is to combine the. Text?section of all input files and cpu/arm920t/start.o into one. Text?section,
The address of the section is specified by the value of the locator symbol (the value of the locator symbol after the byte alignment).

. = ALIGN (4);
. Rodata:/*.rodata read-only data segment */
{
* (. Rodata)
}
This script means 4-byte alignment and then merges the. Rodata section of all input files into one. Rodata section,
The address of the section is specified by the value of the locator symbol (the value of the locator symbol after the byte alignment).

. = ALIGN (4);
__bss_start =.;/*. BSS section start position */
. BSS:
{
* (. BSS)
}
_end =.;/*. BSS End position */}
*************************************************************************************************************** ************************************************
*************************************************************************************************************** ************************************************
*************************************************************************************************************** ************************************************
*************************************************************************************************************** ************************************************

U-boot Link Script 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.