Dynamic Analysis with QEMU Tracing
TL;DR
- Use QEMU’s built-in tracing (
-d) to record instruction flow. - Combine trace logs with
objdumpfor fast correlation. - No real hardware is required; QEMU gives deterministic output.
1. Build a trace target
Create:
| |
Build it:
| |
2. Trace instructions with QEMU
| |
Now inspect build/trace.log to see instruction flow.
3. Correlate trace lines with disassembly
| |
Use the PC values in the trace log to jump to the matching disassembly lines.
Exercises
- Add another function and verify it appears in the trace.
- Build with
-O2and compare the trace length. - Add a conditional branch and see how it changes the trace.
Summary
- QEMU traces give you a lightweight form of dynamic analysis.
- Disassembly + trace logs let you reason about control flow precisely.
- This approach works entirely in emulation with no hardware needed.