c - undefined reference 在 C 中调用汇编函数

标签 c assembly undefined-reference

我就是找不到这个问题的解决方案..

我正在尝试做的是使用 gcc 调用汇编函数。随便看看:

// Somewhere in start.s
global _start_thread
_start_thread:
  ; ...


// Somewhere in UserThread.cpp
extern void _start_thread( pointer );

static void UserMainHack()
{
    _start_thread(((UserThread*)currentThread)->getUserMain());
}

感谢任何帮助..

最佳答案

您知道许多 C 链接器在查找标识符时自动添加前导下划线吗?所以在 C 源代码中(不是汇编程序源代码),只需删除前导下划线:

extern void start_thread( pointer );

static void UserMainHack()
{
    start_thread(((UserThread*)currentThread)->getUserMain());
}

关于c - undefined reference 在 C 中调用汇编函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12934233/

相关文章:

c++ - uint8、uint16等的使用

c++ - 带有 boost 测试的 Autoconf - 链接器问题

assembly - 如何保护 x86 程序集中的多重声明?

assembly - MIX 中的除法是如何进行的?

assembly - 哪种类型的汇编跳转指令最有用?

c++调用类的构造函数

linux - 无法将应用程序与 mudflap 链接

linux上的C网络服务器编程

c - "git log -1 fullpath/myfile"与 libgit2

c++ - 将 int 数组放入 char 中。 C 或 C++