23.11.2013 Views

Obfuscation of Abstract Data-Types - Rowan

Obfuscation of Abstract Data-Types - Rowan

Obfuscation of Abstract Data-Types - Rowan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 2. OBFUSCATIONS FOR INTERMEDIATE LANGUAGE 37<br />

M<br />

ThenEdge<br />

ElseEdge<br />

ThenVert<br />

Es<br />

ElseVert<br />

Es<br />

Figure 2.8: Flow graph to build a conditional expression<br />

Next, we create a test C corresponding to i %2 == 0 in the the predicate<br />

is even(I,C) and we create an expression J for the indices <strong>of</strong> the new arrays,<br />

using the predicate index(I,J) (we omit the details <strong>of</strong> these predicates).<br />

Now, we need to create vertices corresponding to the branches <strong>of</strong> the conditional<br />

— the flow graph we want to create is shown in Figure 2.8. To create<br />

the “then” branch, we first obtain a fresh label ThenLab with which we create<br />

a new vertex ThenVert. This vertex needs to contain an instruction B 1 [J] = V<br />

and have the same outgoing edges as N . Then we create a new incoming edge,<br />

ThenEdge, for ThenVert. The construction <strong>of</strong> the “else” branch is similar (we<br />

build the instruction B 2 [J] = V instead).<br />

Finally, we are ready to build a new vertex M which replaces N . This vertex<br />

contains an instruction for the conditional which has label L. The outgoing edges<br />

for this vertex are ThenEdge and ElseEdge.<br />

Replacing uses <strong>of</strong> the original array is slightly easier. Instead <strong>of</strong> manually<br />

building ThenVert and ElseVert we can use the predicate subst to replace A[I]<br />

with B 1 [J] or B 2 [J] as appropriate.<br />

We can adapt this specification for other array splits. In Section 1.3.6, we<br />

defined an array split in terms <strong>of</strong> three functions ch, f 1 and f 2 . The predicate<br />

is even corresponds to the function ch and index corresponds to f 1 and f 2<br />

(which are equal for our example). So by defining a predicate that represents<br />

ch and two predicates for f 1 and f 2 , we can write a specification for any split<br />

that creates two new arrays.<br />

2.3.8 Creating an irreducible flow graph<br />

In Section 2.2.2, we saw how by placing an if statement before a loop we could<br />

create a method with an irreducible control flow graph. Could we specify this<br />

transformation in PLP? The control flow graph that we want to search for is<br />

shown in Figure 2.9 and we would like to place a jump from the node Jump<br />

to the node InLoop. However, in EIL (and IL) we do not have an instruction<br />

corresponding to while; instead we have to identify a loop from the flow graph.<br />

Figure 2.10 contains the logic program that performs this transformation.<br />

The code has two parts: the first finds a suitable loop and the second builds the<br />

jump.<br />

Let us look at the conditions needed to find a loop. First we want to find a

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!