Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AFLplusplus/AFLplusplus/llms.txt
Use this file to discover all available pages before exploring further.
What is Instrumentation?
Instrumentation is the process of adding code to a program that allows AFL++ to monitor its execution and track which code paths are taken. This feedback is essential for coverage-guided fuzzing. When you compile a program with AFL++, the compiler inserts small pieces of tracking code at strategic points (typically at the beginning of each basic block or edge). During execution, this instrumented code updates a shared memory region that AFL++ reads to understand what code was executed.Proper instrumentation is critical for fuzzing effectiveness. Poor instrumentation can lead to missed paths, while good instrumentation enables AFL++ to efficiently explore the target’s behavior.
Choosing an Instrumentation Mode
AFL++ offers several instrumentation modes, each with different tradeoffs. Use this decision flow:LTO Mode (afl-clang-lto)
Link-Time Optimization (LTO) mode is the recommended instrumentation method. It instruments at link time when all compilation units are available, enabling optimal coverage tracking.Why LTO Mode?
Vanilla AFL and basic instrumentation modes assign random IDs to basic blocks during compilation. With thousands of instrumented locations, this causes edge collisions in the coverage map:- At 256 instrumented blocks: ~1 collision (on average)
- At 10,000 blocks: ~750 collisions
- At 50,000 blocks: ~18,000 collisions!
LTO Advantages
✓ Collision-free coverage: Guaranteed unique edge IDs ✓ Better performance: 10-25% speed gain vs LLVM mode ✓ Auto-dictionary: Automatically extracts comparison values during compilation ✓ Compatible with other features: Works with CMPLOG, LAF-intel, and instrumentation listsLTO Requirements
- LLVM 12 or newer (LLVM 18+ recommended)
- Must set
AR=llvm-arandRANLIB=llvm-ranlib - Some targets may need
AS=llvm-asorLD=afl-clang-lto
Building with LTO
LTO compilation can be significantly slower than other modes, especially for large projects. The runtime performance gain is worth the extra build time.
LTO Output Example
LLVM Mode (afl-clang-fast)
LLVM mode provides compiler-level instrumentation using LLVM’s infrastructure. It’s the most compatible mode and works with LLVM 3.8 through 21 (though 18+ is recommended).LLVM Mode Advantages
✓ Compiler optimizations: 2x faster than obsolete assembly-based instrumentation ✓ CPU independent: Works on non-x86 architectures ✓ Better thread support: Handles multi-threaded targets more gracefully ✓ Wide compatibility: Works with most LLVM-compatible code ✓ PCGUARD mode: Provides collision-free coverage (LLVM 9+)Building with LLVM Mode
LLVM Instrumentation Variants
You can select different instrumentation strategies: PCGUARD (default, LLVM 9+):- Collision-free coverage
- Best performance
- Recommended for most targets
GCC Plugin Mode (afl-gcc-fast)
For systems without LLVM, AFL++ provides a GCC plugin that offers similar functionality to LLVM mode.Requirements
- GCC 5 or newer
- GCC plugin development headers (
gcc-VERSION-plugin-dev)
Building with GCC Plugin
GCC plugin mode is less efficient than LLVM modes and lacks some advanced features. Use LLVM when possible.
Using afl-cc (Unified Compiler)
All AFL++ compilers are symlinks toafl-cc, which automatically detects the mode from the binary name. You can also explicitly set the mode:
Advanced Instrumentation Options
LAF-Intel / COMPCOV
Splits complex comparisons (integers, strings, floats, switches) into byte-level comparisons, making them easier for AFL++ to solve:LAF-Intel is particularly helpful when you don’t have a large, high-quality corpus. It helps AFL++ bypass difficult comparison checks.
CMPLOG (Redqueen)
Instruments the target to send comparison values to AFL++, which tries to insert these values into the fuzzing data:Selective Instrumentation
Instrument only specific parts of the code to reduce overhead and focus fuzzing: Allow-list (instrument only these files/functions):Thread-Safe Instrumentation
For multi-threaded targets, enable thread-safe counters:Instrumentation Best Practices
Compile Statically
Always compile targets statically when possible:Disable Symbol Hiding
If using linker scripts that hide symbols, you may see:Handle Build System Quirks
Some build systems need special handling:Optimize for Fuzzing
Remove unnecessary checks during fuzzing:Verifying Instrumentation
Check if your binary is properly instrumented:Expect thousands of instrumented edges for most real-world programs. Very low counts (<200) suggest incomplete instrumentation or early bailout.
Next Steps
- Learn about coverage tracking to understand how instrumentation data is used
- Explore mutation strategies that leverage coverage feedback
- Read the LLVM instrumentation details
- Check out LTO mode documentation

