7

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.

aarelovich
  • 4,638
  • 10
  • 48
  • 94

1 Answers1

8

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

AJM
  • 1,014
  • 12
  • 23
baggio
  • 196
  • 1
  • 5
  • The startup code that uses this linker script copies the .data section from ROM to RAM. So, if I undestand you correctly, when you know this is going to happen you need the > ram AT > rom parameters? And sorry I can't see this link. And one other thing the sentence in "The address is the address of the section when program is being loaded" you are referring to LMA, right? – aarelovich Mar 11 '15 at 14:56
  • Yes, sorry, my intention was to write LMA(I edited my answer above). Another stackoverflow question also explains a similar example: [link](http://stackoverflow.com/questions/13831462/understanding-the-location-counter-of-gnu-linker-scripts). – baggio Mar 12 '15 at 20:08