Calling convention for Linux on x86_64 (amd64) is as follows:

  • Arguments 1-6 are passed via registers rdi, rsi, rdx, rcx, r8, r9 respectively. An argument smaller than 8 bytes are widened to 8 bytes when passed via registers. This does not account for non-integer or non-pointer arguments like floating point/vector/large structs, which are passed via other means (e.g., SSE registers or memory).
  • Arguments 7 and beyond are pushed onto the stack like cdecl.

The ABI also requires rsp to be 16-byte aligned prior to a call (after loading the arguments). This means that the value in rsp should end in a zero hex digit.

For more information on this topic, refer to the System V ABI, section 3.2.3, available in Sources. The ABI provides detailed instructions on how each category of arguments are passed to the callee. Note that the Linux kernel uses a slightly different calling convention, available in section A.2.1.