HW22
Are function-local variables (
autoin C) allocated at compile-time or run-time?If some function definition has a local variable
x, will that variable always be assigned a single memory location in any possible program that has such a function?Label which of the following stack frame elements are caller created, and which are callee created, in the x86 64 System V ABI:
- Callee-saved registers
- Local variables
- Old base pointer
- Register parameters
- Return address
- Stack parameters
What register in the x86 64 System V ABI is meant to hold a pointer to the currently-executing function’s stack frame?
What is the greatest number of active stack frames that will exist in memory at one time for the
factorialfunction in the following program?#include <stdio.h> int factorial(int n) { if (n < 2) { return 1; } else { return n * factorial(n - 1); } } int main() { int n = 5; printf("factorial(%d) = %d\n", n, factorial(n)); }