简体   繁体   English

错误:在 android ndk 中构建 libunwind 时需要注册

[英]Error: lo register required when build libunwind in android ndk

I want to build libunwind from Android source at eclipse using ndk r10d.我想在 Eclipse 中使用 ndk r10d 从 Android 源代码构建 libunwind。 But I fail at compiling "Gresume.c" , and it fail at the asm code .但是我在编译 "Gresume.c" 时失败了,它在 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 [armeabi] 编译拇指:MyBacktrace <= Gresume.c /var/folders/g7/9gd3cwy96z12qt3vlf7sc5q80000gn/T//cc6jsBSj.s:汇编程序消息:/var/folders/g7/9gd3cwy96js0fj0s0cc:/var/folders/g7/9gd3cwy96z12qt3vlf7sc5q80000gn/T//cc6jsBSj.s : 需要注册 -- `ldmia r2,{r4-r12,lr}' make: *** [obj/local/armeabi/objs/MyBacktrace/libunwind/src/arm/Gresume.o] 错误 1

the full code can found at the link bellow.完整代码可以在下面的链接中找到。

It seems you're building Thumb code, so I'd guess you're seeing this because you're targeting the wrong architecture version.您似乎正在构建 Thumb 代码,所以我猜您看到这一点是因为您针对的是错误的架构版本。 Traditionally most Thumb instructions can only use the "low registers" r0-r7 - a Thumb version of ldmia capable of moving "high registers" (ie r8-r12, r14 here) didn't exist until ARMv7 * .传统上,大多数 Thumb 指令只能使用“低寄存器” r0-r7 - 能够移动“高寄存器”(即r8-r12, r14此处)的ldmia的 Thumb 版本直到 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.据我所知,Android 的最低公分母仍然是 ARMv5,所以如果你默认针对它,那么汇编器将拒绝在该指令集版本中不可能的事情。

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.将您的构建设置更改为目标 ARMv7,或者只是构建为 ARM 代码而不是 Thumb,应该将相关选项传递给汇编程序,以便它可以为该指令找到合适的编码。

* Technically ARMv6T2, but I'm pretty sure ARM1156 isn't relevant in an Android context. * 技术上是 ARMv6T2,但我很确定 ARM1156 与 Android 上下文无关。

Short solution fromhere , put your code in a distinct .s file with this at the beginning :这里开始的简短解决方案,将您的代码放在一个不同的 .s 文件中,开头是:

.thumb
.syntax unified

But I still don't get why it works...但我仍然不明白为什么它有效......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM