Add "support" for odexed instructions using Format3rms

Also, change the name of the invoke-*-range-quick opcodes to invoke-*-quick/range,
to be consistent with the naming scheme of non-odexed opcodes

git-svn-id: https://smali.googlecode.com/svn/trunk@542 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com
2010-01-01 22:35:35 +00:00
parent f322260c22
commit c9c2ec3d48
5 changed files with 30 additions and 12 deletions

View File

@ -53,8 +53,8 @@ public class UnresolvedNullReferenceMethodItem extends InstructionFormatMethodIt
template.setAttribute("Register", formatRegister(instruction.ObjectRegisterNum));
switch (instruction.OriginalInstruction.opcode)
{
case INVOKE_VIRTUAL_RANGE_QUICK:
case INVOKE_SUPER_RANGE_QUICK:
case INVOKE_VIRTUAL_QUICK_RANGE:
case INVOKE_SUPER_QUICK_RANGE:
template.setAttribute("UseInvokeRange", 1);
if (isLastInstruction) {
template.setAttribute("AddGoto", 1);

View File

@ -263,10 +263,9 @@ public enum Opcode
IPUT_WIDE_QUICK((byte)0xf6, "iput-wide-quick", ReferenceType.none, Format.Format22cs, true),
IPUT_OBJECT_QUICK((byte)0xf7, "iput-object-quick", ReferenceType.none, Format.Format22cs, true),
INVOKE_VIRTUAL_QUICK((byte)0xf8, "invoke-virtual-quick", ReferenceType.none, Format.Format35ms, true),
INVOKE_VIRTUAL_RANGE_QUICK((byte)0xf9, "invoke-virtual-range-quick", ReferenceType.none, Format.Format3rms, true),
INVOKE_VIRTUAL_QUICK_RANGE((byte)0xf9, "invoke-virtual-quick/range", ReferenceType.none, Format.Format3rms, true),
INVOKE_SUPER_QUICK((byte)0xfa, "invoke-super-quick", ReferenceType.none, Format.Format35ms, true),
INVOKE_SUPER_RANGE_QUICK((byte)0xfb, "invoke-super-range-quick", ReferenceType.none, Format.Format3rms, true);
INVOKE_SUPER_QUICK_RANGE((byte)0xfb, "invoke-super-quick/range", ReferenceType.none, Format.Format3rms, true);
private static Opcode[] opcodesByValue;

View File

@ -126,9 +126,9 @@ public class DeodexUtil {
instructionThrowTable.set(Opcode.IPUT_WIDE_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.IPUT_OBJECT_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_VIRTUAL_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_VIRTUAL_RANGE_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_VIRTUAL_QUICK_RANGE.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_SUPER_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_SUPER_RANGE_QUICK.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_SUPER_QUICK_RANGE.value & 0xFF);
instructionThrowTable.set(Opcode.INVOKE_DIRECT_EMPTY.value & 0xFF);
}
@ -621,7 +621,7 @@ public class DeodexUtil {
}
return true;
}
case INVOKE_VIRTUAL_RANGE_QUICK:
case INVOKE_VIRTUAL_QUICK_RANGE:
{
Instruction3rms ins = ((Instruction3rms)i.instruction);
int registerNum = ins.getStartRegister();
@ -716,7 +716,7 @@ public class DeodexUtil {
}
return true;
}
case INVOKE_SUPER_RANGE_QUICK:
case INVOKE_SUPER_QUICK_RANGE:
{
Instruction3rms ins = ((Instruction3rms)i.instruction);
int registerNum = ins.getStartRegister();
@ -909,8 +909,8 @@ public class DeodexUtil {
case INVOKE_SUPER_QUICK:
objectRegisterNum = ((Instruction35ms)instruction).getRegisterD();
break;
case INVOKE_VIRTUAL_RANGE_QUICK:
case INVOKE_SUPER_RANGE_QUICK:
case INVOKE_VIRTUAL_QUICK_RANGE:
case INVOKE_SUPER_QUICK_RANGE:
objectRegisterNum = ((Instruction3rms)instruction).getStartRegister();
break;
default:

View File

@ -449,7 +449,14 @@ INSTRUCTION_FORMAT3rc_TYPE_PHRASE
WS
REGISTER_RANGE_EMITCHILDREN
WS? COMMA_EMIT WS?
NONVOID_TYPE_DESCRIPTOR_EMITCHILD;
NONVOID_TYPE_DESCRIPTOR_EMITCHILD;
INSTRUCTION_FORMAT3rms_METHOD_PHRASE
: INSTRUCTION_FORMAT3rms_METHOD_EMIT
WS
REGISTER_RANGE_EMITCHILDREN
WS? COMMA_EMIT WS?
VTABLE_OFFSET_EMIT;
INSTRUCTION_FORMAT51l_PHRASE
: INSTRUCTION_FORMAT51l_EMIT
@ -1494,6 +1501,13 @@ fragment INSTRUCTION_FORMAT3rc_TYPE_EMIT
fragment INSTRUCTION_FORMAT3rc_TYPE
: 'filled-new-array/range';
fragment INSTRUCTION_FORMAT3rms_METHOD_EMIT
: INSTRUCTION_FORMAT3rms_METHOD {emit($INSTRUCTION_FORMAT3rms_METHOD, INSTRUCTION_FORMAT3rms_METHOD);};
fragment INSTRUCTION_FORMAT3rms_METHOD
: 'invoke-virtual-quick/range'
| 'invoke-super-quick/range'
;
fragment INSTRUCTION_FORMAT51l_EMIT
: INSTRUCTION_FORMAT51l {emit($INSTRUCTION_FORMAT51l, INSTRUCTION_FORMAT51l);};
INSTRUCTION_FORMAT51l

View File

@ -459,6 +459,11 @@ instruction returns [int size]
| //e.g. filled-new-array/range {v0..v6} I
INSTRUCTION_FORMAT3rc_TYPE OPEN_BRACE register_range CLOSE_BRACE nonvoid_type_descriptor {$size = Format.Format3rc.size;}
-> ^(I_STATEMENT_FORMAT3rc_TYPE[$start, "I_STATEMENT_FORMAT3rc_TYPE"] INSTRUCTION_FORMAT3rc_TYPE register_range nonvoid_type_descriptor)
| //e.g. invoke-virtual-quick/range {v0 .. v10}, vtable@0x14
INSTRUCTION_FORMAT3rms_METHOD OPEN_BRACE register_range CLOSE_BRACE VTABLE_OFFSET
{
throw new OdexedInstructionException(input, $INSTRUCTION_FORMAT3rms_METHOD.text);
}
| //e.g. const-wide v0, 5000000000L
INSTRUCTION_FORMAT51l REGISTER fixed_literal {$size = Format.Format51l.size;}
-> ^(I_STATEMENT_FORMAT51l[$start, "I_STATEMENT_FORMAT51l"] INSTRUCTION_FORMAT51l REGISTER fixed_literal)