Runtime domain and load-time domain (running address and loading address)

Publisher:初入茅庐Latest update time:2015-09-15 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
AT (ldadr): defines the storage (load) address of this section.

Let’s look at a simple example:

SECTIONS    

 firtst  0x00000000  head.o  init.o    

 second  0x30000000  AT(4096)  main.o    

}

        In the above, head.o is placed at the beginning of address 0x00000000, init.o is placed after head.o, and their running addresses are also 0x00000000, that is, the connection and storage addresses are the same (no AT specified); main.o is placed at the beginning of 4096 (0x1000, which is AT specified, storage address), but its running address is 0x30000000, and before running, it needs to be copied from 0x1000 (load address) to 0x30000000 (run address), and this process also uses reading Nand  flash. This is the difference between storage address and connection (running) address, called load time domain and run time domain, which can be specified separately in the .lds connection script file.

        The compiled .lds file can be called with -Tfilename when using the arm-linux-ld link command, such as arm-linux-ld  –Tnand.lds  xo  yo  –o  xy.o. You can also use the -Ttext parameter to directly specify the link address, such as arm-linux-ld  –Ttext  0x30000000  xo  yo  –o  xy.o.

In summary:

         Connection address <==> operation address
         storage address <==> load address

Since the program has two addresses, it involves some differences in jump instructions. Let's take a closer look at these jump instructions.

        In ARM assembly, there are two common jump methods: b jump instruction and ldr instruction to assign a value to PC.

(1)        step1  : The b jump instruction is a relative jump that depends on the current PC value. The offset is calculated using bits [23:0] of the instruction itself. This means that the program using the b instruction does not depend on the location of the code to be jumped to, but only on the instruction itself.

(2)        ldr  pc,  =step1  : This instruction reads data from a certain location in memory (step1) and assigns it to the PC. It also depends on the current value of the PC, but the offset is the link address (address at runtime) of that location (step1), so it can be used to implement a program jump from Flash to RAM.

         We will often use the feature of "storage address and connection address are different" (technically called load time domain and runtime domain) in the future: most machines start running from address 0 when powered on, but there are always many limitations in performance when running programs from address 0 (when the running address and the load address are different, only relative jumps can be used). Therefore, generally at the beginning, position-independent instructions are used to copy the program itself to its connection address, and then the method of assigning values ​​to the pc register is used to jump to the memory starting from the connection address to execute the rest of the code.

Reference address:Runtime domain and load-time domain (running address and loading address)

Previous article:S3C2440 touch screen
Next article:ARM working mode

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号