[cfe-dev] Problem linking example program with DataFlow Sanitizer
Peter Collingbourne
peter at pcc.me.uk
Wed May 7 16:31:48 PDT 2014
On Wed, May 07, 2014 at 05:52:25PM -0500, Frederico Araujo wrote:
> Hi Peter,
>
> Thank you for your reply.
>
> I'm still having problems even after using cmake. Please see my comments
> below.
>
> On Wed, May 7, 2014 at 4:16 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
>
> > Hi Frederico,
> >
> > On Wed, May 07, 2014 at 03:43:07PM -0500, Frederico Araujo wrote:
> > > Hi,
> > >
> > > I'm trying to compile the example program from the DataFlow Sanitizer
> > page (
> > > http://clang.llvm.org/docs/DataFlowSanitizer.html) without success. I
> > > receive a number of errors when trying to compile the example with clang:
> > >
> > > /> clang -fsanitize=dataflow -o labelprop labelprop.c
> > [...]
> > > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/Scrt1.o: In
> > > function `_start':
> > > (.text+0x20): undefined reference to `main'
> > [...]
> > > /tmp/labelprop-bfe82e.o: In function `dfs$main':
> > > labelprop.c:(.text+0x78): undefined reference to `dfs$dfsan_create_label'
> >
> > It looks like DFSan wasn't able to find the ABI list file. Unfortunately
> > only the CMake build system currently supports building the ABI list.
> > Can you please try again with CMake?
> >
>
> I created this simple CMake list file:
>
> cmake_minimum_required (VERSION 2.6)
> project (EXAMPLE)
> add_executable(labelprop labelprop.c)
> SET (CMAKE_C_COMPILER "/usr/bin/clang")
> SET (CMAKE_C_FLAGS "-fsanitize=dataflow")
>
> After building the project with the above configuration, I still get the
> same errors as before. Anything missing? Perhaps I should say that I'm new
> to cmake :)
Sorry, I meant that you need to compile LLVM/Clang/compiler-rt with CMake
following the instructions here:
http://llvm.org/docs/CMake.html
> I forgot to ask in my first email: is there any step-by-step instructions
> on how to compile and get the dataflow sanitizer example working?
It shouldn't take any more than compiling with the -fsanitize=dataflow command
line flag, but admittedly the requirement to build Clang with CMake had not
been documented. I'll see about documenting it.
> > /usr/local/llvm/build/Debug+Asserts/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a(sanitizer_deadlock_detector1.o):(.data.rel.ro._ZTIN11__sanitizer9DDetectorE[_ZTIN11__sanitizer9DDetectorE]+0x0):
> > > undefined reference to `vtable for __cxxabiv1::__class_type_info'
> >
> > This would appear to indicate that your sanitizer runtimes were built with
> > RTTI, which is a little surprising. Did you do anything in particular to
> > enable RTTI?
> >
>
> Well, no. I just followed the instructions on the clang webpage on how to
> compile llvm and clang. I used the trunk versions of everything. I also
> compiled the optional projects. Could it be the -fsanitizer-dataflow option?
So it looks like when built with Makefiles, the dfsan runtime library contains
some object files that were compiled with RTTI. It isn't immediately clear why
this is happening with dfsan and not with the other sanitizer runtimes. Alexey,
do you have any idea?
In any case, building with CMake should fix this.
Thanks,
--
Peter
More information about the cfe-dev
mailing list