This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The meaning of LMA and location counter in GNU ld


ali hagigat <hagigatali@gmail.com> writes:

> What is the real meaning of LMA? is it a physical address?
> When we assign some numbers to the location counter, what these
> numbers mean? Are they physical addresses? or virtual addresses? or
> they are just local addresses for ld?
> When we use some addresses in a linker command file, are they final
> physical addresses? or they show a range of 4 GB virtual addresses for
> a 32 bit Intel machine?

The LMA is the load address, as distinguished from the VMA which is the
virtual address.  It's easiest to understand the difference if you think
of a system without virtual memory.  The LMA is intended to specify the
address where the section should be loaded.  However, all references to
the section will be resolved as though the section were loaded at the
VMA.  In a typical use, the LMA will be in ROM and the VMA of the data
segment will be in RAM.  You will load the program into RAM at the LMA.
At program startup time, the contents of the data segment will be copied
from the LMA to the VMA.  It will thus be initialized and also be
writable.

As I say, that is the typical usage.  The exact meaning of the numbers
is ultimately going to depend on the mechanism used to load the program
when the program starts, whether that means jumping to an address in ROM
or loading some bytes of a disk or a network.  So there is no precise
way to answer some of your questions; the only answer is: it depends.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]