<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 25, 2014 at 5:41 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-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>On Mon, Feb 24, 2014 at 4:33 PM, Tom Roeder <<a href="mailto:tmroeder@google.com" target="_blank">tmroeder@google.com</a>> wrote:<br>




><br>
> I'm definitely interested in removing the inline asm bits. I'm not<br>
> sure what you mean by a pseudo-plt, though; do you mean hooking into<br>
> the code that generates the Procedure Linkage Table? I really don't<br>
> know much about the LLVM back end, so I'd have to learn how that all<br>
> works in LLVM first.<br>
<br>
</div></div>Either that or using similar functionality. It's definitely more<br>
complicated on the start than using the inline assembly.<br>
<span><font color="#888888"><br>
-eric<br></font></span></blockquote><div><br></div>I've been digging around in the back end for a bit now, trying to figure out the best way to implement the jump-instruction tables; there's already support for jump tables there, but it's a different kind of jump table than the one I want.<div>



<br></div><div>One direction that looks promising to me is to add an intrinsic, something like:<div><br></div><div>declare void @llvm.jump.instr.table.entry(i8*, i8*)</div><div><br></div><div>The first argument would be the original function (the one that gets jumped to in the table), and the second argument is the _JT function declared but not defined by the pass.</div>



<div><br></div><div>Then I can add a custom lowering in each supported architecture that would turn this into a labeled jump instruction something like</div></div><div><br></div><div>  .globl func_JT</div><div>func_JT:</div>



<div>  jmp func@PLT</div><div><br></div><div><br></div><div>The CFI pass would add a special function that would consist only of these intrinsics, one for each jump statement needed by the table, and padded to a power of two using another special intrinsic (something like llvm.undefined.instr) that would lower to an undefined instruction (like ud2 in x86).</div>



<div><br></div><div>I'd appreciate feedback anyone might have about this proposal.</div><div><br></div><div>Thanks,</div><div><br></div><div>Tom </div></div><br></div></div>