[cfe-dev] Undefined reference to dfsan_add_label in dataflow sanitizer

Peter Collingbourne peter at pcc.me.uk
Wed Jun 4 11:05:25 PDT 2014


Hi Frederico,

This was because of a bug in the declaration of the dfsan_add_label function
(it was defined with C++ linkage instead of the expected C linkage).
It should be fixed as of r210202.

Peter

On Wed, Jun 04, 2014 at 12:14:34PM -0500, Frederico Araujo wrote:
> Hi,
> 
> When  trying to use the function *dfsan_add_label* defined in the dataflow
> sanitizer interface I get an undefined reference error. Other functions
> such as *dfsan_create_label* and *dfsan_set_label* work fine. I can emulate
> this function by using dfsan_union and fsan_set_label, but I'm curious to
> understand why it's undefined. Any ideas?
> 
> Here is the output of compilation with -v flag:
> 
> clang version 3.5.0 (208131)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
>  "/usr/local/llvm/cmakebuild/bin/clang-3.5" -cc1 -triple
> x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
> -disable-llvm-verifier -main-file-name mrpoc.c -mrelocation-model pic
> -pic-level 2 -pie-level 2 -mdisable-fp-elim -fmath-errno -masm-verbose
> -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
> -v -resource-dir /usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0
> -internal-isystem /usr/local/include -internal-isystem
> /usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0/include
> -internal-externc-isystem /usr/include/x86_64-linux-gnu
> -internal-externc-isystem /include -internal-externc-isystem /usr/include
> -fdebug-compilation-dir /home/frederico/dev/tests/llvm/mr -ferror-limit 19
> -fmessage-length 116 -fsanitize=dataflow
> -fsanitize-blacklist=/usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0/dfsan_abilist.txt
> -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option
> -fcolor-diagnostics -o /tmp/mrpoc-da2ec3.o -x c mrpoc.c
> clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
> x86_64-unknown-linux-gnu
> ignoring nonexistent directory "/include"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/local/include
>  /usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0/include
>  /usr/include/x86_64-linux-gnu
>  /usr/include
> End of search list.
>  "/usr/bin/ld" -whole-archive
> /usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a
> -no-whole-archive -pie -z relro --hash-style=gnu --build-id --eh-frame-hdr
> -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o mrpoc
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/Scrt1.o
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o
> /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginS.o
> -L/usr/lib/gcc/x86_64-linux-gnu/4.8
> -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu
> -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
> -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..
> -L/usr/local/llvm/cmakebuild/bin/../lib -L/lib -L/usr/lib
> /tmp/mrpoc-da2ec3.o -lpthread -lrt -lm -ldl
> --dynamic-list=/usr/local/llvm/cmakebuild/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a.syms
> -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
> --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtendS.o
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
> /tmp/mrpoc-da2ec3.o: In function `main':
> mrpoc.c:(.text+0xb3): undefined reference to `dfsan_add_label'
> /tmp/mrpoc-da2ec3.o: In function `dfsw$dfsan_add_label':
> mrpoc.c:(.text.dfsw$dfsan_add_label[dfsw$dfsan_add_label]+0xb): undefined
> reference to `dfsan_add_label'
> clang-3.5: error: linker command failed with exit code 1
> 
> Thanks,
> Fred

> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


-- 
Peter



More information about the cfe-dev mailing list