Stack in Memory and Registers
Explore how the stack operates in memory and registers on ARM64 Linux platforms. Understand the function call mechanism, register roles like pc, sp, lr, and the use of branch instructions. Learn to analyze call stacks and stack overflow causes using GDB.
We'll cover the following...
We'll cover the following...
Register review
So far, we have seen and used general-purpose CPU registers:
x0/w0x1/w1x2/w2x3/w3x4/w4- …
x30/w30
We also have special purpose registers:
XZR/WZR(the zero register)pc(the instruction pointer)sp(the stack pointer)
Application memory simplified
When an executable file is loaded into memory, we observe the following:
- Its header and sections are mapped to memory pages.
- Some data and code are copied unmodified, but some data is initialized and expanded.
- The first stack is also created at this stage.
- A
pcregister is set to point to the first program instruction, andsppoints to the top of the stack.
This simplified process is shown in the figure below:
...