i just started to learn intel att assembly and met the next problem: i got segfault when i tried to use access to stack. i did access indirectly to memory location, but when i tried to do so with stack i got segfalt. my system is :
Linux cat 4.19.36 #1-NixOS SMP Sat Apr 20 07:16:05 UTC 2019 x86_64 GNU/Linux
i use gas comiler:
as -gfstab -o a.o a.s
ld -o a.out a.o
this is example of my tiny code:
.code64
.globl _start
.text
_start:
movl (%esp) , %eax
xor %eax , %eax
inc %eax
int $0x80
the program compiled and linked but when i tried to start it i got:
as -gfstab -o a.o a.s
ld -o a.out a.o
./a.out
make: *** [makefile:4: new] Segmentation fault
i used gdb to solve the problem. indirect access to stack gave me the next result:
6 movl (%esp) , %eax
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
_start () at a.s:6
6 movl (%esp) , %eax
i took this example from internet and they said that this is the way to do things. what i am doing wrong? TNX