Hi!
What is the difference between VMA (Virtual Memory Address) and LMA (Load Memory Address)?
The Gnu ld documentation has the following explanation: "Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This is the address the section will have when the output file is run. The second is the LMA, or load memory address. This is the address at which the section will be loaded. In most cases the two addresses will be the same. An example of when they might be different is when a data section is loaded into ROM, and then copied into RAM when the program starts up (this technique is often used to initialize global variables in a ROM based system). In this case the ROM address would be the LMA, and the RAM address would be the VMA. "
In the above, "who" copies the data section from ROM to RAM? Isn't this the same as when a program that is started from a shell is copied from the harddrive to RAM by a loader, i.e. normal procedure?
As far as I have understood things the loader loads the executable into RAM (from secondary storage) and then execution starts. So to me the address of a section when it is run (VMA) is the same as the address to where the section is loaded (LMA)?
If a section can be loaded to one address and then moved to another section when run, who then moves the section from the load address (LMA) to the run address (VMA)?
When is the LMA referenced (and by who) and when is the VMA referenced (and by who)?
BRs!