<br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 2:49 PM, Tom Roeder <span dir="ltr"><<a href="mailto:tmroeder@google.com" target="_blank">tmroeder@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
Thanks for the followup.<br>
<br>
If I understand the suggestion correctly, this doesn't solve the<br>
problem of building a jump table to call into other functions, since,<br>
as you note, indirectbr can only call into blocks in the same<br>
function. Is the conclusion then that there is no way to do this in<br>
LLVM IR? </blockquote><div> </div><div>How about creating a new basic block in the current function and placing a "call" instruction to the desired function call inside it?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
It looks like these kind of restrictions (no branching<br>
between functions and no instructions outside of functions) are<br>
designed into the structure of LLVM IR. Is this correct?<br>
<br>
Thanks,<br>
<br>
Tom<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Jan 3, 2013 at 6:50 AM, Joshua Cranmer <<a href="mailto:pidgeot18@gmail.com">pidgeot18@gmail.com</a>> wrote:<br>
> On 1/2/2013 11:05 AM, Tom Roeder wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I'm currently writing an opt module for fast indirect call checks<br>
>> using a table of allowed indirect call targets. The code replaces<br>
>> function pointers with offsets into the table then masks the offset<br>
>> for the table size and restores the function pointer before the call.<br>
>> I have some ways of dealing with some kinds of external code that are<br>
>> sufficient for my use case but not for more general use.<br>
>><br>
>> I'd like to generalize the table to be a table of jump instructions (a<br>
>> classic jump table) rather than just a table of function pointers,<br>
>> since this would solve some of my problems for the more general cases.<br>
>> I know how to do this using inline assembly in LLVM, but this ties the<br>
>> module to a particular architecture or set of architectures.<br>
>><br>
>> Is there a way to build a table of jump instructions like this in pure<br>
>> LLVM IR? My limited understanding of LLVM says no, and I haven't been<br>
>> able to find a way to do this, but I would appreciate any pointers you<br>
>> can give me.<br>
><br>
><br>
> You can use a jump table using indirectbr, although note that this<br>
> instruction requires you to label all the possible target blocks and that<br>
> the targets can only be blocks in the same function.<br>
><br>
> --<br>
> Joshua Cranmer<br>
> News submodule owner<br>
> DXR coauthor<br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br>