I'm developing bare metal for a Raspberry Pi using Rust. It has been quite successful in Aarch32. However, I've started adjusting my code to also work with Aarch64 compilation target.
As Aarch64 compile target has a strict requirement on a stack pointer to be 16 Byte aligned I encountered an issue where the compiled code does not comply to this rule.
The disassembly of the corresponding parts look like this:
80170: f81e0ffc str x28, [sp, #-32]!
80174: a9017bf3 stp x19, x30, [sp, #16]
80178: d108c3ff sub sp, sp, #0x230
[..... some other code where the stack pointer is still aligned]
801e4: 910023e8 add x8, sp, #0x8
801e8: 94000114 bl 80638 <_ZN12ruspiro_uart5uart15Uart13new17hdc68614e1535f836E>
80638: 6f00e400 movi v0.2d, #0x0
8063c: 3904011f strb wzr, [x8, #256]
80640: ad070100 stp q0, q0, [x8, #224] // <-- due to the add x8, sp, #8 the stack pointer is unaligned here !
Is there any way to force Rust to use proper stack alignment when compiling/optimizing the code ?
Any hint would be much appreciated.
I'm using a nightly rust with target aarch64-unknown-linux-gnu and the gcc cross compile toolchain aarch64-elf from ARM hosted on a Windows machine.