如何在部分上使用 fixups 属性? [英] How to use the fixups attribute on a section?

查看:31
本文介绍了如何在部分上使用 fixups 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修正"在应用于某个部分时究竟有什么作用?在 fasm 示例中,我发现了以下部分声明,但我真的不确定 fixups 属性的作用,我在 fasm 文档中找不到太多相关信息.

What exactly does "fixups" do when applied on a section? In a fasm sample i found the following section delcaration and i'm really not sure what the fixups attribute does, i couldn't find much information on that in the fasm documentation.

section '.reloc' fixups data readable discardable
if $=$$
    dd 0,8          ; if there are no fixups, generate dummy entry
end if

推荐答案

这似乎是 FASM 如何生成 PECOFF DLL 的错误..reloc 部分仅适用于 PECOFF 图像(EXE 和 DLL),并提供允许在任何地址加载图像的重定位(或修复").(PECOFF 目标文件中使用了不同种类的重定位;这些修正没有放在 .reloc 部分中.)

This appears to be a workaround for a bug in how FASM generates PECOFF DLLs. The .reloc section only applies to PECOFF images (EXEs and DLLs), and provides relocations (or "fixups") that allow the image to be loaded at any address. (Relocations of a different sort are used in PECOFF object files; these fixups aren't put in the .reloc section.)

FASM 中的错误是,如果 DLL 不需要任何重定位而不是根本不生成重定位,它将生成一个空的 .reloc 部分.如果有空部分,Windows 将拒绝加载 DLL(或 EXE).如果 .reloc 部分没有任何内容,该解决方法通过添加一个虚拟的基本重定位块"来强制非空 .reloc 部分.

The bug in FASM is that it will generate an empty .reloc section if the DLL doesn't need any relocations rather than not generating one at all. Windows will refuse to load a DLL (or EXE) if has an empty section. The workaround forces a non-empty .reloc section, by adding a dummy "base relocation block" if the .reloc section doesn't have any contents.

显然 FASM 的开发者并不认为这是 FASM 中的错误,而是 Windows 中的错误,因此没有修复它.

Apparently the developer of FASM doesn't think this is a bug in FASM, but rather a bug in Windows, and so hasn't fixed it.

为了直接回答您的问题,fixups 关键字似乎表明该部分是 FASM 的特殊部分,它用于如上所述的图像重定位.与其他属性不同,它不对应于 PECOFF 图像中使用的部分标志之一,因此它似乎只能由 FASM 在内部使用.

To answer your question directly, the fixups keyword appears to indicate that this section is special to FASM, that it's used for image relocations as described above. Unlike the the other attributes it doesn't correspond to one of the section flags used in PECOFF images, so it appears to only be used internally by FASM.

这篇关于如何在部分上使用 fixups 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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