|ARM Technical Support Knowledge Articles|
An external interface (or externally visible interface) exists when there is a call to a function which is not defined within the same source file. Imagine a non-leaf function, for example
f5 from diagram in the FAQ: What is a leaf function?. If the functions
f6 are defined in separate C translation units (source files), then there is an external interface between these two functions. The external interface is described in more detail in the ARM Architecture Procedure Call Standard (AAPCS).
The compiler must maintain 8 byte stack alignment when external interfaces are visible. To ensure the stack is 8 byte aligned, the compiler modifies the stack pointer once on entry and exit to a function. For example, on entry and exit to function
f5, the compiler will modify the stack pointer to guarantee that the stack is 8 byte aligned for when
f5 makes a call to either
f7. The compiler can achieve this by pushing an even number of registers onto the stack, or adjusting the stack pointer. The exception to this rule are leaf functions; leaf functions do not need to maintain 8 byte stack alignment. For example, on entry to function
f6 the compiler does not need to maintain 8 byte stack alignment as
f6 does not make any calls.
If you are writing your own assembly code you need to take care of 8 byte stack alignment, if necessary, for example, if you are writing a re-entrant interrupt handler.
Article last edited on: 2011-09-01 19:32:00
Did you find this article helpful? Yes No
How can we improve this article?