gpt4 book ai didi

linux - 为什么系统调用会破坏 rcx 和 r11?

转载 作者:太空狗 更新时间:2023-10-29 11:06:55 26 4
gpt4 key购买 nike

<分区>

在书中Low-Level Programming: C, Assembly, and Program Execution on Intel® 64 Architecture它说,

On system call arguments The arguments for system calls are stored in a different set of registers than those for functions. The fourth argument is stored in r10 , while a function accepts the fourth argument in rcx!

The reason is that syscall instruction implicitly uses rcx. System calls cannot accept more than six arguments.

你可以看到这个Stack Overflow post里面也提到了这个,

A system-call is done via the syscall instruction. This clobbers %rcx and %r11, as well as %rax, but other registers are preserved.

我理解破坏 rax 来存储返回码,但为什么 rcxr11syscall 中被破坏>?是否有破坏 rcx/r11 的特定系统调用的列表?有破坏的约定吗?它们在任何系统调用中都被认为是安全的吗?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com