How do the va_arg
\ va_start
\ va_list
\ va_end
macros work under the hood in x64?
The calling convention in i386 passes parameters on the stack, hence the macro just increments some pointer that points to the stack base and forwards it. However, in x64, all parameters are passed by registers.... so what happens there? How does the called function know which registers were used to pass arguments to ensure it doesn't clobber them?
va_list
could hold details of how many arguments were passed in registers, and which one it has got to, but my guess is that variadic parameters are simply passed on the stack in all cases. – Cresting