LMA和VMA

如果是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


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部