rewrite gcc plugin

When we started using AFL, it did not have an integrated GCC plugin.
There was one proposed by Austin Seipp, but for various reasons we
ended up using some of its infrastructure (runtime and wrapper), but
writing the GCC plugin proper from scratch.

With AFL++'s renewed interest in a GCC plugin, we rebased ours, with
some features that are or were missing in the one that was integrated:

* efficient, fully-functional inline and out-of-line instrumentation

Inline instrumentation was work in progress in the original plugin.
Controlled by AFL_GCC_OUT_OF_LINE.

* reproducible instrumentation

Obey -frandom-seed for pseudorandom number generation.

* licensing clarity and strict compliance

GPLv3+ for the plugin, that uses GCC internals; add a copy of the
license, as required.

* allow/deny list support

Copied and adjusted from the LLVM plugin implementation.

* neverZero support

Not as compact as the asm-wrapper version, but likely more efficient.
Both are quite thread-unsafe, with different caveats.
Controlled with AFL_GCC_SKIP_NEVERZERO.
This commit is contained in:
Alexandre Oliva
2020-09-07 12:35:31 -03:00
committed by Paul Butcher
parent 43cb626ad3
commit 9544b3dbf2
9 changed files with 1615 additions and 517 deletions

View File

@ -1335,6 +1335,12 @@ int main(int argc, char **argv, char **envp) {
AFL_REAL_LD, AFL_CLANG_FLTO);
#endif
SAYF(
"\nGCC Plugin-specific environment variables:\n"
"AFL_GCC_OUT_OF_LINE: disable inlined instrumentation\n"
"AFL_GCC_SKIP_NEVERZERO: do not skip zero on trace counters\n"
"AFL_GCC_INSTRUMENT_FILE: enable selective instrumentation by "
"filename\n");
}
SAYF(