I recently read that software breakpoints for Linux on ARM are implemented using UND
instruction in ARM mode and the BKPT
instruction in Thumb mode. Why are there 2 separate instructions used to raise software interrupts?
0
votes
1 Answers
0
votes
Thumb compatible code:
0000e150 <pthread_mutexattr_setpshared>:
e150: b573 push {r0, r1, r4, r5, r6, lr}
e152: 4605 mov r5, r0
e154: 460c mov r4, r1
e156: 4616 mov r6, r2
e158: f7fd fa70 bl b63c <pthread_mutexattr-0xba>
e15c: 4629 mov r1, r5
Pure arm:
0000d564 <pthread_mutex_init>:
d564: e2503000 subs r3, r0, #0
d568: 03a00016 moveq r0, #22
d56c: 012fff1e bxeq lr
arm bkpt 0xe7f001f0
thumb bkpt 0xde01
If try to use always arm bkpt and rewrite first instruction in function: pthread_mutex_init all will be fine but if rewrite first instruction in pthread_mutexattr_setpshared second instruction will be rewrote too.
If always try to use thumb bkpt and rewrite first instruction in pthread_mutex_init resulted instruction will be invalid.
bkpt
instruction starting armv5? Edit: never mind, if it's Linux, it probably needs to support all ARM versions. – tangrs