【发布时间】:2015-05-26 10:41:47
【问题描述】:
.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
但如果我删除最后一行代码 int 0x80 ,那么它会导致段错误。
我不知道为什么?谁能告诉我。
感谢您的宝贵时间。
谢谢大家。现在我得到了答案。
没有int $0x80这行代码,系统不知道这个应用程序是否已经结束或者这个应用程序什么时候结束。所以会导致崩溃。
【问题讨论】:
-
如果你没有正确退出你的程序回到操作系统(你用
eax = 1离开int 0x80)你认为程序结束时会去哪里? -
谢谢,我知道为什么了。
-
嘿,simowce,你会发布“为什么”吗?该答案将对任何未来遇到相同问题的开发人员有所帮助。