I tried running step 5 with clang -fsanitize=dataflow instead of gcc but it gave the following error: relocation R_X86_64_32 against `desc' can not be used when making a shared object; recompile with -fPIC error adding symbols: Bad value clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) So I also tried adding -fPIC option at step 1 when converting .c program to .bc and still results in same error. Is there anything else I may be missing here. Thanks On Fri, Jun 2, 2017 at 9:25 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:> Programs compiled with dfsan require a runtime library in order to work > correctly. You will need to link your program with "clang > -fsanitize=dataflow". > > Peter > > On Fri, Jun 2, 2017 at 12:46 AM, Archa . via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi, >> >> I am trying to instrument a small program with dfsan at IR and then >> compile it. But I end up with undefined reference errors. >> >> Steps taken: >> 1.Convert toy program to .bc >> 2. IR pass to insert dfsan calls >> 3.opt -dfsan on resultant bitcode from step 2 >> 4. llc step3.bc -o step4.s >> 5. gcc step.s -o step5.o >> >> I get error "undefined reference to `__dfsan_arg_tls' " and so forth for >> all functions defined. >> Is there something I am missing or doing wrong in my steps. >> >> Thanks >> >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > > > -- > -- > Peter >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170603/a44fd7af/attachment-0001.html>
Peter Collingbourne via llvm-dev
2017-Jun-03 10:43 UTC
[llvm-dev] Compiling program with dfsan at IR
Try passing -relocation-model=pic at step 4. Peter On Sat, Jun 3, 2017 at 2:19 AM, Archa . <archa91 at gmail.com> wrote:> I tried running step 5 with clang -fsanitize=dataflow instead of gcc but > it gave the following error: > > relocation R_X86_64_32 against `desc' can not be used when making a shared > object; recompile with -fPIC > error adding symbols: Bad value > clang-5.0: error: linker command failed with exit code 1 (use -v to see > invocation) > > So I also tried adding -fPIC option at step 1 when converting .c program > to .bc and still results in same error. Is there anything else I may be > missing here. > > Thanks > > > > On Fri, Jun 2, 2017 at 9:25 PM, Peter Collingbourne <peter at pcc.me.uk> > wrote: > >> Programs compiled with dfsan require a runtime library in order to work >> correctly. You will need to link your program with "clang >> -fsanitize=dataflow". >> >> Peter >> >> On Fri, Jun 2, 2017 at 12:46 AM, Archa . via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> Hi, >>> >>> I am trying to instrument a small program with dfsan at IR and then >>> compile it. But I end up with undefined reference errors. >>> >>> Steps taken: >>> 1.Convert toy program to .bc >>> 2. IR pass to insert dfsan calls >>> 3.opt -dfsan on resultant bitcode from step 2 >>> 4. llc step3.bc -o step4.s >>> 5. gcc step.s -o step5.o >>> >>> I get error "undefined reference to `__dfsan_arg_tls' " and so forth >>> for all functions defined. >>> Is there something I am missing or doing wrong in my steps. >>> >>> Thanks >>> >>> >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>> >> >> >> -- >> -- >> Peter >> > >-- -- Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170603/f9f53940/attachment.html>
Thank you that worked in removing the undefined reference errors for the dfsan related functions like __dfsan*. But I make use of some libc functions like printf, and the error persists for such functions: undefined reference to `dfs$printf'. Thanks Thanks and Regards Archa On Sat, Jun 3, 2017 at 12:43 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:> Try passing -relocation-model=pic at step 4. > > Peter > > On Sat, Jun 3, 2017 at 2:19 AM, Archa . <archa91 at gmail.com> wrote: > >> I tried running step 5 with clang -fsanitize=dataflow instead of gcc but >> it gave the following error: >> >> relocation R_X86_64_32 against `desc' can not be used when making a >> shared object; recompile with -fPIC >> error adding symbols: Bad value >> clang-5.0: error: linker command failed with exit code 1 (use -v to see >> invocation) >> >> So I also tried adding -fPIC option at step 1 when converting .c program >> to .bc and still results in same error. Is there anything else I may be >> missing here. >> >> Thanks >> >> >> >> On Fri, Jun 2, 2017 at 9:25 PM, Peter Collingbourne <peter at pcc.me.uk> >> wrote: >> >>> Programs compiled with dfsan require a runtime library in order to work >>> correctly. You will need to link your program with "clang >>> -fsanitize=dataflow". >>> >>> Peter >>> >>> On Fri, Jun 2, 2017 at 12:46 AM, Archa . via llvm-dev < >>> llvm-dev at lists.llvm.org> wrote: >>> >>>> Hi, >>>> >>>> I am trying to instrument a small program with dfsan at IR and then >>>> compile it. But I end up with undefined reference errors. >>>> >>>> Steps taken: >>>> 1.Convert toy program to .bc >>>> 2. IR pass to insert dfsan calls >>>> 3.opt -dfsan on resultant bitcode from step 2 >>>> 4. llc step3.bc -o step4.s >>>> 5. gcc step.s -o step5.o >>>> >>>> I get error "undefined reference to `__dfsan_arg_tls' " and so forth >>>> for all functions defined. >>>> Is there something I am missing or doing wrong in my steps. >>>> >>>> Thanks >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> llvm-dev at lists.llvm.org >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> >>>> >>> >>> >>> -- >>> -- >>> Peter >>> >> >> > > > -- > -- > Peter >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170603/dcc78436/attachment.html>