Quiz Entry - updated: 2026.07.06
How do you read the stack layout after sscanf or read_six_numbers?
The lea offset(%rsp) instructions before the call map each parsed value to a stack slot; read those slots afterward with x/ at the same offsets.
* lea offsets map parsed values to rsp slots; read them back with x/. *
Example setup:
lea 0xc(%rsp), %rdx
lea 0x7(%rsp), %rcx
lea 0x8(%rsp), %r8
Stack map:
rsp+0x07: 1 byte (char, from %rcx)
rsp+0x08: 4 bytes (int, from %r8)
rsp+0x0c: 4 bytes (int, from %rdx)
Reading in GDB:
# Read 6 integers at rsp
(gdb) x/6wd $rsp
# Read single char at rsp+7
(gdb) x/c $rsp+7
# Read int at specific offset
(gdb) x/d $rsp+0xc
Tip: The order of lea instructions does NOT match the order of values in the format string. Map each lea to its corresponding %d/%c in the format string by register (rdx=3rd arg, rcx=4th, r8=5th, r9=6th).
Go deeper: