如何解析ARM64组件Sigbus错误?
我写了一个非常简单的ARM64汇编功能:
这样:
.global asmQuickSort \
asmQuickSort: \
1 sub x2, x1, #1 \
2 mov x1, #0 \
3 sub sp, sp, #8 \
4 str w1, [sp] \
5 add sp, sp, #8 \
6 ret
和主要CPP称呼它:
int main(int argc ,char** argv){ \
int a[7] = {5,4,3,4,3,2,1}; \
asmQuickSort(a,7); \
for(int i=0;i< 7;i++){ \
printf("%d\n",a[i]); \
} \
return 1;\
}
但是,当我将其放入Aarch64板并运行时,它会满足
第4行W1处的Sigbus错误,[SP]
此可执行文件使用QEMU-AARCH64运行良好,但在臂板中,它收到了Sigbus。
那么,为什么该应用会收到Sigbus错误?
我应该检查什么?
I wrote a very simple ARM64 assembler function:
Like this:
.global asmQuickSort \
asmQuickSort: \
1 sub x2, x1, #1 \
2 mov x1, #0 \
3 sub sp, sp, #8 \
4 str w1, [sp] \
5 add sp, sp, #8 \
6 ret
and main cpp to call it:
int main(int argc ,char** argv){ \
int a[7] = {5,4,3,4,3,2,1}; \
asmQuickSort(a,7); \
for(int i=0;i< 7;i++){ \
printf("%d\n",a[i]); \
} \
return 1;\
}
But, when I put it into aarch64 board and run it ,it met
sigbus error at line 4 str w1, [sp]
This executable file ran well using qemu-aarch64 ,but in arm board it received sigbus.
So, why does the app receive sigbus error?
And what should I to check?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是堆栈对齐。
手册在“ load/load/store store asseling modes”(c1.3.3333333333333333333333333333333) ):
听起来像是在操作系统上启用了堆栈对齐检查,并且您通过向其添加8个堆栈指针将堆栈指针错过。因此,将该价值更改为16,您应该很好。
我假设您知道这一点,但是以防万一:您当前的堆栈用法
asmquicksort
无论如何都没有目的。It's probably stack alignment.
The manual has this to say on "Load/store addressing modes" (C1.3.3):
It sounds like stack alignment checking is enabled on your OS, and you misalign the stack pointer by adding 8 to it. So change that value to 16 and you should be good.
And I'm assuming you're aware of this, but just in case: your current stack usage inside
asmQuickSort
serves no purpose anyway.