Lesson 3 of 9 · 25m
Sections, Loaders, and the Shape of Control Flow
Map executable sections, entry initialization, imports, and cross-reference structure before diving into individual basic blocks.
A binary is not a flat pile of instructions. It is a loading recipe plus machine code plus data, arranged so a kernel and runtime can turn it into a process. When reverse engineers get lost, it is often because they are reading instructions without knowing which parts of the map are executable, writable, constant, imported, or generated by the compiler runtime.
Sections tell you where meaning lives
Inspect sections and permissions before disassembling:
readelf -SW ./sample | awk '{print $2, $3, $7, $8}' | head -30
objdump -h ./sample | head -30Typical ELF layout puts executable code in .text, constants in .rodata, mutable initialized data in .data, zero-initialized data in .bss, dynamic linking stubs in .plt, and relocation targets in .got. On PE files you see .text, .rdata, .data, .pdata, and sometimes .reloc. Permissions matter as much as names; writable executable regions deserve attention.
Entry point is not main
The ELF entry point usually enters runtime initialization, not the author's main:
_start:
xor ebp, ebp
mov r9, rdx
pop rsi
mov rdx, rsp
and rsp, -16
...
call __libc_start_main__libc_start_main receives the real main address through a register or argument depending on platform and version. In Ghidra or IDA, follow initialization outward instead of assuming the entry point is application logic.
Control-flow graphs are terrain, not plot
A function graph shows basic blocks and branches, not purpose. Use shape to classify before reading every instruction:
long linear block initialization or parsing pipeline
small loop around memcpy copy/transform routine
nested switch dispatch state machine or protocol handler
many callers, tiny body utility wrapper
recursive shape tree traversal or recursive descent parserGraph complexity is not proof of importance. Sometimes the tiny function called everywhere is the key authorization check, while the enormous function is generated protobuf serialization.
Cross-references turn landmarks into relationships
Strings, constants, imports, and function pointers become useful when connected by xrefs. If .rodata contains invalid license signature, find every reference to that string. Then inspect whether nearby code verifies signatures, chooses an error path, or merely prints diagnostics. The relationship — not the string — is the finding.
Field notes
- Overlay data after the formal end of a PE or appended archives in ELF binaries can hide configuration or payloads.
- Exception metadata and unwind tables can reveal function boundaries even in stripped binaries.
- Jump tables often live in
.rodata; treating them as ordinary integers obscures switch targets. - Do not trust section names absolutely. Packers and linkers can create misleading layouts.
Was this lesson helpful?