gpt4 book ai didi

linux-kernel - 系统调用使用寄存器或堆栈将参数传递给内核?

转载 作者:行者123 更新时间:2023-12-05 00:24:57 25 4
gpt4 key购买 nike

我对系统调用感到困惑。在 X86 中,系统调用使用 eax 将系统调用号传递给内核。

但是它用什么将参数传递给内核,在某些地方我看到它使用堆栈,而在少数地方它说它使用 EBX、ECX 等寄存器。

那么有人可以确认哪个是正确的吗?

前引用:
link说它使用堆栈。

还有这个 link说它使用寄存器。

最佳答案

两个链接都告诉我们参数从用户空间通过 EBX、ECX 等寄存器传递到内核空间。

在第一个引用页面: 35/352 , 系统调用实现/包装器任务 第 1 点,给出的是

the parameters available in the user stack are moved to the processor registers and then this registers are used to pass parameters of the syscall to the kernel space.



我认为在第一篇引用文献的系统调用实现页面上看到堆栈一词后,您一定感到困惑。

关于linux-kernel - 系统调用使用寄存器或堆栈将参数传递给内核?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25440319/

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