Quiz Entry - updated: 2026.07.06
How does endianness affect what you see in GDB memory dumps?
x86 is little-endian — the least significant byte sits at the lowest address — but x/ with a word/giant size reassembles the value for you; only raw x/xb byte dumps show the reversed order.
* Little-endian: LSB at lowest address; x/xw reassembles, x/xb shows raw bytes. *
Example: The integer 0x04030201 in memory:
Address: 0x00 0x01 0x02 0x03
Content: 0x01 0x02 0x03 0x04 (LSB first)
GDB handles it for you:
# Shows "correctly" as 0x04030201
(gdb) x/xw 0x7fffffffe000
0x04030201
# Shows raw bytes (reversed from how you'd write the number)
(gdb) x/4xb 0x7fffffffe000
0x01 0x02 0x03 0x04
When it matters:
- Examining strings: No effect (strings are byte sequences, order preserved)
- Examining integers:
x/xwshows the "correct" value;x/xbshows raw byte order - Examining addresses: Use
x/aorx/xg— GDB handles endianness
Forensic trap: If you dump memory as raw bytes and try to read addresses manually, remember to reverse each group of 8 bytes.
Go deeper: