罗正雄 via llvm-dev
2019-May-09 08:54 UTC
[llvm-dev] How to rewrite custom function in dfsan?
Hi, I am trying to rewrite the custom function __dfsw_read in compiler-rt/lib/dfsan/dfsan_custom.cc, I wrote the function __dfsw_read like this dfsan_lib.c ``` #include <stdio.h> #include <sanitizer/dfsan_interface.h> __attribute__((visibility("default"))) ssize_t __dfsw_read (int __fd, void *__buf, size_t __nbytes, dfsan_label __fd_label, dfsan_label __buf_label, dfsan_label __nbytes_label, dfsan_label *ret_label) { ssize_t ret = read(__fd, __buf, __nbytes); if(ret != -1) { assign_taint_labels_exf(__buf, fd, ret, __nbytes); fd += ret; } *ret_label = 0; return ret; } ``` with following ABI List: dfsan_abilist.txt ``` fun:read=uninstrumented fun:read=custom ``` Then, I pack the lib with ``` clang -Wall -fPIC -fsanitize-blacklist=./dfsan_abilist.txt -o dfsan_lib.o dfsan_lib.c ar -rc dfsan_lib.o dfsan_lib.a ``` And then compile with my test program test.c ``` clang -fsanitize=dataflow -fsanitize-blacklist=./dfsan_abilist.txt -fPIC test.c -ldfsan_lib ``` Then error occurs which says that "__dfsw_read" has been defined in compiler-rt/lib/dfsan/dfsan_custom.cc. Is there something I am missing or doing wrong in my steps? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190509/1824aa6c/attachment.html>