1
所以我想鏈接一個簡單的程序集與C++,到目前爲止沒有運氣。鏈接C++和程序集時分段錯誤
大會腳本
section .data
global getebx
getebx:
mov eax, 0x0
cpuid
mov eax, ebx
ret
C++
#include <iostream>
extern "C" unsigned getebx();
int main(){
std::cout << (const char *)getebx()<< std::endl;
return 0;
}
,並建立我只是運行以下命令。
nasm -f elf32 cpuidtest.asm
g++ -m32 -g main.cc cpuidtest.o
當我運行可執行文件時,出現了分段錯誤(Core Dumped)錯誤。所以我的下一個本能就是把它帶到gdb。這是什麼它返回:
program received signal SIGSEGV, Segmentation fault.
0xf7da0e86 in ??() from /lib/i386-linux-gnu/libc.so.6
我該如何解決這個問題?先謝謝你。
可悲的是,這並沒有完全解決這個問題會不會是一個問題,這方面的看法?非常感謝你的幫助。 – Pnelego
@Pnelego查看更新。 – Jester
修復了一切,謝謝你的幫助。 (我不相信我沒有看到)。 – Pnelego