"功能层次关联” (即COMDAT代)在MASM组装? [英] "Function-level linking" (i.e. COMDAT generation) in MASM assembly?

查看:169
本文介绍了"功能层次关联” (即COMDAT代)在MASM组装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法,使MASM生成函数COMDATs,使未使用的功能链接器删除?

Is there any way to make MASM generate COMDATs for functions, so that unused functions are removed by the linker?

(即。我在寻找 /戈瑞的等价MASM)。

(i.e. I'm looking for the equivalents of /Gy for MASM.)

推荐答案

不是直接的,而是可行的;这里讨论 和<一个href=\"http://wayback.archive.org/web/20040212035208/http://www.launcherasm.com/technical/comdats.html\"相对=nofollow>这里。

Not straightforward, but doable; discussed here and here.

第一步是把每个功能在单独的段用的名字,如的.text $ A,$的.text B,等等。这样,汇编器将不再凝聚成一个单一的.text段,但最终链接将;有一个在微软的接头有关的东西过去在该节的名称$字符一个特殊的规则。汇编器会发出多个code节的.obj文件。我已经试过了,我可以证实它。 MASM的至少一种香料一样。 :)

The first step involves putting each function into a separate segment with names like .text$a, .text$b, etc. This way, the assembler won't unite them into a single .text section, but the linker eventually will; there's a special rule in Microsoft linkers regarding the stuff past the $ character in the section name. The assembler will emit an .obj file with multiple code sections. I've tried that, I can confirm that it does. At least one flavor of MASM does. :)

然后,他们建议运行在目标文件,它将标志着你作为部分的COMDATs实用。该工具似乎失去了时间和位衰减,但其作用大致可以推断出。它读取并分析COFF obj文件,经过部分和一个掴COMDAT标志上的所有.text段。我认为这只是一个标志;可以更。作为第一步,其娱乐,我建议用编译/ Gy的C文件,然后没有,并通过一些低级的PE / COFF浏览器比较两个.obj文件。我没去这么远,因为我的情况是完全不同的。

Then they suggest running an utility over an object file that will mark your sections as COMDATs. The said utility seems to be lost to time and bit decay, but its action can be roughly deduced. It reads and parses a COFF .obj file, goes through sections and slaps a COMDAT flag on all .text sections. I assume it's just a flag; could be more. As a first step to its recreation, I'd suggest compiling a C file with /Gy then without, and comparing the two .obj files via some low-level PE/COFF browser. I didn't go this far, since my scenario was rather different.

这篇关于&QUOT;功能层次关联&rdquo; (即COMDAT代)在MASM组装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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