链接汇编和c问题
试图了解如何链接在结构中定义的函数,该函数位于汇编代码中,并且尝试从 c 调用它。我认为缺少一个步骤,因为当我调用该函数时,我得到一个未解析的外部符号......
;Assembly.asm
.686p
.mmx
.xmm
.model flat
include Definitions.inc
.code
?Initialize@Foo@@SIXPAUFee@@@Z proc
jmp $
?Initialize@Foo@@SIXPAUFee@@@Z endp
end
//CFile.c
struct Fee
{
signed long id;
}
struct Foo
{
static void Initialize(Fee *);
}
int startup(Fee * init)
{
Foo::Initialize(init); //<-- This is unresolved
return 0;
}
Trying to understand how to link a function that is defined in a struct, the function is in the assembly code, and am trying to call it from c. I think am missing a step cause when I call the function, I get an unresolved external symbol...
;Assembly.asm
.686p
.mmx
.xmm
.model flat
include Definitions.inc
.code
?Initialize@Foo@@SIXPAUFee@@@Z proc
jmp $
?Initialize@Foo@@SIXPAUFee@@@Z endp
end
//CFile.c
struct Fee
{
signed long id;
}
struct Foo
{
static void Initialize(Fee *);
}
int startup(Fee * init)
{
Foo::Initialize(init); //<-- This is unresolved
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的汇编代码定义了一个函数,其修饰名称解码为
通过 undname.exe 实用程序获得的 As。 Foo::InitializeCurrentCpu() 不会与 Foo::Initialize() 匹配,名称不匹配。调用约定也没有。
首先用 C++ 编写此代码,然后查看 .map 文件以获取正确的修饰名称。或者用 extern "C" 声明函数以抑制 C++ 修饰。
Your assembly code defines a function whose decorated name decodes to
As obtained through the undname.exe utility. Foo::InitializeCurrentCpu() won't be a match for Foo::Initialize(), the name doesn't match. Nor does the calling convention.
Write this code in C++ first and look at the .map file for the correct decorated name. Or declare the function with extern "C" to suppress C++ decoration.