Lion Cipher Lab

Read a stack frame in gdb: prove the x86-64 calling convention from registers and memory

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

Steps in this lab

  1. The vocabulary, in plain words
  2. Write and build the program
  3. Stop on the very first instruction and prove the arguments
  4. Watch the prologue build the frame, one instruction at a time
  5. Read the frame: saved rbp, return address, bt and info frame
  6. Find the locals, then finish the function and catch the return value
  7. Read the epilogue and a call in the disassembly
  8. When NOT to trust this picture, and how a pro does it better

Open the full interactive lab →

Keep learning