On Wed, Mar 30, 2016 at 6:26 PM, fengwei.yin fengwei.yin@linaro.org wrote:
Thanks a lot for your quick response. The .ii file was attached.
In UnwindFromContext, there is an asm that forces the assembler into ARM mode.
if (ucontext == nullptr) { int ret = (({ unw_tdep_context_t *unw_ctx = (&context_); register unsigned \ long *unw_base asm ("r0") = unw_ctx->regs; __asm__ __volatile__ ( ".align 2\nbx\ pc\nnop\n.code 32\n" "stmia %[base], {r0-r15}\n" "orr %[base], pc, #1\nbx %[ba\ se]" : [base] "+r" (unw_base) : : "memory", "cc"); }), 0);
The ".code 32" puts us in ARM mode.
GCC still thinks that we are in thumb mode though, and continues to emit thumb instructions, some of which have no arm mode equivalent, e.g. cbnz and cbz.
I don't see any convenient push/pop for thumb/arm mode. This is probably a macro expanded into the asm. You could have two versions of the asm, one that gets used when __thumb__ is defined and one that gets used when __thumb__ is not defined. The __thumb__ version would switch back into thumb mode at the end with a ".thumb" pseudo-op.
Or alternatively, don't build with -mthumb.
Jim