I have a library written in C mixed mixed with some assembly for ARM. It used to be compiled for armv6. Now I am trying to upgrade it to armv7. However, there is an interrupt handler which has the instruction stmdb sp!, {pc} which is not allowed in armv7. What would be an equivalent instruction on armv7? I tried str r15, [sp, #-4]! but that doesn’t work.
I have a library written in C mixed mixed with some assembly for ARM.
Share
There’s specific limitations regarding the use of
PCin the reg list forPUSHandPOPinstructions, depending on the operation mode, see:ARM Instruction Set Reference,
PUSH/POPSpecifically, in Thumb[2] there is no
push {pc}operation (which is the same as saying there’s nostmfd sp!, {pc}operation –pushis mapped tostmfd sp!).So if you’re compiling your kernel code (why else do you have/need an interrupt handler if it’s not kernel code), check whether you’re compiling a Thumb-2 kernel.
That said, you’re saying you encountered a
stmfd sp!,{pc}instruction – you’re sure that’s not a typo ?stmfd sp!,{lr}(and its sibling,ldmfd sp!, {pc}– herePCis present) is normal / fully legal and often required / encountered in both ARM mode and Thumb-2 mode. But that actually is the purpose of saving the program counter to the stack ? What can one do with that that wouldn’t be achievable in other ways ?