reference
每一个loadable
或allocatable
的section
都有两个地址。分别是:
- VMA: virtual memory address. This is the address the section will have when the output file is run.
- LMA: load memory address. This is the address at which the section will be loaded.
绝大部分时候LMA
与VMA
都是相同的,程序都是先加载,后运行,在程序开始运行之前被加载到的地址就是LMA
,当程序开始运行后,其地址就是VMA
。为什么要有两种地址?因为在程序开始运行时,有一些section
需要被移动,例如当嵌入式系统中先都将代码和数据加载到了ROM中,此时的地址就是LMA
,但是当开始运行之后,需要将数据部分拷贝到RAM中,此时数据的地址就是VMA
。