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 35<br />

replace var (OldVar,<br />

NewVar,<br />

replace vertex(OldVert,NewVert) : nil<br />

) :−<br />

exists ({ }∗ ;<br />

{ ′ set(OldVar,OldVal)}<br />

) (entry,OldVert),<br />

list<strong>of</strong> (OldEdge,source(OldVert,OldEdge),OldEdges),<br />

@vlabel(OldVert,instr label(Labels, )),<br />

assign fn(OldVal,NewVal),<br />

build assign(Labels,NewVar,NewVal,OldEdges,NewVert).<br />

build assign(Labs,L,R,Edges,Vert) :−<br />

@new vertex(instr label(Labs,exp(expr type(assign(L,R),<br />

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

Edges,Vert).<br />

Figure 2.6: Predicates for replacing assignments<br />

Finding a suitable array<br />

We need to find a vertex InitVert which has an array initialisation <strong>of</strong> the form:<br />

OldArray := newarr(Type)[Size]<br />

where OldArray is a local variable <strong>of</strong> array type.<br />

For this transformation to be applicable, we ensure that every path through<br />

our method goes through InitVert and that the array is always used with its<br />

index (except at the initialisation) — so for example, we cannot pass the whole<br />

array to another method. We can write this safety condition as follows:<br />

safe to transform(InitVert,OldArray) :−<br />

all ({ }∗ ;<br />

{ ′ isnode(InitVert) } ;<br />

{ not( ′ unindexed(OldArray)) }∗<br />

) (entry,exit).<br />

The predicate unindexed(OldArray,E) holds if OldArray is used without an<br />

index at the node pointed to by edge E. We define unindexed by pattern<br />

matching to EIL expressions. So, for example:<br />

unindexed(A,A).<br />

unindexed(exp(E),A) :− unindexed(E,A).<br />

unindexed(expr type(E,T),A) :− unindexed(E,A).<br />

unindexed(arrayindex(L,R),A) :− not(L = A), unindexed(L,A).<br />

unindexed(arrayindex(L,R),A) :− unindexed(R,A).<br />

After a suitable array has been found we need to create initialisations for<br />

our two new arrays with the correct sizes.

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

Saved successfully!

Ooh no, something went wrong!