<br><br><div class="gmail_quote">On Fri Oct 31 2014 at 6:20:02 AM Xiaoguang Wang <<a href="mailto:xgwang09@gmail.com">xgwang09@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 6:28 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><br><div class="gmail_quote"><div><div>On Thu Oct 30 2014 at 2:01:24 PM Xiaoguang Wang <<a href="mailto:xgwang09@gmail.com" target="_blank">xgwang09@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 4:48 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><br><div class="gmail_quote"><div><div>On Thu Oct 30 2014 at 1:16:38 PM Xiaoguang Wang <<a href="mailto:xgwang09@gmail.com" target="_blank">xgwang09@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 30, 2014 at 2:33 PM, Robin Morisset <span dir="ltr"><<a href="mailto:morisset@google.com" target="_blank">morisset@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br><br>From my understanding of the LLVM IR, it is impossible to jump to the middle of a Basic Block, only to its beginning. But there is a splitBasicBlock function that seems like it might be useful to you, to make sure a basic block is starting at the exact place you want to jump.<div><br></div><div>Best regards,</div><div>Robin</div></blockquote><div> </div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Thanks you all! I'm looking at splitBasicBlock and trying to use that.  BTW, is there a way at lower level of LLVM that can implement this functionality? E.g. MCBasicBlock or MCInst?<br><br></div></div></div></div></blockquote><div><br></div></div></div><div>You are unlikely to want to do this at the MC level, maybe the MI level. What are you trying to accomplish? </div><span><font color="#888888"><div><br></div><div>-eric</div></font></span></div>
</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra">Thanks for the answer. I want to construct a table which can jump to the address after a call instruction. And replace the call/ret instructions with that indirection table. So to protect return address on stack.<br><br></div></div></blockquote><div><br></div></div></div><div>An MI level pass will likely work, but you might end up having issues replacing instructions. It'll be some effort though.</div><span><font color="#888888"><div><br></div><div>-eric</div></font></span></div>
</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra">Thanks Eric for your help. I'm reading the function <i>Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF)</i> in lib/Target/X86/X86CodeEmitter.cpp. And I hope this is the place I have to modify for my purpose.<br><br></div></div></blockquote><div><br></div><div>I might make an MI pass and make sure it happens last in the pipeline for this, but I haven't given it a lot of thought.</div><div><br></div><div>-eric </div></div>