[llvm-dev] using llvm DataFlowSanitizer error

Sam Kerner via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 1 11:10:47 PDT 2018


On Sat, Mar 31, 2018 at 8:50 AM, 吕涛 via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Hi. I'm using llvm DataFlowSanitizer. I add such code in library libtiff.
>
> dfsan_label lt_label = dfsan_create_label("buf_offset", 0);
>
> dfsan_set_label(lt_label, (unsigned char *)buf, size);
>
> But when i compile libtiff with "-fsanitize=dataflow" option, then there is
> an error as follows:
>
>
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_enc_init'

DataFlowSanitizer creates an instrumented version of each function in
the program.  The instrumented version of a function has "dfs$" as a
prefix.  A missing reference to the function "dfs$jbg_enc_init" means
that no instrumented version of the function "jbg_enc_init" was
created.

Can you find the definition of the function jbg_enc_init ?  Is the
file that defines it compiled with "-fsanitize=dataflow"?  If it is
defined in a library libtiff depends on, try building the library with
"-fsanitize=dataflow".

If a functions that gives this sort of link error is implemented in
assembly, then DataFlowSanitizer has no opportunity to instrument it.
Many programs have some macro you can set to compile without using
assembly, and setting that macro fixes these issues.

If you can not avoid calling an assembly function, you can tell
DataflowSanitizer that a function is uninstrumented using the ABI list
file:

   https://clang.llvm.org/docs/DataFlowSanitizer.html#abi-list

> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_write_tables'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_suppress_tables'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$inflateReset'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_read_scanlines'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_set_quality'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_dec_init'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$inflateEnd'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_start_decompress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$deflateReset'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_read_raw_data'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_read_header'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_enc_free'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$inflateInit_'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_CreateDecompress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_dec_getimage'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_strerror'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_write_scanlines'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_finish_compress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_abort'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_dec_getsize'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_CreateCompress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$inflate'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_dec_free'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_destroy'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_finish_decompress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_resync_to_restart'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_enc_out'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jbg_dec_in'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$deflateParams'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$deflate'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_start_compress'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_set_defaults'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$deflateInit_'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$deflateEnd'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$inflateSync'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_set_colorspace'
> ../libtiff/libtiff.so.5.2.5: undefined reference to
> `dfs$jpeg_write_raw_data'
> ../libtiff/libtiff.so.5.2.5: undefined reference to `dfs$jpeg_std_error'
> clang-7.0: error: linker command failed with exit code 1 (use -v to see
> invocation)
> tools/CMakeFiles/tiff2ps.dir/build.make:100: recipe for target
> 'tools/tiff2ps' failed
> make[2]: *** [tools/tiff2ps] Error 1

Based on the names of the functions in the link error, I would guess
that the link step includes code that calls a library which processes
JPEG files.  That surprised me:  Why would a library to process TIFF
images need to depend on a library that processes JPEG images?  I see
in the log above that you ran "make all" and the specific build that
failed is "tiff2ps".  Do you care about that specific target?  If not,
"make $THE_TARGET_YOU_CARE_ABOUT".  There is a good chance that the
JPEG library is not used by most targets.

Let us know what you discover:  libtiff is a reasonably common
library.  Sharing your solution is likely to help others.


> CMakeFiles/Makefile2:311: recipe for target
> 'tools/CMakeFiles/tiff2ps.dir/all' failed
> make[1]: *** [tools/CMakeFiles/tiff2ps.dir/all] Error 2
> Makefile:138: recipe for target 'all' failed
> make: *** [all] Error 2
>
>
> I search on the internet, and found one answer in
> http://clang-developers.42468.n3.nabble.com/Problem-linking-example-program-with-DataFlow-Sanitizer-td4039375.html
>
>
> So i try to use cmake to recompile the llvm. There is an error again.
>
>
> [ 52%] Building ASM object
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_x86_64.S.o
> cc1: error: -Werror=date-time: no option -Wdate-time
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/build.make:1070:
> recipe for target
> 'projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_x86_64.S.o'
> failed
> make[2]: ***
> [projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_x86_64.S.o]
> Error 1
> CMakeFiles/Makefile2:20521: recipe for target
> 'projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/all'
> failed
> make[1]: ***
> [projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/all]
> Error 2
> Makefile:149: recipe for target 'all' failed
> make: *** [all] Error 2
>
>
> Can anyone help me to solve this problem? Thank you.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>


More information about the llvm-dev mailing list