将数组的值分配给eax时出现分段错误(AT& T语法)
问题描述:
我只是想将myarray[0]
的值加载到eax
:
I'm just trying to load the value of myarray[0]
to eax
:
.text
.data
# define an array of 3 words
array_words: .word 1, 2, 3
.globl main
main:
# assign array_words[0] to eax
mov $0, %edi
lea array_words(,%edi,4), %eax
但是当我运行此命令时,我会不断出现段错误. 有人可以指出我在这里做错了什么吗?
But when I run this, I keep getting seg fault. Could someone please point out what I did wrong here?
答
标签main
似乎在.data
部分中.
如果系统不允许执行.data
部分中的代码,则应导致分段错误.
It should lead to segmentation fault if the system doesn't allow to execute codes in .data
section.
程序代码应位于.text
部分.