Hello,
for an university course I am working on a code morphing pass. The idea
is that a random vector gets generated at the entry point of functions
and that vector will be used to randomize the flow of execution.
Alternative flows are built looking at the instructions inside the basic
blocks of the function and for some of them replacing the orginal
instruction with a set of logically equivalent basic blocks.
+---------+
| |
| ... |
+-/-----\-+
+------------+ / \
| ... | +------/-+ +-\-------+
| | => | A1 | | A2 |
| A | | | | |
| ... | +------\-+ +-/-------+
+------------+ \ /
+-\-----/-+
| |
| ... |
+---------+
Just to be more visual :) Instruction A get replaced by the basic blocks
A1 and A2 that contain a sequence of instruction semantically equivalent
to A.
Alternative blocks shold be stored in a configuration file or something
that can be easily changed.
My original idea was to use an XML to store the alternatives using a
lisp like language. For example:
<xor>
<alternative>(xor r1 r2)</alternative>
<alternative>
(and (or register1 register2) (not (and register1 register2)))
</alternative>
</xor>
Parsing the string inside the alternative blocks I should be able to
build basic blocks that contain a sequence of instruction semantically
equivalent to the original one. And here is my question :)
Is there any way of doing this using the LLVM infrastructure in a
simpler or more efficent way?
Thank you for your time.
Best regards
Marco.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130309/cbda974d/attachment.sig>