问题描述
我在几个地方看到微软对 x64
平台的调用约定被缩小到只有一个:调用者清理堆栈(cdecl
),并且参数以组合方式传递堆栈和寄存器(我不会在这里详细介绍).我假设如果这是操作系统的调用约定,那么可能所有其他针对 Windows 的编译器(例如 mingw-w64)也遵循它.
I saw in several places that Microsoft calling conventions for x64
platforms were narrowed down to just one: Caller cleans stack (cdecl
), and parameters are passed in a combination of stack and registers (I am not going into the exact details here). I assume that if this is the calling convention of the OS, then probably all other compilers targeting Windows (e.g. mingw-w64) follow it, too.
此调用约定在其他主要平台(x64
Linux 等)上是否也适用?或者 Linux 是否仍然使用多种调用约定,甚至只是一种但不同的调用约定?GCC
或 Clang
是否允许 x64
Linux 上的多个调用约定?
Is this calling convention true also on other major platforms (x64
Linux, etc.)? Or does Linux still use multiple calling conventions, or even just one but a different one? Do GCC
or Clang
allow for multiple calling conventions on x64
Linux?
推荐答案
我刚刚找到答案 此处和此处.基本上,Windows 以一种方式做,其他人以另一种方式做,但每个平台只以一种方式做(而不是每个平台以多种方式使用 x86
)
I just found the answer here and here. Basically, Windows does it one way, everyone else does it another way, but each platform only does it one way (as opposed to multiple ways per-platform with x86
)
这篇关于x64 上的调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!