汇编代码文件如下:
section .bss
section .data
section .text
global _gettsc
_gettsc:
rdtsc
rol rdx,32
or rdx,rax
mov rax,rdx
ret
C/C++代码文件如下:
#include <stdio.h>
extern unsigned long _gettsc();
int main()
{
unsigned long count = _gettsc();
return 0;
}
如果c++代码文件命名为.cpp则按照C++去编译链接会报错:
nasm -f elf64 -F stabs -Ox standerd.asm -o standerd.asm.o
make: Circular standerd.asm <- standerd.asm.o dependency dropped.
g++ -lpthread -I./ -masm=intel -O3 main.cxx.o standerd.asm.o -o test
main.cxx.o: In function `main':
main.cpp:(.text.startup+0x5): undefined reference to `_gettsc()'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
makefile:19: recipe for target 'all' failed
如果C/C++代码文件改名为.c按照c语言去编译链接则不会报错
请问有什么解决办法吗?