Commit Graph

197 Commits

Author SHA1 Message Date
7c3c0b26d1 document new env var 2023-04-24 20:32:04 +02:00
9e3e1a5512 afl-cc: Don't offer __AFL_INIT() etc. in GCC/CLANG modes
instrumentation/README.persistent_mode.md documents in the section about
deferred forkserver initialization:

> With the location selected, add this code in the appropriate spot:
>
> ```c
> #ifdef __AFL_HAVE_MANUAL_CONTROL
>   __AFL_INIT();
> #endif
> ```
>
> You don't need the #ifdef guards, but including them ensures that the program
> will keep working normally when compiled with a tool other than afl-clang-fast/
> afl-clang-lto/afl-gcc-fast.
>
> Finally, recompile the program with afl-clang-fast/afl-clang-lto/afl-gcc-fast
> (afl-gcc or afl-clang will *not* generate a deferred-initialization binary) -
> and you should be all set!


This strongly implies that you can compile a program that uses __AFL_INIT()
under an `#ifdef __AFL_HAVE_MANUAL_CONTROL` guard with afl-gcc/-clang.

However, this currently fails:

  $ cat example.c
  #include <stdio.h>

  int main(void) {
  #ifdef __AFL_HAVE_MANUAL_CONTROL
  	__AFL_INIT();
  #endif

  	puts("Hello");
  }
  $ afl-gcc example.c -o example
  afl-cc++4.06a by Michal Zalewski, Laszlo Szekeres, Marc Heuse - mode: GCC-GCC
  [!] WARNING: You are using outdated instrumentation, install LLVM and/or gcc-plugin and use afl-clang-fast/afl-clang-lto/afl-gcc-fast instead!
  afl-as++4.06a by Michal Zalewski
  [+] Instrumented 1 locations (64-bit, non-hardened mode, ratio 100%).
  /usr/bin/ld: /tmp/ccuJHcpt.o: in function `main':
  /home/jn/dev/fuzz/AFLplusplus/example.c:5: undefined reference to `__afl_manual_init'
  collect2: error: ld returned 1 exit status


The issue here is an inconsistency in afl-gcc (i.e. afl-cc operating in GCC mode):

 - afl-cc defines __AFL_HAVE_MANUAL_CONTROL and __AFL_INIT unconditionally
 - __AFL_INIT relies on __afl_manual_init, which is defined in afl-compiler-rt.o
 - afl-cc doesn't link afl-compiler-rt in GCC or CLANG mode


Since afl-gcc/-clang is documented as not supporting deferred forkserver
initialization, this patch omits the definitions of __AFL_HAVE_MANUAL_CONTROL
and related macros in GCC/CLANG mode.

This restores the ability to compile a deferred-forkserver program under
afl-gcc, if it can also be compiled under gcc.

[ In case someone reads this an feels adventurous enough (as I did) to
  think about enabling deferred forkserver under afl-gcc: Whether the
  deferred forkserver actually works can be verified by placing a
  usleep(100000) or similar at the start of main (before __AFL_INIT()),
  and watching the execution speed. It doesn't work. ]
2023-04-10 13:47:19 +02:00
0eace0212e afl-cc: Avoid casts of string literals to char*, in definition of __AFL_INIT() etc.
With the right -W options, compilers may complain about the cast of
string literals (for PERSIST_SIG and DEFER_SIG) to (char*), and they're
right to do so, because string literals are constant. Since some
projects enable -Werror, this can lead to a broken build with afl-cc.

Let's simply cast to (const char *), which preserves the constness of
the string literal.
2023-04-08 17:24:02 +02:00
80eabd6e8a AFL_LLVM_DICT2FILE_NO_MAIN support 2023-02-13 11:34:14 +01:00
4063a3eb4c nit 2023-01-23 12:50:57 +01:00
8bc7b3cf26 add CFI variant for gcc 2023-01-23 12:45:21 +01:00
35f09e11a4 welcome 2023 2023-01-03 09:38:07 +01:00
c24939e812 Merge pull request #1576 from AFLplusplus/persistent_mode_always
Persistent mode always
2022-11-10 14:46:01 +01:00
b868758cd7 more llvm16 fixes 2022-11-10 12:06:00 +01:00
513a6ce7b6 try llvm 16 fix 2022-11-10 11:55:29 +01:00
c1562a7cde Didn't mean to change that 2022-11-09 03:34:37 +01:00
0496390526 fmt 2022-11-09 02:32:13 +00:00
d65cf10bad Always enable persistent mode, no env/bincheck needed 2022-11-09 03:28:06 +01:00
0e908d5b1e Fix -rpath argument 2022-10-20 08:26:55 -04:00
2107ece114 auto shmem fuzzing (#1541)
* auto shmem fuzzing

* print warning when forcing shmem fuzzing

* typos

* Shmem always

* typo fix

* fixes

Co-authored-by: Dominik Maier <dmnk@google.com>
2022-10-07 15:40:04 +02:00
0623a73a5c fix docs 2022-09-17 11:56:39 +02:00
b27a4a3689 Fix loading and registeration of LTO pass for new pass manager 2022-09-14 15:54:29 +02:00
88ff8aa81e fix gcc_mode cmplog 2022-08-25 08:47:30 +02:00
b4cb3784a5 add malloc check 2022-08-19 13:17:01 +02:00
f00d83afbc filter pipe in gcc_mode 2022-08-15 17:38:53 +02:00
4e98071385 better handling of -fsanitize=..,...,.. lists 2022-08-14 14:40:26 +02:00
b847e0f414 clang format 14 2022-07-12 09:04:54 +02:00
1759859ae2 fix double free on exit for -c 0 on src cmplog 2022-07-07 09:03:46 +02:00
1334851e7c cmplog support for gcc_plugin by adacore 2022-07-04 09:59:47 +02:00
1a4c0d2ecd nits 2022-06-20 17:59:14 +02:00
ee409d18a6 code format 2022-04-25 10:14:04 +02:00
f53e6a6cf2 fix instrumentation for -Werror,-Wunused-but-set-variable
`used` is so it isn't optimized out. `unused` is to avoid the warning.
2022-04-20 15:39:28 -04:00
630eb943a5 use passthrough mode for wasm 2022-04-20 15:38:37 -04:00
285a5cb38b Some scan-build fixes 2022-03-31 15:36:26 +00:00
a436ef47e5 fix instrumentlist for LTO with clang < 13 2022-03-30 09:16:47 +02:00
fa2b040476 fix LTO with cmplog and laf 2022-03-18 15:00:24 +01:00
69c9a176eb our own PCGUARD mode not for llvm 10.0.1 2022-03-18 12:57:51 +01:00
bdfac291ba fix split pass loading 2022-03-18 08:47:45 +01:00
3d1be62c96 merge fixes 2022-03-17 16:39:40 +01:00
1bea949f34 Merge branch 'dev' into newpm2 2022-03-17 16:30:29 +01:00
e4f201707f make LTO pass work too plus some fixes 2022-03-17 14:35:15 +01:00
59eaed2f70 make pcguard work 2022-03-17 13:52:48 +01:00
d325fa5db8 code format 2022-03-01 20:13:57 +01:00
f70760896c Revert "Merge branch 'newpm2' into dev"
This reverts commit fee1acf7e6, reversing
changes made to 675d17d737.
2022-03-01 19:21:31 +01:00
fee1acf7e6 Merge branch 'newpm2' into dev 2022-02-22 13:58:49 +01:00
05119990b6 LLVM 14 fixes 2022-02-22 11:13:00 +01:00
914eb79cbc todo list 2022-02-21 10:32:43 +01:00
92db443635 Revert "remove new llvm pass manager :("
This reverts commit 55ed2a443c.
2022-02-20 19:51:43 +01:00
5e8da2b85c Adapt to my MacOS 2022-02-09 20:36:16 +01:00
fa628865c1 remove debug msg 2022-02-08 18:43:23 +01:00
05a36f10ba import mozilla afl-cc patch 2022-02-08 18:33:59 +01:00
22da04f077 fix 2022-01-21 10:13:37 +01:00
550ba4d772 nits and code format 2022-01-19 22:26:52 +01:00
4bcb177f62 Revert "fix classify counts"
This reverts commit 4217a6606c.
2022-01-19 22:17:36 +01:00
4217a6606c fix classify counts 2022-01-15 13:58:17 +01:00