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.
Overview
The GCC plugin provides true compiler-level instrumentation for targets that must be built with GCC rather than LLVM/Clang. It offers similar benefits to LLVM mode but works with the GCC compiler infrastructure.TL;DR
Benefits
- Compiler optimizations: Leverages GCC’s optimization capabilities
- Better performance: Up to 2x faster for CPU-bound programs
- CPU-independent: Works on non-x86 architectures (build afl-fuzz with
AFL_NOX86=1) - GCC-specific targets: Only option for projects that require GCC
Requirements
GCC Version
GCC 4.5.0 or newer with plugin support.Plugin Development Headers
Install the plugin development package matching your GCC version:Compiler Selection
The plugin must match your GCC version. Set compilers via environment variables:If
CC/CXX environment variables are set, they take precedence over AFL_CC/AFL_CXX.Version Check Override
If compiling with a different GCC version than system-installed:Building
afl-gcc-fast- GCC plugin wrapper for Cafl-g++-fast- GCC plugin wrapper for C++
Usage
Basic Compilation
With Specific GCC Version
Environment Variables
The GCC plugin supports several AFL++ environment variables:Specify the GCC compiler to use (e.g.,
gcc-11, /usr/bin/gcc-12).Specify the G++ compiler to use (e.g.,
g++-11, /usr/bin/g++-12).Instrument only a percentage of branches (default: 100%).
Enable AddressSanitizer instrumentation.
Enable hardening compile-time options.
Disable optimization passes.
Disable GCC version mismatch checks.
Features
Deferred Initialization
Start the forkserver after expensive initialization:Persistent Mode
Fuzz multiple times in a single process for 10-20x performance:Selective Instrumentation
Instrument only specific files using allowlist/denylist:CMPLOG Support
The GCC plugin supports CmpLog for Redqueen-style mutations:Performance
| Binary Type | Expected Gain |
|---|---|
| CPU-bound programs | Up to 2x faster |
| Fast binaries | ~10% faster |
| Process-creation bound | Minimal gain |
Performance gains are comparable to LLVM mode but may vary based on GCC optimizations.
When to Use GCC Plugin
- Use GCC Plugin When
- Use LLVM Mode When
- Target requires GCC (doesn’t build with Clang)
- Working on GCC-specific code
- Target uses GCC extensions
- LLVM/Clang not available on platform
Comparison with Other Modes
| Feature | GCC Plugin | LLVM Mode | LTO Mode |
|---|---|---|---|
| Compiler | GCC | Clang/LLVM | Clang/LLVM |
| Performance | Good | Better | Best |
| Collision-free | No | No | Yes |
| Persistent mode | Yes | Yes | Yes |
| CmpLog | Yes | Yes | Yes |
| N-Gram coverage | No | Yes | Yes |
| Context-sensitive | No | Yes | Yes |
| AFL_INST_RATIO | Yes | No | No |
Troubleshooting
Plugin Headers Not Found
Version Mismatch
Compilation Fails
If the target doesn’t compile:-
Verify it builds with regular GCC:
-
Check GCC version compatibility:
-
Set compiler explicitly:
Example: Complete Build
Next Steps
Persistent Mode
Achieve 10-20x performance with persistent mode fuzzing
CmpLog
Enable Redqueen-style mutations
LLVM Mode
Switch to LLVM for better performance (if target supports it)
Selective Instrumentation
Instrument only specific parts of code

