[cfe-dev] Problem linking in some dataflow sanitizer functions?

Christian Convey christian.convey at gmail.com
Mon Jan 12 09:56:01 PST 2015


Hello, I'm using the dataflow sanitizer in clang 3.6 for the first
time, I'm I'm running into some linker errors.  I was wondering if
someone could point out my mistake?

I downloaded (today) from git the current llvm, clang, and compiler-rt
code.  It built without any problem.

Using that build of clang/llvm, I'm able to run the example code shown
here:  http://clang.llvm.org/docs/DataFlowSanitizer.html#example

However, I have a linking problem when I try to extend the example.
When I try to call the function "dfsan_get_label_info", the linker
can't find it.  This is a bit of a surprise, because it does appear to
be defined in my LLVM build:

cconvey at spaceman /tmp $ nm
/home/cconvey/dw/clang-llvm-git/build/bin/../lib/clang/3.6.0/lib/linux/libclang_rt.dfsan-x86_64.a
| grep dfsan_get_label_info
0000000000000990 T _Z20dfsan_get_label_infot
cconvey at spaceman /tmp $ c++filt _Z20dfsan_get_label_infot
dfsan_get_label_info(unsigned short)

And I'm reasonably sure I'm linking in that .a file:

cconvey at spaceman /tmp $
/home/cconvey/dw/clang-llvm-git/build/bin/clang  -fsanitize=dataflow
foo.c -v
clang version 3.6.0 (http://llvm.org/git/clang.git
48d2f2367001a51a3253cc34aea4a91c92fd45fb)
(http://llvm.org/git/llvm.git
ad017096fc8eec5afd256f572d8d0b9d5d8aa09f)
...
End of search list.
 "/usr/bin/ld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -o a.out
/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/home/cconvey/dw/clang-llvm-git/build/bin/../lib -L/lib -L/usr/lib
-whole-archive /home/cconvey/dw/clang-llvm-git/build/bin/../lib/clang/3.6.0/lib/linux/libclang_rt.dfsan-x86_64.a
-no-whole-archive
--dynamic-list=/home/cconvey/dw/clang-llvm-git/build/bin/../lib/clang/3.6.0/lib/linux/libclang_rt.dfsan-x86_64.a.syms
/tmp/foo-5310a2.o --no-as-needed -lpthread -lrt -lm -ldl -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/foo-5310a2.o: In function `dfs$execute_tree':
foo.c:(.text+0xa89): undefined reference to `dfsan_get_label_info'
/tmp/foo-5310a2.o: In function `dfsw$dfsan_get_label_info':
foo.c:(.text.dfsw$dfsan_get_label_info[dfsw$dfsan_get_label_info]+0xb):
undefined reference to `dfsan_get_label_info'
clang-3.6: error: linker command failed with exit code 1 (use -v to
see invocation)
cconvey at spaceman /tmp $

(I'm also having linkage problems when my code uses C++ iostreams, but
I figured I'd work through this issue first.)



More information about the cfe-dev mailing list