afl-cc compiler wrapper instruments programs for coverage-guided fuzzing. It supports multiple compilation modes and instrumentation strategies.
Synopsis
Description
afl-cc is a drop-in replacement for your regular compiler (gcc/clang) that adds instrumentation to track code coverage during fuzzing. The wrapper automatically selects the appropriate compiler backend and instrumentation mode based on available toolchains.
Compiler Mode Selection
The compiler mode can be selected in three ways (in order of priority):1. Command-line Option
--afl-lto- LTO (Link-Time Optimization) mode--afl-llvm- LLVM mode with PCGUARD instrumentation--afl-gcc-plugin- GCC plugin mode--afl-gcc- Traditional GCC mode--afl-clang- Clang assembly mode
2. Symlink Name
Create symlinks toafl-cc:
afl-clang-fast→ LLVM modeafl-clang-lto→ LTO modeafl-gcc-fast→ GCC plugin modeafl-gcc→ GCC modeafl-clang→ Clang mode
3. Environment Variable
Instrumentation Options
Configure the instrumentation mode. Available options:
CLASSIC- Traditional AFL edge coverage (default)PCGUARD- Optimized PCGUARD instrumentationLTO- Link-time optimization modeCTX- Context-sensitive instrumentationNGRAM-2toNGRAM-16- N-gram coverage
AFL_LLVM_INSTRUMENT=CLASSIC,CTXEnable CmpLog instrumentation for better coverage of comparison operations.
Enable AddressSanitizer (detects memory corruption bugs).
Enable MemorySanitizer (detects use of uninitialized memory).
Enable UndefinedBehaviorSanitizer (detects undefined behavior).
Automatically add hardening flags:
-D_FORTIFY_SOURCE=2 -fstack-protector-all.Selective Instrumentation
File containing functions/files to instrument (one per line).
File containing functions/files to NOT instrument (one per line).
Percentage of branches to instrument (0-100). Useful for very large programs.
LAF-INTEL Transform
Split complex comparisons for better fuzzing:Enable all LAF transformations.
Split integer comparisons into byte-by-byte checks.
Split switch statements.
Transform string comparison functions.
Advanced Options
Disable automatic
-O3 optimization.Set optimization level (default: 3). Example:
AFL_OPT_LEVEL=2Specify alternative C compiler to use.
Specify alternative C++ compiler to use.
Directory containing AFL++ runtime objects and plugins.
Suppress banner and compilation messages.
Examples
Basic Compilation
LTO Mode (Recommended)
With Sanitizers
CmpLog Mode
Context-Sensitive Coverage
LAF-INTEL Transforms
Selective Instrumentation
Persistent Mode Macros
For in-process fuzzing with__AFL_LOOP():
See Also
- afl-fuzz - Main fuzzing engine
- afl-cmin - Corpus minimizer
- Environment Variables - Complete variable reference

