diff options
author | vanhauser-thc <vh@thc.org> | 2023-06-07 15:17:46 +0200 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2023-06-07 15:17:46 +0200 |
commit | 88603a2c2e770b20373c4002cb4aaf4e7b058ae5 (patch) | |
tree | 7f8ff7f563078dc58b3f4fc8d7517a8a50002292 | |
parent | a4b927241651c645cc1a2f5b185681830e7000f9 (diff) | |
download | afl++-88603a2c2e770b20373c4002cb4aaf4e7b058ae5.tar.gz |
add issue to faq
-rw-r--r-- | docs/FAQ.md | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/docs/FAQ.md b/docs/FAQ.md index 8178db46..9275eb94 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -279,3 +279,54 @@ If you find an interesting or important question missing, submit it via Solution: just do an `export AFL_MAP_SIZE=(the value in the warning)`. </p></details> + +<details> + <summary id="linker-errors">Linker errors.</summary><p> + + If you compile C++ harnesses and see `undefined reference` errors for + variables named `__afl_...`, e.g.: + + ``` + /usr/bin/ld: /tmp/test-d3085f.o: in function `foo::test()': + test.cpp:(.text._ZN3fooL4testEv[_ZN3fooL4testEv]+0x35): undefined reference to `foo::__afl_connected' + clang: error: linker command failed with exit code 1 (use -v to see invocation) + ``` + + Then you use AFL++ macros like `__AFL_LOOP` within a namespace and this + will not work. + + Solution: Move that harness portion to the global namespace, e.g. before: + ``` + #include <cstdio> + namespace foo { + static void test() { + while(__AFL_LOOP(1000)) { + foo::function(); + } + } + } + + int main(int argc, char** argv) { + foo::test(); + return 0; + } + ``` + after: + ``` + #include <cstdio> + static void mytest() { + while(__AFL_LOOP(1000)) { + foo::function(); + } + } + namespace foo { + static void test() { + mytest(); + } + } + int main(int argc, char** argv) { + foo::test(); + return 0; + } + ``` +</p></details> |