elf 文件中各节的虚拟地址和物理地址 [英] virtual and physical addresses of sections in elf files

查看:134
本文介绍了elf 文件中各节的虚拟地址和物理地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

objdump 如何计算 elf 段的物理地址 (LMA)?据我所知,elf 节标题仅包含节 [1] 的虚拟地址 (VMA).

How does objdump compute the physical address (LMA) of elf sections? As far as I can tell, elf section headers only contain the virtual address (VMA) of sections [1].

通常,VMA 和 LMA 是相同的.但对于初始化数据段 (.data),VMA 是变量的 RAM 位置,LMA 是初始值所在的 ROM 位置.Crt0 负责在调用 main() 之前将初始值复制到 RAM 中.例如:

Usually, VMA and LMA are the same. But for initialized data sections (.data), the VMA is the RAM location of the variables and LMA is the ROM location where the initial values are located. Crt0 is responsible for copying the initial values into RAM before main() is called. For example:

$ objdump -h my.elf
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0003c3d0  00080000  00080000  00010000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  5 .data         000008d0  40000000  000d08d4  00060000  2**3
                  CONTENTS, ALLOC, LOAD, DATA

-汤姆

[1] http://www.ouah.org/RevEng/x430.htm

推荐答案

查找有关 LMA 的信息:http://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/binutils/docs/ld/Basic-Script-Concepts.html#Basic-Script-Concepts

Find this about LMA: http://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/binutils/docs/ld/Basic-Script-Concepts.html#Basic-Script-Concepts

重要的是:

每个可加载或可分配的输出节都有两个地址.第一个是 VMA,即虚拟内存地址.这是运行输出文件时该部分将具有的地址.第二个是LMA,或加载内存地址.这是该部分将被加载的地址.在大多数情况下,这两个地址是相同的.它们可能不同的一个例子是数据段被加载到 ROM 中,然后在程序启动时复制到 RAM 中(这种技术通常用于在基于 ROM 的系统中初始化全局变量).在这种情况下,ROM 地址将是 LMA,而 RAM 地址将是 VMA

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

这篇关于elf 文件中各节的虚拟地址和物理地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆