Lion Cipher Lab
Read a stack frame in gdb: prove the x86-64 calling convention from registers and memory
- Cyber / Security Engineer
- Intermediate
- ~60 min
- Free · no account required
Why it matters
When you analyse unknown software, a suspicious sample, or a crash with no source, the source is the one thing you do not have. What you do have is the machine's rules. Every compiler on a given platform agrees on a calling convention: a fixed contract for where a function's inputs arrive, where its answer leaves, and what the caller can rely on afterward. Learn that contract once and you can stand at any function in any program and say what went in and what came out. The same skill is behind reading crash dumps, understanding why a stack overflow overwrites a return address, and every later…
What you'll learn
- naming the registers that carry the first integer arguments and the return value on x86-64 Linux
- recognising a function prologue and epilogue in disassembly
- reading rbp, rsp, the saved rbp and the saved return address from raw memory with x/
- using bt, frame, info frame and finish to walk and check the call stack
- proving an argument value from a register instead of trusting the source
- knowing why optimised code breaks the simple rbp-chain picture
Steps in this lab
- The vocabulary, in plain words
- Write and build the program
- Stop on the very first instruction and prove the arguments
- Watch the prologue build the frame, one instruction at a time
- Read the frame: saved rbp, return address, bt and info frame
- Find the locals, then finish the function and catch the return value
- Read the epilogue and a call in the disassembly
- When NOT to trust this picture, and how a pro does it better
Open the full interactive lab →