Registers hold the handful of values a program is working on right now; everything else lives in memory. A running process sees one long, flat array of bytes, each with its own numeric address. Assembly reaches into that array constantly — loading values to work on, storing results back — so you need a mental map of how it is laid out and how multi-byte values sit inside it.
The operating system hands each process a range of addresses divided into regions, each with a purpose. Drawn in GDB's orientation — lowest address at the top, highest at the bottom:
The stack and heap grow toward each other across the free space between them: the heap climbs into higher addresses as you malloc, and the stack descends into lower addresses as you call functions and allocate locals. This is the map the rest of the courses refer back to — the Binary Exploitation track lives almost entirely in the stack region.
0x400000?0x08048000). The first page at 0x400000 holds the ELF header and program headers, so your .text is aligned up to the next page and the first instruction lands at 0x401000 — which is exactly why every break _start in this course stops there. Everything below 0x400000 is deliberately left unmapped, so dereferencing a NULL (or small) pointer faults instead of silently reading real memory.These addresses are fixed only because we link with ld directly, producing a non-PIE binary. Most distribution binaries are PIE (position-independent) and the loader drops them at a randomized base on every run (ASLR) — a defense the Binary Exploitation course spends real effort defeating.
When a multi-byte value is stored in memory, which byte comes first? x86 is little-endian: the least-significant byte is stored at the lowest address. Store the 32-bit value 0x12345678 and look at the individual bytes versus the whole word:
break _startBreakpoint 1 at 0x401000runBreakpoint 1, 0x0000000000401000 in _start ()si0x0000000000401008 in _start ()p/x $rax$1 = 0x402000x/4xb $rax0x402000: 0x78 0x56 0x34 0x12x/1xw $rax0x402000: 0x12345678si0x000000000040100f in _start ()p/x $rbx$2 = 0x12345678x/4xb reads four bytes starting at the address and shows 0x78 0x56 0x34 0x12 — the value backwards, least-significant byte first. x/1xw reads the same four bytes as a word and shows 0x12345678, the right way round. The bytes really are reversed in memory; the CPU reassembles them when it reads the value. This trips everyone up the first time they stare at a hex dump of an address.
Instructions reach memory through an effective address built from up to four parts, written inside brackets:
[base + index*scale + displacement]rbx)rcx)1, 2, 4, or 8, the size of each elementAny part is optional, which gives you everything from a plain pointer to full array indexing:
1mov rax, [rbx] ; value at the address in rbx
2mov rax, [rbx + 8] ; 8 bytes past it
3mov raxTwo instructions do the bulk of the work, and the difference between them matters:
mov moves data. mov rbx, [val] dereferences — it reads the bytes at that address and copies the value into rbx.lea (load effective address) computes the address itself, without touching memory. lea rax, [val] puts the address of val into rax, not its contents.You can see both in the session above: lea rax, [val] left the address in rax, while mov ebx, [val] pulled the value 0x12345678 into rbx. lea is the assembly equivalent of C's &, and it is also handy for quick arithmetic — lea rax, [rbx + rcx*4] computes rbx + rcx*4 in one instruction without ever reading memory.
The regions above are the coarse view — what the kernel maps when it loads the program. Zoom in and each region is built from named sections that the linker laid down. readelf -S lists them all; here are the ones you will meet most often, grouped by the permissions they end up with:
| Section | What it holds | Perms |
|---|---|---|
.text | machine code — your instructions | r-x |
.plt | stubs that jump into shared-library functions | r-x |
.init / .fini | code that runs before main and after it returns | r-x |
.rodata | read-only constants: string literals, const globals, jump tables | r-- |
.data | initialized writable globals — C's int total = 42; | rw- |
.bss | zero-initialized globals — C's int counter; — takes no file space, just a reserved size | rw- |
.got / .got.plt | runtime-resolved addresses of library functions and data | rw- |
.dynamic | the table the loader reads to wire up shared libraries | rw- |
.symtab / .strtab / .debug_* | symbol names and debug info — not loaded into memory at runtime | — |
Two things are worth internalizing. First, sections with matching permissions are merged into one loadable segment — every r-x section becomes the single executable region in the map above, every rw- section becomes the writable one. That is why the coarse picture has a handful of regions while readelf -S shows dozens of sections. Second, .bss costs nothing on disk: an uninitialized global is stored as "reserve N zeroed bytes," so a program with a megabyte-sized zero array does not carry a megabyte of zeros around in its file.
The bare nasm programs in this course only ever produce .text and .data — .plt, .got, and the rest appear once you link against a library like libc. How those two sections cooperate to call a function whose address is not known until runtime is the subject of The GOT and PLT.