symcc icon indicating copy to clipboard operation
symcc copied to clipboard

c++ targets

Open vanhauser-thc opened this issue 4 years ago • 2 comments

I want to put afl++ and symcc on fuzzbench and I am running into problems on every target - because they all at some point are compile c++ code (latest at the harness) and this breaks, e.g.

#19 38.51 + /symcc_build/sym++ -stdlib=libc++ -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument -O3 -std=c++11 /src/target.cc .libs/libpng12.a /libAFLDriver.a -I . -lz -o /out/fuzz-target
#19 38.55 In file included from /src/target.cc:13:
#19 38.55 In file included from /libcxx_symcc_install/include/c++/v1/cstdlib:86:
#19 38.55 /libcxx_symcc_install/include/c++/v1/stdlib.h:111:82: error: use of undeclared identifier 'labs'; did you mean 'abs'?
#19 38.55 inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
#19 38.55                                                                                  ^

I tried to include math.h, stdlib.h, cstdlib, -lm etc. but nothing solved this error. Have you seen these issues before and if yes - how did you fix them?

also maybe update the Dockerfile to use llvm 10 instead of 8? (e.g. by moving to focal, then you would also likely not need to compile z3)

vanhauser-thc avatar Sep 11 '20 08:09 vanhauser-thc

I haven't seen that error before, but I think it's likely to be related to your use of libc++ as C++ standard library. sym++ uses an instrumented version of that library (which I suppose you installed in /libcxx_symcc_install). However, since SymCC is itself implemented in C++, it needs an uninstrumented standard library as well - which is usually libstdc++ as provided by the distribution.

As a quick test, could you try compiling without -stdlib=libc++ or, if that's not possible, with SYMCC_REGULAR_LIBCXX=1 set in the environment? The latter will cause sym++ to build without expecting an instrumented C++ standard library, which is bad for the analysis but will help to diagnose the issue. Also, could you give me some more information on your environment? Are you using the Docker image?

I'm working on the problem with libc++ at the moment anyway, so there may be a solution soon (if this even turns out to be the root cause of the error you're getting).

sebastianpoeplau avatar Sep 14 '20 21:09 sebastianpoeplau

@sebastianpoeplau I set SYMCC_REGULAR_LIBCXX=1 however still the same error.

vanhauser-thc avatar Sep 15 '20 16:09 vanhauser-thc