关于“链接地图”的问题输出和“假设” MASM 汇编器指令
我是 MASM 的新手。所以这些问题可能是非常基本的。
当我使用 MASM 汇编器时,有一个名为“链接映射”的输出文件。其内容由数据段、代码段、堆栈段等各个段的起始偏移量和长度组成。我想知道,这些信息描述的是哪里?他们是在谈论各个段如何在 EXE 文件中定位,还是在 EXE 文件被程序加载器加载到内存后,段如何在内存中定位?
顺便说一句:“假设”指令有什么作用?我的理解是,它告诉汇编器将一些信息发送到exe文件头,以便程序加载器可以使用它来相应地设置DS、CS、SS、ES寄存器。我的说法正确吗?
提前致谢。
I am new to MASM. So the questions may be quite basic.
When I am using the MASM assembler, there's an output file called "Link Map". Its content is composed of the starting offset and length of various segments, such as Data segment, Code segment and Stack segment. I am wondering that, where are these information describing? Are they talking about how various segments are located within an EXE file or, how segments are located within memory after the EXE file being loaded into memory by a program loader?
BTW: What does the "Assume" directive do? My understanding is that it tell the assembler to emit some information into the exe file header so the program loader could use it to set DS, CS, SS, ES register accordingly. Am I right on this?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
链接器映射
这不是 MASM 特定的。它是链接器的一部分。 Ie
cl.exe
相同,与
也有此选项 (
/Fm
),它执行相同的操作。它是按出现顺序放置在 EXE 或 DLL 映像中的部分的列表。例如代码、数据、资源、导入表、导出表等。
偏移量是相对于图像部分的开始位置的。链接器可以将多个对象部分组合成图像部分。
例如,
上面是对象部分(它们来自
.obj
文件),因为它们包含以$
开头的后缀。链接器会将它们合并到最终图像模块中的一个.idata
部分(按后缀的字典顺序)。该偏移量相对于链接器分配导入地址表(.idata
部分)的起始位置。假设
提供编译时检查,以防止意外误用寄存器。它不会生成任何代码。请参阅
Linker map
this is not MASM specific. It is part of the linker. I.e.
is the same as
or
cl.exe
has this option too (/Fm
) which does the same thing.It is a list of the sections that are placed in the EXE or DLL image, in the order they appear. E.g. code, data, resources, import table, export table, etc.
The offset is relative to the start of the image section. A number of object sections may be combined into an image section by the linker.
E.g.
The above are object sections (they come from
.obj
files) since they contain a suffix starting with$
. The linker will merge them into one section.idata
in the final image module (in lexicographic order of the suffix). The offset is relative to the start of where the linker will allocate the import address table (.idata
section).Assume
Provides compile-time checks, to prevent accidental misuse of registers. It doesn't generate any code. See