<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 7, 2018 at 7:02 PM PenYiWang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<span style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Hi</span><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">I want to trace the code of clang/llvm CFI <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(Control Flow Integrity)</span> mechanism</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">I found that there is ForwardControlFlowIntegrity.cpp in llvm 3.6</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><a href="https://github.com/llvm-mirror/llvm/blob/release_36/lib/CodeGen/ForwardControlFlowIntegrity.cpp" style="color:rgb(17,85,204)" target="_blank">https://github.com/llvm-mirror/llvm/blob/release_36/lib/CodeGen/ForwardControlFlowIntegrity.cpp</a><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">But I don't know which files implement  CFI (Control Flow Integrity)  in later version</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">(1)</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">If I use this command</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">clang-6.0 -fsanitize=cfi-icall -fvisibility=hidden -flto ./test.c<br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">Which files implement CFI ? </div></div></blockquote><div><br></div><div>In that case it would be LowerTypeTests.cpp as well as parts of clang/lib/CodeGen (grep for CFIICall).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">(2)</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">I found these two files</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">but I set break point  in gdb , and didn't find anything</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">(gdb) b llvm::CrossDSOCFI::buildCFICheck<br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><a href="https://github.com/llvm-mirror/llvm/blob/release_60/lib/Transforms/IPO/LowerTypeTests.cpp" style="color:rgb(17,85,204)" target="_blank">https://github.com/llvm-mirror/llvm/blob/release_60/lib/Transforms/IPO/LowerTypeTests.cpp</a><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><a href="https://github.com/llvm-mirror/llvm/blob/release_60/lib/Transforms/IPO/CrossDSOCFI.cpp" style="color:rgb(17,85,204)" target="_blank">https://github.com/llvm-mirror/llvm/blob/release_60/lib/Transforms/IPO/CrossDSOCFI.cpp</a></div></div></blockquote><div><br></div><div>The CrossDSOCFI.cpp file is only involved in implementing cross-DSO CFI (i.e. -fsanitize-cfi-cross-dso). If you don't request cross-DSO CFI only LowerTypeTests.cpp is used.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">(3)</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">What's "MCCFIInstruction" ?</div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">Does it relate to<span> </span><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">CFI (Control Flow Integrity) ?</span></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><a href="http://llvm.org/doxygen/classllvm_1_1MCCFIInstruction.html" style="color:rgb(17,85,204)" target="_blank">http://llvm.org/doxygen/classllvm_1_1MCCFIInstruction.html</a></div></div></blockquote><div><br></div><div>No, that's a different CFI. </div><div><br></div><div>Peter</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:14px;text-decoration-style:initial;text-decoration-color:initial">Thanks</div>

<br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div></div>