在 armv8 架构中将半字值存储到堆栈内存中时出现总线错误? [英] BUS Error while storing halfword value into stack memory in armv8 architecture?

查看:31
本文介绍了在 armv8 架构中将半字值存储到堆栈内存中时出现总线错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个寄存器 w1 和 w2,我想将它们存储在堆栈中.我想将完整的单词 w1 和 w2 的一半存储到堆栈中.这是我的实现:

I have two registers w1 and w2 that I want to store on stack. I want to store the complete word w1 and half part of w2 into the stack. Here is my implementation:

STR w1, [sp, #-8]!
STRH w2, [sp, #-8]!

在编译时,第一条指令运行良好,但第二条指令引发总线错误.我知道这是一些对齐问题,但我无法正确理解为什么会发生这种情况?

On compilation the first instruction runs fine but the second instruction throws a bus error. I know this is some alignment issue but I am not able to properly understand why is this happening?

我正在为 ARMv8(64 位)架构编译.

I am compiling for ARMv8(64-bit) architecture.

推荐答案

根据 ARMv8 指令集概述等文档,...添加任何偏移量必须是四字(16 字节)对齐,否则将生成堆栈对齐异常."

According to the ARMv8 Instruction Set Overview, among other documents, "... if SP is used as the base register then the value of the stack pointer prior to adding any offset must be quadword (16 byte) aligned, or else a stack alignment exception will be generated."

我能够复制您的错误.所以SP mod 16必须是0.

I am able to replicate your error. So SP mod 16 must be 0.

Bus error (core dumped)

这篇关于在 armv8 架构中将半字值存储到堆栈内存中时出现总线错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆