Linux的64:为什么R8和R9之前不会R10进来的系统调用? [英] Linux x64: why does r10 come before r8 and r9 in syscalls?

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

问题描述

我决定采取裂缝在装配有一天,我已经被玩弄,例如打印的东西从ARGV到标准输出很基本的东西。我发现的Linux系统调用号这个大名单带参数和一切,我很好奇,为什么 R10 R8 和<$ C用于参数$ C> R9 。我发现各种怪异公约关于什么可以用来做什么和什么时候,像循环计数器 RCX 怎么走。是否有特别的原因 R10 被感动了?是不是更方便?

I decided to take a crack at assembly the other day, and I've been playing around with really basic things like printing stuff from argv to stdout. I found this great list of linux syscall numbers with arguments and everything, and I'm curious why r10 is used for arguments before r8 and r9. I've found all kinds of weird conventions about what can be used what for what and when, like how loop counters go in rcx. Is there a particular reason why r10 was moved up? Was it more convenient?

我应该还提到我很感兴趣,这是出于好奇,不是因为它引起了我的问题。

I should probably also mention I'm interested in this out of curiosity, not because it's causing me problems.

编辑:我发现这个问题它靠拢,引用的 x64的ABI文档页124,它指出,用户级应用程序使用的 偏下,RSI,RDX,RCX ,R8,R9 。而另一方面使用内核 R10 毁坏 RCX RCX ,和C $ C>和 R11 。这或许可以解释如何 R10 结束了在那里,但为什么却在交换?

I found this question which gets close, referencing the x64 ABI documentation on page 124, where it notes that user level applications use rdi, rsi, rdx, rcx, r8, r9. The kernel on the other hand uses r10 instead of rcx, and destroys rcx and r11. That might explain how r10 ended up there, but then why was it swapped in?

推荐答案

RCX ,以及 R11 ,是所使用的系统调用指令,被立即销毁了。因此,这些寄存器不仅没有保存系统调用后,但他们甚至不能被用于参数传递。因此, R10 被选来代替无法使用 RCX 来传递第四个参数。

RCX, along with R11, is used by the syscall instruction, being immediately destroyed by it. Thus these registers are not only not saved after syscall, but they can't even be used for parameter passing. Thus R10 was chosen to replace unusable RCX to pass fourth parameter.

另请参阅这个答案了解了一下关于如何系统调用的更多信息使用这些寄存器。

See also this answer for a bit more information on how syscall uses these registers.

参考:<一href="http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf"相对=nofollow>英特尔指令集参考,寻找 SYSCALL

这篇关于Linux的64:为什么R8和R9之前不会R10进来的系统调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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