segmentation fault when assigning value of an array to eax (AT&T syntax)
问题 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? 回答1: It seems the label main is in the .data section. It should lead to segmentation fault if the system doesn't allow to execute codes in .data section. Program code should be