Summary
- The stack is LIFO, grows toward lower addresses;
RSPis the top,RBPthe frame base. push/popmoveRSPby 8;callpushes a return address,retpops it.- A frame holds the return address, saved RBP, saved registers, and locals.
- Prologue:
push rbp; mov rbp, rsp; sub rsp, N. Epilogue:leave; ret. - SysV: 6 args in registers; Windows x64: 4 args plus shadow space.
- Overwriting the saved return address is the root of stack overflows (CSC 472).
Key Takeaway
Frames are the grammar of compiled code. Read them fluently and reverse engineering becomes reading.