节/段指令有多重要?
节/段指令有多重要?我注意到它们通常是可选的。另外,我注意到当您包含或不包含它们时,输出大小会发生变化。
我正在使用 NASM,如果有帮助的话。
How important are section/segment directives? I've noticed that they are usually optional. Also, I've noticed that the output size changes when you do or do not include them.
I'm using NASM, if that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们非常重要,因为如果将字符串保存在代码段中,程序执行速度可能会慢得多,并且字符串会破坏指令缓存中的数据。
如果您创建一个库(.lib 或类似的东西),它也很重要,因为由于上述原因,您不希望数据(字符串)直接位于可执行指令后面。
They are very important because if you save your strings in the Code segment the program could execute much slower and the Strings blow up the data in the Instruction cache.
If you create a Library(.lib or something like that) it is also important because you don't wan't data (strings) to lay directly behind your executable instructions because of the reasons above.
对于使用 NASM 的多节 bin 输出格式的任何重要内存布局来说,节都至关重要:https://www.nasm.us/xdoc/2.14.02/html/nasmdoc7.html#section-7.1.3
例如,这些是我正在设置的部分在我的一个程序中: https://hg. ulukai.org/ecm/ldebug/file/126b4d793c94/source/debug.asm#l109
DATA_ENTRY 和两个 ASMTABLE 部分都由同一段寻址,并且不会从加载到进程中的位置重新定位。 DATASTACK 也由前一个段寻址,但它是一个 nobits 部分。 CODE 由其自己的段寻址,因此 vstart=0。在初始化期间它也会被重新定位到 DATASTACK 后面的某个位置(具体位置取决于某些情况)。 INIT 也由其自己的段寻址。它首先重新定位自己,并在初始化结束时从进程的内存中丢弃。
Sections are crucial to any non-trivial memory layout using NASM's multisection bin output format: https://www.nasm.us/xdoc/2.14.02/html/nasmdoc7.html#section-7.1.3
For example, these are the sections I'm setting up in one of my programs: https://hg.ulukai.org/ecm/ldebug/file/126b4d793c94/source/debug.asm#l109
DATA_ENTRY and both ASMTABLE sections are all addressed by the same segment and are not relocated from where they are loaded into the process. DATASTACK is also addressed by the prior segment, but is a nobits section. CODE is addressed by its own segment, thus vstart=0. It is also relocated to somewhere behind DATASTACK during initialisation (the exact position depends on some circumstances). INIT is also addressed by its own segment. It relocates itself first, and is discarded from the process's memory at the end of initialisation.