为什么不跟随的Linux系统调用的Unix约定? [英] Why doesn't Linux follow Unix syscall conventions?

查看:231
本文介绍了为什么不跟随的Linux系统调用的Unix约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我教自己的Linux汇编语言和我已经遇到BSD和Linux之间的一个有趣的差异。在Unix中,你调用一个80H中断之前把你的系统调用的参数压入堆栈;相比之下,在Linux中,你通过参数在寄存器中。

I'm teaching myself Linux assembly language and I've come across an interesting difference between BSD and Linux. In Unix, you push your syscall parameters onto the stack before calling an 80h interrupt; by contrast, in Linux, you pass your parameters in registers.

有谁知道用寄存器,而不是堆栈走什么理由是为Linux开发人员?

Does anyone know what the rationale was for the Linux developers to go with registers instead of the stack?

请注意:这是一个很好的页面,详细说明这种差异:的 FreeBSD的开发者手册:系统调用没有解释的理由。

Note: Here's a good page detailing this difference: FreeBSD Developer's Handbook:System Calls without explaining the rationale.

推荐答案

该系统调用约定是不同的,因为标准功能调用顺序是不同的。林假设你正在谈论的x86-32调用约定和AMD64调用约定之间的差异。您可以检查出的AMD64 ABI 这里

The syscall convention is different because the standard function calling sequence is different. Im assuming you're talking about the difference between the x86-32 calling convention and the AMD64 calling convention. You can check out the AMD64 ABI here.

但是,如果你想获得点快速检查的这个职位。基本上,它是关于速度。通过改变调用约定,并使用寄存器而不是堆栈,你可以在序幕和呼叫的尾声剃了说明。

But if you want to get to the point quickly check this post. Basically it's about speed. By changing the calling convention and using registers instead of the stack you can shave off instructions in the prologue and the epilogue of a call.

这篇关于为什么不跟随的Linux系统调用的Unix约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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