Issue
I want to build libunwind from Android source at eclipse using ndk r10d. But I fail at compiling "Gresume.c" , and it fail at the asm code . I can't understand asm code and I searched any place can't found people who has the same problem ,so I hope somebody can help me .
the error line of code is:
asm __volatile__ (
"ldmia %0, {r4-r12, lr}\n"
"mov sp, r12\n"
"bx lr\n"
: : "r" (regs) ,
"m" (*(struct regs_overlay *)regs)
);
the error output:
[armeabi] Compile thumb : MyBacktrace <= Gresume.c /var/folders/g7/9gd3cwy96z12qt3vlf7sc5q80000gn/T//cc6jsBSj.s: Assembler messages: /var/folders/g7/9gd3cwy96z12qt3vlf7sc5q80000gn/T//cc6jsBSj.s:88: Error: lo register required -- `ldmia r2,{r4-r12,lr}' make: *** [obj/local/armeabi/objs/MyBacktrace/libunwind/src/arm/Gresume.o] Error 1
the full code can found at the link bellow.
Solution
It seems you're building Thumb code, so I'd guess you're seeing this because you're targeting the wrong architecture version. Traditionally most Thumb instructions can only use the "low registers" r0-r7
- a Thumb version of ldmia
capable of moving "high registers" (i.e. r8-r12, r14
here) didn't exist until ARMv7*. As far as I'm aware Android's lowest-common-denominator is still ARMv5, so if you are targeting that by default then the assembler is going to refuse things which are impossible in that instruction set version.
Changing your build settings to either target ARMv7, or just to build as ARM code instead of Thumb, should pass the relevant options through to the assembler such that it can find an appropriate encoding for that instruction.
* Technically ARMv6T2, but I'm pretty sure ARM1156 isn't relevant in an Android context.
Answered By - Notlikethat