Is simple assembly code causing a segment error?
.section .data
.section .text
.globl _start
_start:
movl $1, %eax # this is the linux kernel command
# number (system call) for exiting
# a program
movl $4, %ebx # this is the status number we will
# return to the operating system.
# Change this around and it will
# return different things to
# echo $?
int $0x80 # this wakes up the kernel to run
# the exit command
But if I remove the last line of code int 0x80
, then it throws a segment error .
I do not know why? Can someone tell me.
Thank you for your time.
Thanks everyone. Now I am getting the answer.
Without a line of code int $0x80
, the system does not know if this application ended or when this application ended. ... It will crash.
source to share
If you delete int 0x80
, you will have a segmentation fault because it will start executing any random bytes in RAM right after your program. You really can't predict what will happen and something might happen, but a segfault will likely happen because the random data will most likely act as memory access outside of your process memory.
source to share