zephyriot / zephyr-issues

0 stars 0 forks source link

Stack alignment on ARM doesn't always follow Procedure Call Standard #547

Open nashif opened 8 years ago

nashif commented 8 years ago

Reported by Jon Medhurst:

The ARM Procedure Call Standard [1] specifies that the stack be aligned to a multiple of 8 bytes at any 'public interface' (function call boundaries essentially). GCC understands that requirement however various assembler functions (e.g. _isr_wrapper) push an odd number of words (4-byte values) onto the stack before calling other functions, violating the standard.

This issue could cause bugs with use of va_arg with 64-bit values, with future implementation of floating point support (having 64 bit floats) and possibly other situations.

Also, exception entry points (e.g. interrupts) need to align the stack correctly on entry as they may occur at times where stacks aren't suitably aligned (i.e.. SP%8 may be 4 not 0). Note: Cortex-M CPUs provides an (optionally supported) means of automatically aligning stacks when exceptions occur, the STKALIGN flag in the Configuration and Control Register.

[1] http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf

(Imported from Jira ZEP-580)

nashif commented 7 years ago

by Mark Linkmeyer:

Fixing incorrect priority