Inline assembly in Arm z_arch_switch_to_main_thread missing clobber list #16900
Labels
area: ARM
ARM (32-bit) Architecture
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Describe the bug
I have been experimenting with compiling Zephyr with clang on Arm, I couldn't run the resulting binary with ninja run due to the stack getting corrupted and traced the problem back to this bit of inline assembly in ARM z_arch_switch_to_main_thread
Is missing the clobber list, I think at least r0 is needed here. When compiling the HelloWorld program with clang I get from the object:
When compiled with GCC and some versions we happen not to use r0 for _main_stack but in principle this could happen with some future version. I think that at least r0 should be on the clobber list as this can be overwritten before the MSR PSP, r0.
To Reproduce
This is somewhat tricky as to use a clang cross compiler on Arm requires quite a few changes. I think that this should reproduce with the following:
Steps to reproduce the behavior:
Expected behavior
I expect that if the compiler chooses to use r0 for _main_stack it isn't overwritten with MOV r0, %1
Impact
This is just a report of a latent problem in the source, I don't think it will affect anyone using GCC and the default flags right now.
Environment (please complete the following information):
I rebased my patches to support clang on 442df97 committed on Thu Jun 6 06:31:43 2019 -0500 with first line "scripts/dts: Remove alias defines for labels"
The text was updated successfully, but these errors were encountered: