Re: VMA vs LMA?
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Aug 2007 13:19:40 +0200
dspfun wrote:
Hi!
What is the difference between VMA (Virtual Memory Address) and LMA
(Load Memory Address)?
Your quotation from the ld documentation explains that pretty well, I thought.
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?
No, these are different situations. When an OS loads code from a file, the OS does the copying. Usually the VMA and LMA are the same, so that the OS loads the initialised data section directly into place. With a ROM'ed program, where the program is run directly from the ROM rather than being first copied into RAM (in which case you have the same situation as an OS and a file), the code at the beginning of the program copies the data across and also clears the bss - this is part of the crt0 startup code.
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)?
That is the case *if* the program is copied into RAM before running.
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)?
See above.
BRs!.
- Follow-Ups:
- Re: VMA vs LMA?
- From: dspfun
- Re: VMA vs LMA?
- From: larwe
- Re: VMA vs LMA?
- References:
- VMA vs LMA?
- From: dspfun
- VMA vs LMA?
- Prev by Date: Re: [OT] Freescale English?
- Next by Date: Re: [OT] Freescale English?
- Previous by thread: VMA vs LMA?
- Next by thread: Re: VMA vs LMA?
- Index(es):
Relevant Pages
|