Unaligned memory access instructions are generated on thumbv7em-none-eabi target #137663
Labels
C-bug
Category: This is a bug.
O-Arm
Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In some cases, unaligned memory access instructions are generated for the thumbv7em-none-eabi
embedded target. This crashes the program with a hard-fault error interrupt on thumbv7em MCU
variants like the XMC4800 that do not support unaligned memory access. Whether an thumbv7em MCU
supports unaligned memory access is indicated by by the
UNALIGN_TRP
bit in theCCR
register,see ARMv7 ARM.
This issue can be worked around by setting the rustflag
target-feature=+strict-align
though.cargo/config.toml
but at the same time, this causes the following warning:The following code snippet can trigger this issue in the derived
Default
implementation:From this code, the following invalid unaligned store-word instruction is generated:
The full minimal example together with the generated assembly code can be found at:
https://github.com/maximilian-maisel-bl/rust-thumbv7em-align-bug
A possible fix could be setting the strict align flag in the
thumbv7em-none-eabi
target spec filesimilar to the changes made by #58060 for
aarch64-unknown-none
.This bug might be related to #82945
Used rust version:
rustc 1.87.0-nightly (617aad8c2 2025-02-24)
The text was updated successfully, but these errors were encountered: