Home  >  Q&A  >  body text

asm - 《Linux C一站式编程》:不加 int $0x80 导致段错误

在 《Linux C一站式编程》中有这样一个问题:

.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 这一句去掉,也能够编译链接成功,但是却会导致一个段错误,请问这是为什么?

谢谢大家了~

大家讲道理大家讲道理2716 days ago485

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:14:35

    This is an interrupt. The operating system (this int 80 is under Linux) is fixed. It is recommended to use SYSENTER. Then if there is no SYSENTER or SYSEXIT at the end of a call, of course an error will be reported.

    Go to Google for its function. I won’t be a porter. After all, I haven’t had any contact with it for a long time.

    reply
    0
  • Cancelreply