A brief analysis of the handling process of ARM data anomaly
Exception vectors and program jumps
Data abort is one of the exceptions defined by the ARM system. When an exception occurs, ARM automatically jumps to the anomaly vector table and jumps to the corresponding exception handling through the jump command in the vector table.
ARM's exception handling vector table in the Entry-armv.s file:
. Globl __vectors_start
__vectors_start:
SWI Sys_error0
b vector_und + Stubs_offset
Ldr pc,. LCVSWI + Stubs_offset
b Vector_pabt + Stubs_offset
b Vector_dabt + Stubs_offset
b VECTOR_ADDREXCPTN + Stubs_offset
b VECTOR_IRQ + Stubs_offset
b Vector_fiq + Stubs_offset
For data abort, the corresponding jump address is Vector_dabt + stubs_offset. The directive definition of this address is also in ENTRY-ARMV. S
Vector_stub Dabt, Abt_mode, 8
. Long __dabt_usr @ 0 (usr_26/usr_32)
. Long __dabt_invalid @ 1 (fiq_26/fiq_32)
. Long __dabt_invalid @ 2 (irq_26/irq_32)
. Long __dabt_svc @ 3 (svc_26/svc_32)
. Long __dabt_invalid @ 4
. Long __dabt_invalid @ 5
. Long __dabt_invalid @ 6
. Long __dabt_invalid @ 7
. long __dabt_invalid @ 8
. Long __dabt_invalid @ 9
. Long __dabt_invalid @ A
. long __dabt_invalid @ b
. long __dabt_invalid @ C
. long __dabt_invalid @ d
. long __dabt_invalid @ E
. long __dabt_invalid @ F
Vector_stub is a macro definition:
. macro vector_stub, name, mode, correction=0
. Align 5
Vector_\name:
. If \correction
Sub LR, LR, #\correction
. endif
@
@ Save R0, lr_<exception> (parent PC) and spsr_<exception>
@ (Parent CPSR)
@
Stmia sp, {r0, LR} @ Save R0, LR
Mrs LR, SPSR @ Save the CPSR to LR registers before jumping
str LR, [sp, #8] @ save SPSR
@
@ Prepare for SVC32 mode. IRQs remain disabled.
@
Mrs R0, CPSR
Eor r0, R0, # (\mode ^ svc_mode)
MSR spsr_cxsf, R0 @ ready to enter SVC mode
@
@ The branch table must immediately follow this code
@
and LR, LR, #0x0f @ Get the mode before the jump (usr, SVR, etc.)
mov r0, SP
Ldr LR, [PC, LR, LSL #2] @ According to the pattern jump to the corresponding data abort instructions, and enter the SVC mode
Movs pc, LR @ branch to handler in SVC mode
Endproc (Vector_\name)
. endm
As you can see from the Red Callout section of your code, for the same exception, you jump to a different branch of instruction, depending on the pattern before entering the exception, www.linuxidc.com these instruction branches immediately after the Vector_stub macro definition. If you are in < before entering data abort