AFLplusplus/StdFuzzer

Error when compiling SerenityOS fuzzer multiple definition of __sanitizer_cov_trace_const_cmp

CityOfLight77 opened this issue · 1 comments

When I compiling SerenityOS with StdFuzzer it return an error. Here is command I used to compile SerenityOS

sudo apt-get install -y libboost-all-dev build-essential cmake curl e2fsprogs libmpfr-dev libmpc-dev libgmp-dev ninja-build unzip qemu-system-i386 qemu-utils ccache rsync libgsf-1-dev
git clone https://github.com/SerenityOS/serenity.git; cd serenity
cmake -GNinja -S Meta/Lagom -B Build/lagom-fuzzers \
  -DBUILD_LAGOM=ON \
  -DENABLE_FUZZER_SANITIZER=ON \
  -DENABLE_ADDRESS_SANITIZER=ON \
  -DCMAKE_CXX_COMPILER=$HOME/StdFuzzer/target/release/libafl_cxx \
  -DCMAKE_C_COMPILER=$HOME/StdFuzzer/target/release/libafl_cc
cd Build/lagom-fuzzers
ninja

Here is the error log

cityoflight@SerenityOS:~/serenity/Build/lagom-fuzzers$ ninja
[0/2] Re-checking globbed directories...
[244/638] Linking CXX executable Fuzzers/FuzzZip
FAILED: Fuzzers/FuzzZip
: && /home/cityoflight/StdFuzzer/target/release/libafl_cxx    -fsanitize=address Fuzzers/CMakeFiles/FuzzZip.dir/FuzzZip.cpp.o  -o Fuzzers/FuzzZip  -Wl,-rpath,/home/cityoflight/serenity/Build/lagom-fuzzers  liblagom-archive.so.0.0.0  liblagom-core.so.0.0.0  -fsanitize=fuzzer  -lcrypt && :
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(stdfuzzer-02081e40da0c85a2.stdfuzzer.3418a45c-cgu.0.rcgu.o): in function `__sanitizer_cov_trace_pc_guard':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_pcguard.rs:20: multiple definition of `__sanitizer_cov_trace_pc_guard'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_pc_guard+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(stdfuzzer-02081e40da0c85a2.stdfuzzer.3418a45c-cgu.0.rcgu.o): in function `__sanitizer_cov_trace_pc_guard_init':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_pcguard.rs:53: multiple definition of `__sanitizer_cov_trace_pc_guard_init'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_pc_guard_init+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_cmp1':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:11: multiple definition of `__sanitizer_cov_trace_cmp1'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_cmp1+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_cmp2':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:27: multiple definition of `__sanitizer_cov_trace_cmp2'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_cmp2+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_cmp4':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:43: multiple definition of `__sanitizer_cov_trace_cmp4'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_cmp4+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_cmp8':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:59: multiple definition of `__sanitizer_cov_trace_cmp8'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_cmp8+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_switch':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:75: multiple definition of `__sanitizer_cov_trace_switch'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_switch+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_const_cmp1':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:113: multiple definition of `__sanitizer_cov_trace_const_cmp1'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_const_cmp1+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_const_cmp2':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:117: multiple definition of `__sanitizer_cov_trace_const_cmp2'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_const_cmp2+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_const_cmp4':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:121: multiple definition of `__sanitizer_cov_trace_const_cmp4'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_const_cmp4+0x0): first defined here
/usr/bin/ld: /home/cityoflight/StdFuzzer/target/release/libstdfuzzer.a(sancov_cmp.o): in function `__sanitizer_cov_trace_const_cmp8':
/home/cityoflight/.cargo/git/checkouts/libafl-c33dc6f5ec2f7a70/906bb4e/libafl_targets/src/sancov_cmp.c:125: multiple definition of `__sanitizer_cov_trace_const_cmp8'; /usr/lib/llvm-13/lib/clang/13.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a(FuzzerTracePC.cpp.o):(.text.__sanitizer_cov_trace_const_cmp8+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[246/638] Building CXX object CMakeFiles/LagomJS.dir/hom...ty/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp.o
ninja: build stopped: subcommand failed.

You are linking this one and libfuzzer together in the same binary, remove -fsanitize=fuzzer