|
|
@ -21,8 +21,6 @@ package jode.obfuscator; |
|
|
|
|
|
|
|
|
|
|
|
import jode.AssertError; |
|
|
|
import jode.AssertError; |
|
|
|
import jode.GlobalOptions; |
|
|
|
import jode.GlobalOptions; |
|
|
|
import jode.type.MethodType; |
|
|
|
|
|
|
|
import jode.type.Type; |
|
|
|
|
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.jvm.InterpreterException; |
|
|
|
import jode.jvm.InterpreterException; |
|
|
|
|
|
|
|
|
|
|
@ -236,15 +234,16 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
boolean isStatic, String methodTypeSig, |
|
|
|
boolean isStatic, String methodTypeSig, |
|
|
|
Collection notifyQueue) { |
|
|
|
Collection notifyQueue) { |
|
|
|
|
|
|
|
|
|
|
|
MethodType mt = Type.tMethod(methodTypeSig); |
|
|
|
String[] paramTypes |
|
|
|
|
|
|
|
= TypeSignature.getParameterTypes(methodTypeSig); |
|
|
|
locals = new ConstValue[numLocals]; |
|
|
|
locals = new ConstValue[numLocals]; |
|
|
|
stack = new ConstValue[0]; |
|
|
|
stack = new ConstValue[0]; |
|
|
|
this.notifyQueue = notifyQueue; |
|
|
|
this.notifyQueue = notifyQueue; |
|
|
|
int slot = 0; |
|
|
|
int slot = 0; |
|
|
|
if (!isStatic) |
|
|
|
if (!isStatic) |
|
|
|
locals[slot++] = new ConstValue(1); |
|
|
|
locals[slot++] = new ConstValue(1); |
|
|
|
for (int i=0; i< mt.getParameterTypes().length; i++) { |
|
|
|
for (int i=0; i< paramTypes.length; i++) { |
|
|
|
int stackSize = mt.getParameterTypes()[i].stackSize(); |
|
|
|
int stackSize = TypeSignature.getTypeSize(paramTypes[i]); |
|
|
|
locals[slot] = unknownValue[stackSize-1]; |
|
|
|
locals[slot] = unknownValue[stackSize-1]; |
|
|
|
slot += stackSize; |
|
|
|
slot += stackSize; |
|
|
|
} |
|
|
|
} |
|
|
@ -1150,12 +1149,12 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
FieldIdentifier fi = (FieldIdentifier) canonizeReference(instr); |
|
|
|
FieldIdentifier fi = (FieldIdentifier) canonizeReference(instr); |
|
|
|
int size = (opcode == opc_putstatic) ? 0 : 1; |
|
|
|
int size = (opcode == opc_putstatic) ? 0 : 1; |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
|
|
|
|
size += TypeSignature.getTypeSize(ref.getType()); |
|
|
|
if (fi != null && !fi.isNotConstant()) { |
|
|
|
if (fi != null && !fi.isNotConstant()) { |
|
|
|
fi.setNotConstant(); |
|
|
|
fi.setNotConstant(); |
|
|
|
fieldNotConstant(fi); |
|
|
|
fieldNotConstant(fi); |
|
|
|
} |
|
|
|
} |
|
|
|
Type type = Type.tType(ref.getType()); |
|
|
|
mergeInfo(instr.getNextByAddr(), info.pop(size)); |
|
|
|
mergeInfo(instr.getNextByAddr(), info.pop(size + type.stackSize())); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_getstatic: |
|
|
|
case opc_getstatic: |
|
|
@ -1163,15 +1162,33 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
int size = (opcode == opc_getstatic) ? 0 : 1; |
|
|
|
int size = (opcode == opc_getstatic) ? 0 : 1; |
|
|
|
FieldIdentifier fi = (FieldIdentifier) canonizeReference(instr); |
|
|
|
FieldIdentifier fi = (FieldIdentifier) canonizeReference(instr); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Type type = Type.tType(ref.getType()); |
|
|
|
int typesize = TypeSignature.getTypeSize(ref.getType()); |
|
|
|
if (fi != null) { |
|
|
|
if (fi != null) { |
|
|
|
if (fi.isNotConstant()) { |
|
|
|
if (fi.isNotConstant()) { |
|
|
|
fi.setReachable(); |
|
|
|
fi.setReachable(); |
|
|
|
result = unknownValue[type.stackSize()-1]; |
|
|
|
result = unknownValue[typesize - 1]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Object obj = fi.getConstant(); |
|
|
|
Object obj = fi.getConstant(); |
|
|
|
if (obj == null) |
|
|
|
if (obj == null) { |
|
|
|
obj = type.getDefaultValue(); |
|
|
|
switch (ref.getType().charAt(0)) { |
|
|
|
|
|
|
|
case 'Z': |
|
|
|
|
|
|
|
case 'B': |
|
|
|
|
|
|
|
case 'S': |
|
|
|
|
|
|
|
case 'C': |
|
|
|
|
|
|
|
case 'I': |
|
|
|
|
|
|
|
obj = new Integer(0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'J': |
|
|
|
|
|
|
|
obj = new Long(0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'F': |
|
|
|
|
|
|
|
obj = new Float(0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'D': |
|
|
|
|
|
|
|
obj = new Double(0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
ConstantInfo shortInfo = new ConstantInfo(); |
|
|
|
ConstantInfo shortInfo = new ConstantInfo(); |
|
|
|
constInfos.put(instr, shortInfo); |
|
|
|
constInfos.put(instr, shortInfo); |
|
|
|
shortInfo.flags |= CONSTANT; |
|
|
|
shortInfo.flags |= CONSTANT; |
|
|
@ -1181,7 +1198,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
fi.addFieldListener(fieldListener); |
|
|
|
fi.addFieldListener(fieldListener); |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|
result = unknownValue[type.stackSize()-1]; |
|
|
|
result = unknownValue[typesize - 1]; |
|
|
|
mergeInfo(instr.getNextByAddr(), info.poppush(size, result)); |
|
|
|
mergeInfo(instr.getNextByAddr(), info.poppush(size, result)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1204,7 +1221,7 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
size += TypeSignature.getTypeSize(paramTypes[i]); |
|
|
|
size += TypeSignature.getTypeSize(paramTypes[i]); |
|
|
|
Object value = (argValues[i] = info.getStack(size)).value; |
|
|
|
Object value = (argValues[i] = info.getStack(size)).value; |
|
|
|
if (value != ConstValue.VOLATILE) |
|
|
|
if (value != ConstValue.VOLATILE) |
|
|
|
arg[i] = value; |
|
|
|
args[i] = value; |
|
|
|
else |
|
|
|
else |
|
|
|
constant = false; |
|
|
|
constant = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -1251,7 +1268,8 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
if (!constant) { |
|
|
|
if (!constant) { |
|
|
|
handleReference(ref, opcode == opc_invokevirtual |
|
|
|
handleReference(ref, opcode == opc_invokevirtual |
|
|
|
|| opcode == opc_invokeinterface); |
|
|
|
|| opcode == opc_invokeinterface); |
|
|
|
returnVal = unknownValue[mt.getReturnType().stackSize()-1]; |
|
|
|
int retsize = TypeSignature.getTypeSize(retType); |
|
|
|
|
|
|
|
returnVal = unknownValue[retsize - 1]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ConstantInfo shortInfo = new ConstantInfo(); |
|
|
|
ConstantInfo shortInfo = new ConstantInfo(); |
|
|
|
constInfos.put(instr, shortInfo); |
|
|
|
constInfos.put(instr, shortInfo); |
|
|
@ -1432,8 +1450,8 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putfield: |
|
|
|
case opc_putfield: |
|
|
|
if (Type.tType(instr.getReference().getType()) |
|
|
|
if (TypeSignature |
|
|
|
.stackSize() == 2) { |
|
|
|
.getTypeSize(instr.getReference().getType()) == 2) { |
|
|
|
iter.set(new Instruction(opc_pop2)); |
|
|
|
iter.set(new Instruction(opc_pop2)); |
|
|
|
if (instr.getOpcode() == opc_putfield) |
|
|
|
if (instr.getOpcode() == opc_putfield) |
|
|
|
iter.add(new Instruction(opc_pop)); |
|
|
|
iter.add(new Instruction(opc_pop)); |
|
|
@ -1446,13 +1464,13 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
case opc_invokeinterface: |
|
|
|
case opc_invokeinterface: |
|
|
|
case opc_invokevirtual: { |
|
|
|
case opc_invokevirtual: { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
MethodType mt = (MethodType) Type.tType(ref.getType()); |
|
|
|
String[] pt = TypeSignature.getParameterTypes(ref.getType()); |
|
|
|
Type[] pt = mt.getParameterTypes(); |
|
|
|
|
|
|
|
int arg = 0; |
|
|
|
int arg = 0; |
|
|
|
if (instr.getOpcode() != opc_invokestatic) |
|
|
|
if (instr.getOpcode() != opc_invokestatic) |
|
|
|
iter.set(new Instruction(opc_pop)); |
|
|
|
iter.set(new Instruction(opc_pop)); |
|
|
|
else if (pt.length > 0) { |
|
|
|
else if (pt.length > 0) { |
|
|
|
iter.set(new Instruction(pt[0].stackSize() + opc_pop - 1)); |
|
|
|
iter.set(new Instruction(TypeSignature.getTypeSize(pt[0]) |
|
|
|
|
|
|
|
+ opc_pop - 1)); |
|
|
|
arg++; |
|
|
|
arg++; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (replacement == null) |
|
|
|
if (replacement == null) |
|
|
@ -1463,7 +1481,8 @@ public class ConstantAnalyzer implements Opcodes, CodeAnalyzer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i=arg; i < pt.length; i++) |
|
|
|
for (int i=arg; i < pt.length; i++) |
|
|
|
iter.add(new Instruction(pt[i].stackSize() + opc_pop - 1)); |
|
|
|
iter.add(new Instruction(TypeSignature.getTypeSize(pt[i]) |
|
|
|
|
|
|
|
+ opc_pop - 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (replacement != null) |
|
|
|
if (replacement != null) |
|
|
|