I'm having a hard time making sense of the Apple ARM64 Function Calling Conventions doc and ARM Procedure Call Standard.
When a function is called, I understand that $r0
is self
, and $r2
appears to be the first function argument.
What is in $x1
?
Does the stack pointer refer to the first argument beyond four?
You want to read the "The Base Procedure Call Standard" chapter of the AAPCS64, section 'Subroutine Calls'; their register naming convention uses "r0..r30" where lldb uses "x0..x30". x1
is the second argument register. x0
is the first. The arm64 iOS ABI's biggest difference from AAPCS64 is in how variadic functions (printf
etc) are called. The apple doc you linked to details the exact difference.
lldb provides register alias names for armv7/arm64/x86_64, $argi, to refer to the ith argument. $arg1
, $arg2
, etc. (Arguments are passed on the stack on i386 so the aliases aren't defined there) I'd recommend using these convenience names and not worrying about the details of the architecture, if possible.
NB these argument passing register contents are only valid at the start of the function. They're usually saved on the stack or copied into other registers -- the registers will be reused/overwritten as soon as another function call is made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With