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?

4
  • "crashes" how, exactly?
    – Igor Skochinsky
    Commented Sep 3, 2019 at 10:47
  • Raises SIGSEGV.
    – Vitalii
    Commented Sep 3, 2019 at 11:34
  • IDA itself or the process being debugged?
    – Igor Skochinsky
    Commented Sep 3, 2019 at 14:12
  • The debugged process.
    – Vitalii
    Commented Sep 3, 2019 at 14:58

1 Answer 1

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 and acknowledge you have read our privacy policy.

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