【发布时间】:2023-03-29 02:38:01
【问题描述】:
前几天我决定尝试组装,我一直在玩一些非常基本的东西,比如从 argv 打印到 stdout。我发现this great list of linux syscall numbers 带有参数和所有内容,我很好奇为什么r10 用于r8 和r9 之前的参数。我发现了各种奇怪的约定,关于什么可以用什么,什么时候用,比如循环计数器在rcx 中的使用方式。 r10 上移有什么特别的原因吗?是不是更方便?
我可能还应该提到我对此感兴趣是出于好奇,而不是因为它给我带来了问题。
编辑:我发现 this question 很接近,在第 124 页引用 the x64 ABI documentation,它注意到用户级应用程序使用 rdi, rsi, rdx, rcx, r8, r9。另一方面,内核使用r10 而不是rcx,并销毁rcx 和r11。这或许可以解释 r10 是如何结束的,但为什么它被换了?
【问题讨论】:
-
因为Why do x86-64 Linux system calls modify RCX, and what does the value mean?。只需将 RCX 替换为 R10 就可以使用单个
mov r10,rcx;syscall在 libc 包装函数中。 Why Assembly x86_64 syscall parameters are not in alphabetical order like i386
标签: linux assembly x86-64 system-calls calling-convention