在Linux上,系统调用实际上是如何发生的? [英] How does a syscall actually happen on linux?

查看:94
本文介绍了在Linux上,系统调用实际上是如何发生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

受到这个问题的启发

如何强制GDB进行反汇编?

并与此相关

什么是INT 21h?

在Linux下如何进行实际的系统调用?在执行调用之前,直到实际的内核例程被调用时,会发生什么?

How does an actually system call happen under linux? what happens when the call is performed, until the actual kernel routine is invoked ?

推荐答案

假设我们正在谈论x86:

Assuming we're talking about x86:

  1. 系统调用的ID 为存入EAX寄存器
  2. 系统调用所需的任何参数都存储在系统调用指定的位置.例如,某些系统调用期望其参数驻留在EBX寄存器中.其他人可能希望他们的论点坐在堆栈的顶部.
  3. 调用INT 0x80中断.
  4. Linux内核为EAX寄存器中的ID标识的系统调用提供服务,将所有结果存储在预定位置.
  5. 调用代码会利用所有结果.
  1. The ID of the system call is deposited into the EAX register
  2. Any arguments required by the system call are deposited into the locations dictated by the system call. For example, some system calls expect their argument to reside in the EBX register. Others may expect their argument to be sitting on the top of the stack.
  3. An INT 0x80 interrupt is invoked.
  4. The Linux kernel services the system call identified by the ID in the EAX register, depositing any results in pre-determined locations.
  5. The calling code makes use of any results.

我可能对此有些不满意,已经有好几年了...

I may be a bit rusty at this, it's been a few years...

这篇关于在Linux上,系统调用实际上是如何发生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆