0

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

我想做的是使用 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());
}

谢谢你的帮助..

4

2 回答 2

4

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

extern void start_thread( pointer );

static void UserMainHack()
{
    start_thread(((UserThread*)currentThread)->getUserMain());
}
于 2012-10-17T12:29:41.410 回答
2

使用“ Asm Label ”为您的函数 [declaration] 程序集链接:

extern void start_thread(pointer) __asm__("start_thread");

(并让.globalasm 端匹配它。)

它的工作原理很像extern "C",它可以用于函数和变量,而且它是单方面的(但这次是在 C 方面)。

于 2012-10-19T03:30:43.723 回答