In the ARM64 iPhone call log, what's in the $ x1 register?

I'm having a hard time understanding Apple 's ARM64 doc Function Naming Conventions and the ARM Procedure Call Standard .

When the function is called, I understand what it $r0

is self

, and $r2

is represented by the first argument of the function.

What's in $x1

?

Does the stack pointer point to the first argument above four?

+3


source to share


2 answers


You want to read the Standard Standard Procedure chapter in the AAPCS64 section, Call Routines section; their register naming convention is "r0..r30", where lldb uses "x0..x30". x1

- the second register of arguments. x0

is the first. The biggest difference between the arm64 iOS ABI and the AAPCS64 is how variable 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 i-th argument. $arg1

, $arg2

etc. (The arguments are passed on the stack to i386, so no aliases are defined there). I would recommend using these convenient names and not worrying about architecture details if possible.



NB these arguments passing the contents of the register are only valid at the beginning of the function. They are usually saved on the stack or copied to other registers - the registers will be reused / overwritten as soon as another function call is made.

+7


source


According to Mike Ash's blog post here , write a method like this:

- (int)foo:(NSString *)str { ...

      

Receives translation to a function like this:



int SomeClass_method_foo_(SomeClass *self, SEL _cmd, NSString *str) { ...

      

Thus, the argument in $x1

is a pointer to the selector, which is basically a string containing the name of the method.

0


source







All Articles