これは foo.asm です
extern choose;
[section .data]
num1st dq 3
num2nd dq 4
[section .text]
global main
global myprint
main:
push qword [num2nd]
push qword [num1st]
call choose
add esp,8
mov ebx,0
mov eax,1
int 0x80
; pop qword [num1st]
; pop qword [num2nd]
myprint:
mov edx,[esp+8]
mov ecx,[esp+4]
mov ebx,1
mov eax,4
int 0x80
; pop qword [num1st]
; pop qword [num2nd]
ret
それはC-asm-プログラムです
これはbar.cです
void myprint(char * msg ,int len);
int choose(int a,int b)
{
if (a>=b){
myprint("the 1st one\n",13);}
else {
myprint("the 2nd one\n",13);}
return 0;
}
nasm -f elf64 foo.asm
gcc -c bar.c
gcc -s -o foobar bar.o foo.o
./foobar 、セグメンテーション違反のコアダンプが表示されます
gdb を使用してデバッグしていますが、debuginfo-install が見つからないと表示され、インストールしようとしています。
おそらく問題は 86_64 アーチに関係しているのでしょう...
このリンクを見た後にスタック (NASM) をプッシュすると、セグメンテーション違反が発生しました 。「ポップ」を追加しましたが、機能しません。