Search code examples
x86-64abi

Order that arguments are pushed on stack on x64


In what order are x64 arguments pushed on to the stack:

  • in the System V ABI?
  • in the Windows ABI?

I am writing a Java FFI library that uses dynamically generated stubs and these stubs depend on this order.

I suspect that it is "floats first" but am not sure.


Solution

  • From System V ABI, Section 3.2.3:

    Once registers are assigned, the arguments passed in memory are pushed on the stack in reversed (right-to-left) order.

    Windows x64 ABI is very informal and it is doesn't specify the order of the stack parameters.
    However from Wikipedia and common sense we can reach the same conclusion as above:

    Additional arguments are pushed onto the stack (right to left)