AMD has an ABI specification that describes the calling convention to use on x86-64. All OSes follow it, except for Windows which has it's own x86-64 calling convention. Why?
Does anyone know the technical, historical, or political reasons for this difference, or is it purely a matter of NIHsyndrome?
I understand that different OSes may have different needs for higher level things, but that doesn't explain why for example the register parameter passing order on Windows is rcx - rdx …
我已经阅读了微软的文档,但是这个方案太尴尬了,我想我会仔细检查以确保我正确理解它...
我的理解是通过参数传递的通用方法是这样的:
--- bottom of stack ---
(return address)
[shadow space for arg 1]
[shadow space for arg 2]
[shadow space for arg 3]
[shadow space for arg 4]
arg N
arg N - 1
arg N - 2
...
arg 6
arg 5
---- top of stack -----
Run Code Online (Sandbox Code Playgroud)
实施时似乎很尴尬va_arg......这实际上是否正确?