Re: [問題] 發生 Segmentation fault

看板ASM (組合語言)作者 (「雄辯是銀,沉默是金」)時間10年前 (2015/04/10 09:39), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
.section .data a: .long 10 b: .long 20 .section .text .globl main .type main,@function #別忘了這句,因為main彙編函數也是被crt0.s調用的, main本質上也是個函數 main: mov $a, %esi mov $b, %edi call swapint #不要寫成 _swapint movl $1,%eax movl $0,%ebx int $0x80 [descent@asm]$ gcc -o m m.s f.c [descent@asm]$ ./m success!! end! output?? [descent@asm]$ file m m: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xe20028448ed677fa683eef8db006b324c4421c6e, not stripped x64 使用 register 和 stack 來傳遞變數。 ※ 引述《yshihyu (yshihyu)》之銘言: : http://blog.csdn.net/mirage1993/article/details/39759003 : 我想測試Linux彙編GAS調用C語言函數實例照上面網址代碼步驟做 : 在32bit主機可以正常編譯過 , 但是在64bit 會發生Segmentation fault (core dumped) : 我使用 gdb ./a.out core 去看發現是是死在 : Program terminated with signal SIGSEGV, Segmentation fault. : #0 0x00000000004005b6 in swapint (a=0x1, b=0x7fffcc70fb68) at pro.c:6 : 6 c=*a; : 想請問一下發生SIGSEGV原因是什麼? : 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.248.61.61 ※ 文章網址: https://www.ptt.cc/bbs/ASM/M.1428629958.A.96F.html
文章代碼(AID): #1L9od6bl (ASM)
討論串 (同標題文章)
文章代碼(AID): #1L9od6bl (ASM)