Here is the function:
Code: Select all
.section .data
.section .text
.globl _start
_start:
# Push
push $1
# Function call
call pfun
movq $60, %rax
syscall
.type pfun, @function
pfun:
# Push
push $2
# Return
ret
Program received signal SIGSEGV, Segmentation fault. 0x0000000000000002 in ?? ()
Now, if you add a "pop" after the function push and run it then it will build and run successfully. BUT if you debug it you will see that it never gets inside the function using the "n"(next) command.
I've searched for an answer but didn't found anything similar at all for ASM. Recently started learning ASM and for me it looks perfectly nice so don't really know why it could be happening.
Any help here is appreciated. Thank you.