[LLVMdev] encoded instruction sizes

Tom Roeder tmroeder at google.com
Fri Jul 18 15:07:47 PDT 2014


In code review http://reviews.llvm.org/D4167 for my
ForwardControlFlowIntegrity pass, the question has come up about how to get
instruction encoding length information in a principled manner. I am aware
of MCInstrDesc::getSize(), but when I try this with the relevant
instruction on X86 (JMP_4 to a symbol at PLT), I get 0 back; IIUC, that means
MCInstrDesc can't determine the size.

I need the size information to generate the correct mask for the FCFI code:
it needs to know the size of a jump-instruction table given the number of
jump instructions in the table so that it can create a mask to make sure a
given function pointer is pointing into a table. It would be sufficient for
me to be able to get a reasonable upper bound on the length of the
instruction, too, though a bound that was too loose would mean I would need
to expand the jumptable entry size to match.

I don't know enough about how TableGen works to know if it's possible to
get this information right now or if I'd need to add something else to
enable that. Obviously, the solution of encoding it directly in the backend
as a parameter seems like a non-starter, since it would be duplicating
information in the X86 instruction tables and would be in danger of getting
out of date.

Is there currently any way to get this information from the Targets?

Thanks,

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140718/e81d8881/attachment.html>


More information about the llvm-dev mailing list