0

In Android shared library that heavily protected against debugging, I found following code:

CODE32
ldr pc, [pc, #-4]

For me, this instruction looks like NOP; it just jumps to next instruction in ARM mode. The debugged process crashes on this command, however. I use IDA to debug the process.

Can anyone explain why?

1

This instruction is not a NOP. It reads memory and jumps to the address loaded. If the memory is inaccessible or the loaded address is invalid/non-executable, you will get an exception, so the debugger's behavior is correct.

a NOP-like instruction involving PC in ARM mode would be something like

ADD PC, PC, #-4

(likely disassembled as sub pc, pc, #4 or maybe even ADR PC, next_addr )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.