LMA和VMA

来源:互联网 发布:美恰软件 编辑:程序博客网 时间:2024/05/22 02:30

如果是PC(windows/linux),通常LMA就是VMA, 作为shell的loader负责把程序载入正确的地址(VMA).
如果是嵌入式(没有系统或者非常简单的系统) 通常处于ROM部分的代码将负责搬运工作。 (通常是crt0的工作)

在一份参考pdf中给出了一个简单的搬运代码:

// The following are constructs created by the linker, indicating where the // "data" and "bss" segments reside in memory. The initializers for// the "data" segment resides immediately following the "text"// segment.void ResetISR(void){  unsigned long *src, *dst;  //  // Copy the data segment initializers from flash to SRAM.  //  src = &_etext;  dst = &_data;  while(dst<&_edata) *dst++=*src++;  //  // Zero fill the bss segment.  //  for(dst=&_bss;dst<&_ebss;dst++)*dst = 0;  //  // Call the application's entry point.  //  main();}

参考链接:
https://www.crifan.com/detailed_lma_load_memory_address_and_vma_virtual_memory_address/
https://www.embeddedrelated.com/showthread/comp.arch.embedded/77071-1.php