0
Aarch64 - cbz command HELP!!!
lately, i have been trying to learn aarch64 by using gdb on c executable, but i'm stuck on this one command 'cbz'. According to the documentation, it's supposed to jump to the address if value of register is 0 but in the program value of the register is not 0 in either conditions, i can't understand how this one works.
3 Respuestas
+ 5
Well, you need to get the register to 0 (or check a register that you expect to be 0) if you want the instruction to fire. Just a sanity check (looking for typos and checking your jump/branch range is within the allowed distance):
0x650 - 0x648 = 0x8
offset +144 to offset +152 is 8
... so that's fine
CBZ itself, for arm (AArch64 article below):
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjaghefc.html
Where it reads: "Except that it does not change the condition code flags..." this means that CBZ "compares and branches on zero" in-place, without setting any sort of flag for the result of the last comparison.
Assembly language often splits compare-and-act into two instructions: "present two values" and "now jump (branch) if they are related in some way" while CBZ does it in one, without corrupting the answer of another comparison that you may wish to keep.
This thread lists some tools that may help you:
https://stackoverflow.com/questions/9279451/armv7-word-patch-cbnz
And here's an AARCH64 article on the concept + instruction:
http://thinkingeek.com/2017/11/05/exploring-aarch64-assembler-chapter-9/
0
gdb disassembly of the command
0x0000000000000648 <+144>: cbz w0, 0x650 <main+152>
0
Kirk Schafer so how does it check if w0 is equal to zero??
edit: never mind. it was a stupid mistake that i made with breakpoints
Thanks for your help