-1
這段代碼在終端使用GCC彙編罰款:什麼是「分段故障:11」? (MAC OS X GCC彙編運行時錯誤)
.globl _sub
_sub:
push %rbp
mov %rbp,%rsp
mov $0xBEEF,%eax
pop %rbp
ret
.globl _main
_main:
push %rbp
mov %rbp,%rsp
call _sub
mov $0,%eax
pop %rbp
ret
但是當我運行a.out文件,我得到這個錯誤:
Segmentation fault: 11
如果我在GDB運行它,這是錯誤我得到:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000001
0x0000000000000001 in ??()
任何想法,爲什麼這可能發生?