在linux上
.text
.globl MyFunc
Func:
....
call my_jump
ret
extern "C" FUNC_NO_RETURN void my_jump();
extern "C" __attribute__((noinline)) void my_jump()
{
return;
}
当链接调用“MyFunc”的模块时,我收到以下错误:(在asm代码中添加对my_jump的调用之前,一切正常)
"relocation R_X86_64_PC32 against 'longjmp_hack' can not be used when making a shared object; recompile with -fPIC"
任何想法?
答案 0 :(得分:1)
从file2.h中删除FUNC_NO_RETURN
e.g。的 file2.h:强>
extern“C”void my_jump();
和 file4.c:
#include "file2.h"
extern "C" void MyFunc();
main(){
MyFunc();
}
并修复 file1.s 中的拼写错误:
.text
.globl MyFunc
MyFunc:
call my_jump
ret
这一切都适合我......
g ++ file1.s file3.cpp file4.c -o a.out
编译器版本;
$ g ++ --version
g ++(GCC)4.6.2 20111027(Red Hat 4.6.2-1)
Linux版本:3.1.5-6.fc16.x86_64