Specifications
Further Examples of Stacks
There are a number of special cases for stack layout, which are described in this section.
Stack Frame for a Function With alloca()
The Nios II stack frame implementation provides support for the alloca() function, defined in the
Berkeley Software Distribution (BSD) extension to C, and implemented by the gcc compiler. The space
allocated by alloca() replaces the outgoing arguments and the outgoing arguments get new space
allocated at the bottom of the frame.
Note: The Nios II C/C++ compiler maintains a frame pointer for any function that calls alloca(), even
if -fomit-frame-pointer is spec if ed
Figure 7-2: Stack Frame after Calling alloca()
higher addresses
lower addresses
space for
outgoing
stack
arguments
sp
sp
space for
outgoing
stack
arguments
memory
allocated
by
alloca()
)(acolla gnillac retfAerofeB
Stack Frame for a Function with Variable Arguments
Functions that take variable arguments (varargs) still have their first 16 bytes of arguments arriving in
registers r4 through r7, just like other functions.
In order for varargs to work, functions that take variable arguments allocate 16 extra bytes of storage on
the stack. They copy to the stack the first 16 bytes of their arguments from registers r4 through r7 as
shown below.
NII51016
2015.04.02
Further Examples of Stacks
7-5
Application Binary Interface
Altera Corporation
Send Feedback