x86_64 Assembler

| No Comments

I’m OK at deciphering PowerPC assembler and i386 assembler but now it’s all x86_64. If you’re having a look at the internals of AppKit in x86_64, you need to print out page 21 of this: http://www.x86-64.org/documentation/abi.pdf and stick it on your wall next to your C operator precedence table.

Now wherever you see objc_msgSend (or something similar), the selector gets passed in $rsi. To find out what it is, type:

p (char *)sel_getName($rsi)

x86_64 comes with instruction pointer relative addressing so you might notice that gdb helpfully displays what the target address is wherever it’s used. So if you’re looking at some assembler that looks like this:

0x00007fff811f33fc <-[NSTableView reloadData]+115>: mov -0x10f16b8b(%rip),%rsi # 0x7fff702dc878
0x00007fff811f3403 <-[NSTableView reloadData]+122>: mov %rbx,%rdi
0x00007fff811f3406 <-[NSTableView reloadData]+125>: callq 0x7fff8184278e <dyld_stub_objc_msgSend>

You can figure out what the call is by typing:

p (char *)sel_getName(*(void **)0x7fff702dc878)

And you’ll see something like:

$2 = 0x7fff8187bb68 "_endMyEditing"

Leave a comment