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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

For a slightly more complicated example, the expression x + 5 (where x is a<br />

local variable) is represented by<br />

expr type(applyatom(add(false,true),<br />

expr type(localvar(sname(“x”)),<br />

int(true,b32)),<br />

expr type(ldc(int(true,b32), 5),<br />

int(true,b32))),<br />

int(true,b32))<br />

The term localvar(sname(“x”)) refers to the local variable x — the seemingly<br />

redundant constructor sname reflects the fact that it is also possible to use a<br />

different constructor to refer to local variables by their position in the method’s<br />

declaration list, although this facility is not used.<br />

The constructor applyatom exists to simplify the relationship between IL<br />

and EIL — the term add(false,true) directly corresponds to the IL instruction<br />

add, which adds the top two items on the stack as signed values without overflow.<br />

Thus, the meaning <strong>of</strong> applyatom can be summarised as: “apply the IL<br />

instruction in the first parameter to the rest <strong>of</strong> the parameters, as if they were<br />

on the stack”.<br />

Finally, it remains to explain how EIL instructions are defined. It is these<br />

that will be used to label the edges and nodes <strong>of</strong> flow graphs. An instruction<br />

is either an expression, a branch or a return statement, combined with a list<br />

<strong>of</strong> labels for that statement using the constructor instr label. For example, the<br />

following defines a conditional branch to the label target:<br />

instr label(“conditional” : nil,<br />

branch(cond(. . .), “target”))<br />

Note that we borrow the notation for lists from functional programming, writing<br />

X : Xs instead <strong>of</strong> [X |Xs]. If the current instruction is an expression, then exp<br />

enclosing an expression would be used in place <strong>of</strong> branch, and similarly return<br />

is used in the case <strong>of</strong> a return statement.<br />

2.3.3 Predicates for EIL<br />

The nodes <strong>of</strong> the flow graph are labelled with the logic term corresponding to<br />

the EIL instruction at that node. In addition, each edge is labelled with the<br />

term <strong>of</strong> the EIL instruction at the node that the edge points to; it is these labels<br />

that are used to solve the existential and universal queries.<br />

The logic language provides primitives to access the relevant label given<br />

a node or an edge — @elabel(E,I) holds if I is the instruction at edge E,<br />

and @vlabel(V ,I) holds if I is the instruction at node V (where @ denotes a<br />

primitive).<br />

We can define the set predicate used in Section 2.3.1 as follows:<br />

set(X,A,E) :−<br />

@elabel(E,instr label( ,exp(expr type(assign(X,A), )))).<br />

Note that we denote unbound variables by using an underscore. It is straightforward<br />

to define def in terms <strong>of</strong> set:<br />

def (X,E) :− set(X, ,E)

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

Saved successfully!

Ooh no, something went wrong!