【发布时间】:2012-08-12 18:54:42
【问题描述】:
我正在尝试让 VisualStudio 2010 C 程序调用 fastcall 约定汇编例程。
这是C代码中的声明:
extern boolean _fastcall InNonSuspendableCriticalRegion(DWORD);
这是汇编代码中的声明:
public @InNonSuspendableCriticalRegion@4
@InNonSuspendableCriticalRegion@4 proc near ; fastcall
<code>
@InNonSuspendableCriticalRegion@4 endp
我收到以下链接器错误:
Assembling: C:\DMS\Domains\PARLANSE\Tools\RunTimeSystem\Source\PARLANSE0.asm
1>RuntimeSupport.obj : error LNK2001: unresolved external symbol @InNonSuspendableCriticalRegion@4
我确定我做错了什么傻事,但我看不到。
MS 文档很难弄清楚,因为它非常模糊。我记得在过去的迷雾中,汇编器也会进行一些名称修改,所以我不确定如何 如果是的话,我提供的名称会被破坏。
这是关于如何操作的most explicit reference,我想我完全遵循它;它说,
13. FASTCALL Caller and Callee Summary
The following sample illustrates the code generated in the calling function and in the called function to support __fastcall, the fastcall calling convention:
int __fastcall FastFunc( int a, int b );
calling function called function
-------------------------------------------
mov edx, b @FastFunc@8 PROC NEAR
mov ecx, a .
call @FastFunc@8 .
. .
. RET 8
. @FastFunc@8 ENDP
有什么线索吗?
谢谢...
【问题讨论】:
-
C 代码以剪切-粘贴形式显示。您认为问题出在单“_”上吗?好的,我也对 MS 约定感到困惑,因为“_fastcall”是合法的并且被 C 编译器接受。
-
...我在 C 声明中尝试了“__fastcall”。行为上没有区别。
-
使用额外选项进行组装以生成地图文件怎么样?它应该包含实际的符号(名称)。
-
此外,您应该能够在
PROC指令中指定调用约定,请参阅PROC'slangtypeoption 和.MODEL'slangtypes的列表。这应该会产生适当的名称修饰并让您访问 PROC 的参数(当然,如果已声明)。
标签: assembly x86 declaration masm fastcall