admin管理员组文章数量:1387431
Say I need a proc called 'sub'
(why - because I am writing a compiler that generates MASM source. The programmer can call a function whatever they like, and because it might be part of a library called from another program written in another language I cant mangle the name)
I have worked out I need this
option nokeyword:<sub>
but now I cannot use the sub
instruction. I guessed that maybe I could turn it back on by doing
option nokeyword:<>
ie , clear the list of un-reserved words. But that doesnt work
I looked at the output of msvc with /FA to see what it does, but the code it generates gets rejected by ml64. I cant find another compiler that generates MASM as an intermediate
Say I need a proc called 'sub'
(why - because I am writing a compiler that generates MASM source. The programmer can call a function whatever they like, and because it might be part of a library called from another program written in another language I cant mangle the name)
I have worked out I need this
option nokeyword:<sub>
but now I cannot use the sub
instruction. I guessed that maybe I could turn it back on by doing
option nokeyword:<>
ie , clear the list of un-reserved words. But that doesnt work
I looked at the output of msvc with /FA to see what it does, but the code it generates gets rejected by ml64. I cant find another compiler that generates MASM as an intermediate
Share Improve this question asked Mar 18 at 17:44 pm100pm100 50.4k24 gold badges92 silver badges154 bronze badges 3 |2 Answers
Reset to default 4Well here's the answer - hinted at by @jester
mangle the name, say sub -> __sub
then add alias <sub> = <__sub>
An alias can be a reserved word.
Using ALIAS
didn't work well for me when trying to create static libraries. I'd end up with the mangled name in the symbol table as External and the real name (created by ALIAS
) as WeakExternal. Then, when linking against it, it would generally call the WeakExternal one, which for some reason pointed to an empty region of memory. If someone knows how to fix that, I'd like to hear.
Anyway, the method I found was to simply use =
to declare a new name for the mangled proc name.
First I would declare all my mangled procs as private: @@@sub PROC PRIVATE
. This is the equivalent of marking it static
in C and prevents anything from linking against it.
If I'm calling it within this ASM file I simply use the mangled name: call @@@sub
.
To make it available to other compilation units, I put the following at the bottom of the ASM file, because OPTION NOKEYWORD
will of course render "sub" unusable after this.
OPTION NOKEYWORD: <sub>
sub = @@@sub
PUBLIC sub
本文标签: assemblyhow to create a MASMML64 proc with the same name as a reserved wordStack Overflow
版权声明:本文标题:assembly - how to create a MASMML64 proc with the same name as a reserved word - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744498582a2609182.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
ALIAS
? – Jester Commented Mar 18 at 18:29