Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does > region1 AT > region2 mean in an LD linker script?

Tags:

linker

I'm trying to understand a third party linker script.

At the beginning of the script it defines two memory (using MEMORY {...}) called iram and dram.

Then there are a few sections defined that have the following syntax:

.data{
...
} > dram AT > iram

I know that > dram at the end means to position that section (.data in this case) in the dram region. However I don't understand what the "AT > iram" means.

like image 552
aarelovich Avatar asked Mar 02 '15 12:03

aarelovich


People also ask

How do you read a linker script?

You can use the ` --verbose ' command line option to display the default linker script. Certain command line options, such as ` -r ' or ` -N ', will affect the default linker script. You may supply your own linker script by using the ` -T ' command line option.

What is LD linker script?

Linker Scripts The ld command language is a collection of statements; some are simple keywords setting a particular option, some are used to select and group input files or name output files; and two statement types have a fundamental and pervasive impact on the linking process.

What is align in linker file?

Section alignment with the linkerThe linker permits ELF program headers and output sections to be aligned on a four-byte boundary regardless of the maximum alignment of the input sections. This enables armlink to minimize the amount of padding that it inserts into the image.

What does keep do in linker script?

The KEEP statement within a linker script will instruct the linker to keep the specified section, even if no symbols inside it are referenced. This statement is used within the SECTIONS section of the linker script.


1 Answers

The dram part of the .data definition in your example specifies the virtual memory address (VMA) of the .data section, whereas the the iram part specifies the load memory address (LMA).

The VMA is the address the section will have when the program is run. The LMA is the address of the section when program is being loaded. As an example this can be used to provide initial values for global variables in non-volatile memory which are copied to RAM during program load.

More information can also be found in the manual for the GNU linker ld: https://sourceware.org/binutils/docs/ld/Output-Section-Attributes.html#Output-Section-Attributes

like image 143
baggio Avatar answered Sep 27 '22 18:09

baggio