Tom, this sounds awesome. I'm imagining a wonderful world of CFI hardened browsers. On Mon, Feb 10, 2014 at 5:19 PM, Eric Christopher <echristo at gmail.com>wrote:> > 1. creates a power-of-two sized InlineAsm jump table (or multiple > > jump tables) filled with jump instructions to each address-taken > > function. > > > > Why inline asm? There's probably a better way to do this via lowering > your jump table in the backend etc. >IIRC this came up before, and I don't think we expose anything like a jump table at the IR level. As an IR-to-IR transform, I think asm is the only way to do it. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140210/8fc438b1/attachment.html>
On Mon, Feb 10, 2014 at 11:51 PM, Reid Kleckner <rnk at google.com> wrote:> Tom, this sounds awesome. I'm imagining a wonderful world of CFI hardened > browsers. > > On Mon, Feb 10, 2014 at 5:19 PM, Eric Christopher <echristo at gmail.com> > wrote: >> >> > 1. creates a power-of-two sized InlineAsm jump table (or multiple >> > jump tables) filled with jump instructions to each address-taken >> > function. >> > >> >> Why inline asm? There's probably a better way to do this via lowering >> your jump table in the backend etc. > > > IIRC this came up before, and I don't think we expose anything like a jump > table at the IR level. As an IR-to-IR transform, I think asm is the only > way to do it.I'd have to look more at what he's doing, but wouldn't a simple switch statement in IR suffice? Efficiency would be up to the various lowering mechanisms, but it wouldn't require inline asm. -eric
On 11 Feb 2014, at 08:15, Eric Christopher <echristo at gmail.com> wrote:> On Mon, Feb 10, 2014 at 11:51 PM, Reid Kleckner <rnk at google.com> wrote: >> >> >> >> IIRC this came up before, and I don't think we expose anything like a jump >> table at the IR level. As an IR-to-IR transform, I think asm is the only >> way to do it. > > I'd have to look more at what he's doing, but wouldn't a simple switch > statement in IR suffice? Efficiency would be up to the various > lowering mechanisms, but it wouldn't require inline asm. > > -ericAnother option might be to create an array of function pointers in the LLVM IR, i.e generate code that looks like: void (*jumptable[])() = { &a, &b }; void f(int index) { *(jumptable[index])(); }