mirror of
https://github.com/revanced/smali.git
synced 2025-05-06 09:24:33 +02:00
Add support for Format41c (type references)
This commit is contained in:
parent
d064d69992
commit
d12c769276
@ -100,6 +100,7 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
||||
return true;
|
||||
case Format21c:
|
||||
case Format31c:
|
||||
case Format41c:
|
||||
writeOpcode(writer);
|
||||
writer.write(' ');
|
||||
writeFirstRegister(writer);
|
||||
|
@ -61,6 +61,7 @@ public enum Format {
|
||||
Format3rc(Instruction3rc.Factory, 6),
|
||||
Format3rmi(Instruction3rmi.Factory, 6),
|
||||
Format3rms(Instruction3rms.Factory, 6),
|
||||
Format41c(Instruction41c.Factory, 8),
|
||||
Format51l(Instruction51l.Factory, 10),
|
||||
ArrayData(null, -1, true),
|
||||
PackedSwitchData(null, -1, true),
|
||||
|
@ -71,8 +71,8 @@ public class Instruction21c extends InstructionWithReference implements SingleRe
|
||||
}
|
||||
|
||||
protected void writeInstruction(AnnotatedOutput out, int currentCodeAddress) {
|
||||
if(opcode == Opcode.CONST_STRING && getReferencedItem().getIndex() > 0xFFFF) {
|
||||
throw new RuntimeException("String offset is too large for const-string. Use string-const/jumbo instead.");
|
||||
if(getReferencedItem().getIndex() > 0xFFFF) {
|
||||
throw new RuntimeException(String.format("%s index is too large. Use the %s/jumbo instruction instead.", opcode.referenceType.name(), opcode.name));
|
||||
}
|
||||
|
||||
out.writeByte(opcode.value);
|
||||
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2011, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.jf.dexlib.Code.Format;
|
||||
|
||||
import org.jf.dexlib.Code.Instruction;
|
||||
import org.jf.dexlib.Code.InstructionWithReference;
|
||||
import org.jf.dexlib.Code.Opcode;
|
||||
import org.jf.dexlib.Code.SingleRegisterInstruction;
|
||||
import org.jf.dexlib.DexFile;
|
||||
import org.jf.dexlib.Item;
|
||||
import org.jf.dexlib.TypeIdItem;
|
||||
import org.jf.dexlib.Util.AnnotatedOutput;
|
||||
import org.jf.dexlib.Util.NumberUtils;
|
||||
|
||||
public class Instruction41c extends InstructionWithJumboReference implements SingleRegisterInstruction {
|
||||
public static final InstructionFactory Factory = new Factory();
|
||||
private short regA;
|
||||
|
||||
public Instruction41c(Opcode opcode, int regA, Item referencedItem) {
|
||||
super(opcode, referencedItem);
|
||||
|
||||
if (regA >= 1 << 16) {
|
||||
throw new RuntimeException("The register number must be less than v65536");
|
||||
}
|
||||
|
||||
if (opcode == Opcode.NEW_INSTANCE_JUMBO) {
|
||||
assert referencedItem instanceof TypeIdItem;
|
||||
if (((TypeIdItem)referencedItem).getTypeDescriptor().charAt(0) != 'L') {
|
||||
throw new RuntimeException("Only class references can be used with the new-instance/jumbo opcode");
|
||||
}
|
||||
}
|
||||
|
||||
this.regA = (short)regA;
|
||||
}
|
||||
|
||||
private Instruction41c(DexFile dexFile, Opcode opcode, byte[] buffer, int bufferIndex) {
|
||||
super(dexFile, opcode, buffer, bufferIndex);
|
||||
|
||||
if (opcode == Opcode.NEW_INSTANCE_JUMBO &&
|
||||
((TypeIdItem)this.getReferencedItem()).getTypeDescriptor().charAt(0) != 'L') {
|
||||
|
||||
throw new RuntimeException("Only class references can be used with the new-instance/jumbo opcode");
|
||||
}
|
||||
|
||||
this.regA = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 6);
|
||||
}
|
||||
|
||||
protected void writeInstruction(AnnotatedOutput out, int currentCodeAddress) {
|
||||
out.writeByte(0xFF);
|
||||
out.writeByte(opcode.value);
|
||||
out.writeInt(getReferencedItem().getIndex());
|
||||
out.writeShort(getRegisterA());
|
||||
}
|
||||
|
||||
public Format getFormat() {
|
||||
return Format.Format41c;
|
||||
}
|
||||
|
||||
public int getRegisterA() {
|
||||
return regA & 0xFFFF;
|
||||
}
|
||||
|
||||
private static class Factory implements InstructionFactory {
|
||||
public Instruction makeInstruction(DexFile dexFile, Opcode opcode, byte[] buffer, int bufferIndex) {
|
||||
return new Instruction41c(dexFile, opcode, buffer, bufferIndex);
|
||||
}
|
||||
}
|
||||
}
|
@ -280,8 +280,11 @@ public enum Opcode
|
||||
|
||||
IPUT_OBJECT_VOLATILE((short)0xfc, "iput-object-volatile", ReferenceType.field, Format.Format22c, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE),
|
||||
SGET_OBJECT_VOLATILE((short)0xfd, "sget-object-volatile", ReferenceType.field, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
|
||||
SPUT_OBJECT_VOLATILE((short)0xfe, "sput-object-volatile", ReferenceType.field, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE);
|
||||
SPUT_OBJECT_VOLATILE((short)0xfe, "sput-object-volatile", ReferenceType.field, Format.Format21c, Opcode.ODEX_ONLY | Opcode.ODEXED_STATIC_VOLATILE | Opcode.CAN_THROW | Opcode.CAN_CONTINUE),
|
||||
|
||||
CONST_CLASS_JUMBO((short)0xff00, "const-class/jumbo", ReferenceType.type, Format.Format41c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
|
||||
CHECK_CAST_JUMBO((short)0xff01, "check-cast/jumbo", ReferenceType.type, Format.Format41c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
|
||||
NEW_INSTANCE_JUMBO((short)0xff03, "new-instance/jumbo", ReferenceType.type, Format.Format41c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER);
|
||||
|
||||
private static Opcode[] opcodesByValue;
|
||||
private static Opcode[] expandedOpcodesByValue;
|
||||
|
@ -39,6 +39,17 @@
|
||||
<dumpFile>target/jumbo-string-tests/classes.dump</dumpFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jumbo-type-tests</id>
|
||||
<goals>
|
||||
<goal>assemble</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/test/smali/jumbo-type-tests</sourceDirectory>
|
||||
<outputFile>target/jumbo-type-tests/classes.dex</outputFile>
|
||||
<dumpFile>target/jumbo-type-tests/classes.dump</dumpFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -72,6 +83,20 @@
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jumbo-type-tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<finalName>jumbo-type-tests</finalName>
|
||||
<descriptors>
|
||||
<descriptor>src/assemble/jumbo-type-tests.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -100,6 +125,17 @@
|
||||
<destinationFileOrDirectory>/data/local/jumbo-string-tests.zip</destinationFileOrDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jumbo-type-tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFileOrDirectory>${project.build.directory}/jumbo-type-tests.zip</sourceFileOrDirectory>
|
||||
<destinationFileOrDirectory>/data/local/jumbo-type-tests.zip</destinationFileOrDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -143,6 +179,24 @@
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jumbo-type-tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>adb</executable>
|
||||
<arguments>
|
||||
<argument>shell</argument>
|
||||
<argument>dalvikvm</argument>
|
||||
<argument>-cp</argument>
|
||||
<argument>/data/local/junit-4.6.zip:/data/local/jumbo-type-tests.zip</argument>
|
||||
<argument>org/junit/runner/JUnitCore</argument>
|
||||
<argument>AllTests</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
13
smali-integration-tests/src/assemble/jumbo-type-tests.xml
Normal file
13
smali-integration-tests/src/assemble/jumbo-type-tests.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<assembly>
|
||||
<id>zip</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/jumbo-type-tests/classes.dex</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
@ -0,0 +1,170 @@
|
||||
#Copyright 2011, Google Inc.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
#met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
#notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
#copyright notice, this list of conditions and the following disclaimer
|
||||
#in the documentation and/or other materials provided with the
|
||||
#distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
#contributors may be used to endorse or promote products derived from
|
||||
#this software without specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
.class public LFormat41c;
|
||||
.super Ljava/lang/Object;
|
||||
.source "Format41c.smali"
|
||||
|
||||
.method public constructor <init>()V
|
||||
.registers 1
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public test_const-class-jumbo()V
|
||||
.registers 9
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
const-class/jumbo v0, Lzzz99999;
|
||||
invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
|
||||
move-result-object v0
|
||||
|
||||
#check for the initial 3 z's
|
||||
const v1, 3
|
||||
const v2, 0
|
||||
const-wide v3, 'z'
|
||||
|
||||
:loop
|
||||
invoke-virtual {v0, v2}, Ljava/lang/String;->charAt(I)C
|
||||
move-result v5
|
||||
|
||||
int-to-long v6, v5
|
||||
|
||||
invoke-static {v3, v4, v6, v7}, Lorg/junit/Assert;->assertEquals(JJ)V
|
||||
|
||||
add-int/lit8 v2, v2, 1
|
||||
if-ne v1, v2, :loop
|
||||
|
||||
#and now for the final 9's
|
||||
invoke-virtual {v0}, Ljava/lang/String;->length()I
|
||||
move-result v1
|
||||
const-wide v3, '9'
|
||||
|
||||
:loop2
|
||||
invoke-virtual {v0, v2}, Ljava/lang/String;->charAt(I)C
|
||||
move-result v5
|
||||
|
||||
int-to-long v6, v5
|
||||
|
||||
invoke-static {v3, v4, v6, v7}, Lorg/junit/Assert;->assertEquals(JJ)V
|
||||
|
||||
add-int/lit8 v2, v2, 1
|
||||
if-ne v1, v2, :loop2
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public test_new-instance-jumbo-index()V
|
||||
.registers 3
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
new-instance/jumbo v1, Lzzz99999;
|
||||
|
||||
#there's no way to initialize the new object, due to type index constraints on a method_id_item
|
||||
#so just attempt to create the new object and call it good
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public test_new-instance-jumbo-register()V
|
||||
.registers 257
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
const-string v0, "test"
|
||||
|
||||
#test using a large register
|
||||
new-instance/jumbo v256, LStringWrapper;
|
||||
move-object/16 v1, v256
|
||||
|
||||
invoke-direct {v1, v0}, LStringWrapper;-><init>(Ljava/lang/String;)V
|
||||
|
||||
invoke-virtual {v1}, LStringWrapper;->getValue()Ljava/lang/String;
|
||||
move-result-object v2
|
||||
|
||||
invoke-static {v0, v2}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public test_check-cast-jumbo-fail()V
|
||||
.registers 2
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
:tryStart
|
||||
const-string v0, "test"
|
||||
|
||||
check-cast/jumbo v0, Lzzz99999;
|
||||
:tryEnd
|
||||
.catch Ljava/lang/ClassCastException; {:tryStart .. :tryEnd} :handler
|
||||
|
||||
#the check-cast didn't throw an exception as expected
|
||||
invoke-static {}, Lorg/junit/Assert;->fail()V
|
||||
|
||||
:handler
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
#there's no way to just a successful check-cast/jumbo with a jumbo type, because
|
||||
#it's impossible to create a class that is a subclass of a "jumbo" class, and
|
||||
#it's impossible to define a class that implements a "jumbo" interface
|
||||
#.method public test_check-cast-jumbo-success()V
|
||||
|
||||
.method public test_check-cast-success-jumbo-register()V
|
||||
.registers 257
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
const-string v0, "test"
|
||||
|
||||
:tryStart
|
||||
new-instance/jumbo v256, LStringWrapper;
|
||||
move-object/16 v1, v256
|
||||
|
||||
invoke-direct {v1, v0}, LStringWrapper;-><init>(Ljava/lang/String;)V
|
||||
|
||||
check-cast/jumbo v256, Ljava/lang/Object;
|
||||
:tryEnd
|
||||
.catch Ljava/lang/ClassCastException; {:tryStart .. :tryEnd} :handler
|
||||
|
||||
#no exception. success
|
||||
|
||||
return-void
|
||||
|
||||
:handler
|
||||
|
||||
#the check-cast unexpectedly threw an exception
|
||||
invoke-static {}, Lorg/junit/Assert;->fail()V
|
||||
return-void
|
||||
.end method
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
.class public LStringWrapper;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
#the type_id_item index for this class should be <64k
|
||||
|
||||
.field private stringValue:Ljava/lang/String;
|
||||
|
||||
.method public constructor <init>()V
|
||||
.registers 2
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
const-string v0, "test"
|
||||
|
||||
iput-object v0, p0, LStringWrapper;->stringValue:Ljava/lang/String;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public constructor <init>(Ljava/lang/String;)V
|
||||
.registers 2
|
||||
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
iput-object p1, p0, LStringWrapper;->stringValue:Ljava/lang/String;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public getValue()Ljava/lang/String;
|
||||
.registers 2
|
||||
|
||||
iget-object v0, p0, LStringWrapper;->stringValue:Ljava/lang/String;
|
||||
|
||||
return-object v0
|
||||
.end method
|
@ -0,0 +1,39 @@
|
||||
#Copyright 2011, Google Inc.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
#met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
#notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
#copyright notice, this list of conditions and the following disclaimer
|
||||
#in the documentation and/or other materials provided with the
|
||||
#distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
#contributors may be used to endorse or promote products derived from
|
||||
#this software without specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
.class public LAllTests;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.annotation runtime Lorg/junit/runner/RunWith;
|
||||
value = Lorg/junit/runners/Suite;
|
||||
.end annotation
|
||||
|
||||
.annotation runtime Lorg/junit/runners/Suite$SuiteClasses;
|
||||
value = { LFormat41c; }
|
||||
.end annotation
|
@ -0,0 +1,38 @@
|
||||
#Copyright 2011, Google Inc.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
#met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
#notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
#copyright notice, this list of conditions and the following disclaimer
|
||||
#in the documentation and/or other materials provided with the
|
||||
#distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
#contributors may be used to endorse or promote products derived from
|
||||
#this software without specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
.class public Lzzz99999;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
#The index of the type_id_item for this class should be > 0xffff, to allow
|
||||
#for testing jumbo instructions that reference a type
|
||||
|
||||
#Note that this class can't actually be instantiated, because it's impossible
|
||||
#to call a method on it, due to the limitation of the type_id_item index in
|
||||
#method_id_item
|
@ -690,6 +690,11 @@ INSTRUCTION_FORMAT3rms_METHOD
|
||||
: 'invoke-virtual-quick/range'
|
||||
| 'invoke-super-quick/range';
|
||||
|
||||
INSTRUCTION_FORMAT41c_TYPE
|
||||
: 'check-cast/jumbo'
|
||||
| 'new-instance/jumbo'
|
||||
| 'const-class/jumbo';
|
||||
|
||||
INSTRUCTION_FORMAT51l
|
||||
: 'const-wide';
|
||||
|
||||
|
@ -117,6 +117,7 @@ tokens {
|
||||
I_STATEMENT_FORMAT35c_TYPE;
|
||||
I_STATEMENT_FORMAT3rc_METHOD;
|
||||
I_STATEMENT_FORMAT3rc_TYPE;
|
||||
I_STATEMENT_FORMAT41c_TYPE;
|
||||
I_STATEMENT_FORMAT51l;
|
||||
I_STATEMENT_ARRAY_DATA;
|
||||
I_STATEMENT_PACKED_SWITCH;
|
||||
@ -703,13 +704,14 @@ instruction returns [int size]
|
||||
}
|
||||
}
|
||||
-> ^(I_STATEMENT_FORMAT20bc INSTRUCTION_FORMAT20bc VERIFICATION_ERROR_TYPE verification_error_reference)
|
||||
//TODO: check if dalvik has a jumbo version of throw-verification-error
|
||||
| //e.g. goto/16 endloop:
|
||||
INSTRUCTION_FORMAT20t label_ref_or_offset {$size = Format.Format20t.size;}
|
||||
-> ^(I_STATEMENT_FORMAT20t[$start, "I_STATEMENT_FORMAT20t"] INSTRUCTION_FORMAT20t label_ref_or_offset)
|
||||
| //e.g. sget-object v0 java/lang/System/out LJava/io/PrintStream;
|
||||
| //e.g. sget-object v0, java/lang/System/out LJava/io/PrintStream;
|
||||
INSTRUCTION_FORMAT21c_FIELD REGISTER COMMA fully_qualified_field {$size = Format.Format21c.size;}
|
||||
-> ^(I_STATEMENT_FORMAT21c_FIELD[$start, "I_STATEMENT_FORMAT21c_FIELD"] INSTRUCTION_FORMAT21c_FIELD REGISTER fully_qualified_field)
|
||||
| //e.g. sget-object-volatile v0 java/lang/System/out LJava/io/PrintStream;
|
||||
| //e.g. sget-object-volatile v0, java/lang/System/out LJava/io/PrintStream;
|
||||
INSTRUCTION_FORMAT21c_FIELD_ODEX REGISTER COMMA fully_qualified_field {$size = Format.Format21c.size;}
|
||||
{
|
||||
if (!allowOdex) {
|
||||
@ -717,10 +719,10 @@ instruction returns [int size]
|
||||
}
|
||||
}
|
||||
-> ^(I_STATEMENT_FORMAT21c_FIELD[$start, "I_STATEMENT_FORMAT21c_FIELD"] INSTRUCTION_FORMAT21c_FIELD_ODEX REGISTER fully_qualified_field)
|
||||
| //e.g. const-string v1 "Hello World!"
|
||||
| //e.g. const-string v1, "Hello World!"
|
||||
INSTRUCTION_FORMAT21c_STRING REGISTER COMMA STRING_LITERAL {$size = Format.Format21c.size;}
|
||||
-> ^(I_STATEMENT_FORMAT21c_STRING[$start, "I_STATEMENT_FORMAT21c_STRING"] INSTRUCTION_FORMAT21c_STRING REGISTER STRING_LITERAL)
|
||||
| //e.g. const-class v2 Lorg/jf/HelloWorld2/HelloWorld2;
|
||||
| //e.g. const-class v2, Lorg/jf/HelloWorld2/HelloWorld2;
|
||||
INSTRUCTION_FORMAT21c_TYPE REGISTER COMMA reference_type_descriptor {$size = Format.Format21c.size;}
|
||||
-> ^(I_STATEMENT_FORMAT21c_TYPE[$start, "I_STATEMENT_FORMAT21c"] INSTRUCTION_FORMAT21c_TYPE REGISTER reference_type_descriptor)
|
||||
| //e.g. const/high16 v1, 1234
|
||||
@ -833,6 +835,9 @@ instruction returns [int size]
|
||||
{
|
||||
throwOdexedInstructionException(input, $INSTRUCTION_FORMAT3rms_METHOD.text);
|
||||
}
|
||||
| //e.g. const-class/jumbo v2, Lorg/jf/HelloWorld2/HelloWorld2;
|
||||
INSTRUCTION_FORMAT41c_TYPE REGISTER COMMA reference_type_descriptor {$size = Format.Format41c.size;}
|
||||
-> ^(I_STATEMENT_FORMAT41c_TYPE[$start, "I_STATEMENT_FORMAT41c"] INSTRUCTION_FORMAT41c_TYPE REGISTER reference_type_descriptor)
|
||||
| //e.g. const-wide v0, 5000000000L
|
||||
INSTRUCTION_FORMAT51l REGISTER COMMA fixed_literal {$size = Format.Format51l.size;}
|
||||
-> ^(I_STATEMENT_FORMAT51l[$start, "I_STATEMENT_FORMAT51l"] INSTRUCTION_FORMAT51l REGISTER fixed_literal)
|
||||
|
@ -998,7 +998,7 @@ instruction[int totalMethodRegisters, int methodParameterRegisters, List<Instruc
|
||||
|
||||
$instructions.add(new Instruction20t(opcode, addressOffset));
|
||||
}
|
||||
| //e.g. sget_object v0 java/lang/System/out LJava/io/PrintStream;
|
||||
| //e.g. sget_object v0, java/lang/System/out LJava/io/PrintStream;
|
||||
^(I_STATEMENT_FORMAT21c_FIELD inst=(INSTRUCTION_FORMAT21c_FIELD | INSTRUCTION_FORMAT21c_FIELD_ODEX) REGISTER fully_qualified_field)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($inst.text);
|
||||
@ -1008,7 +1008,7 @@ instruction[int totalMethodRegisters, int methodParameterRegisters, List<Instruc
|
||||
|
||||
$instructions.add(new Instruction21c(opcode, regA, fieldIdItem));
|
||||
}
|
||||
| //e.g. const-string v1 "Hello World!"
|
||||
| //e.g. const-string v1, "Hello World!"
|
||||
^(I_STATEMENT_FORMAT21c_STRING INSTRUCTION_FORMAT21c_STRING REGISTER string_literal)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT21c_STRING.text);
|
||||
@ -1018,7 +1018,7 @@ instruction[int totalMethodRegisters, int methodParameterRegisters, List<Instruc
|
||||
|
||||
instructions.add(new Instruction21c(opcode, regA, stringIdItem));
|
||||
}
|
||||
| //e.g. const-class v2 org/jf/HelloWorld2/HelloWorld2
|
||||
| //e.g. const-class v2, org/jf/HelloWorld2/HelloWorld2
|
||||
^(I_STATEMENT_FORMAT21c_TYPE INSTRUCTION_FORMAT21c_TYPE REGISTER reference_type_descriptor)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT21c_TYPE.text);
|
||||
@ -1074,7 +1074,7 @@ instruction[int totalMethodRegisters, int methodParameterRegisters, List<Instruc
|
||||
|
||||
$instructions.add(new Instruction22b(opcode, regA, regB, (byte)litC));
|
||||
}
|
||||
| //e.g. iput-object v1 v0 org/jf/HelloWorld2/HelloWorld2.helloWorld Ljava/lang/String;
|
||||
| //e.g. iput-object v1, v0, org/jf/HelloWorld2/HelloWorld2.helloWorld Ljava/lang/String;
|
||||
^(I_STATEMENT_FORMAT22c_FIELD inst=(INSTRUCTION_FORMAT22c_FIELD | INSTRUCTION_FORMAT22c_FIELD_ODEX) registerA=REGISTER registerB=REGISTER fully_qualified_field)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($inst.text);
|
||||
@ -1249,6 +1249,16 @@ instruction[int totalMethodRegisters, int methodParameterRegisters, List<Instruc
|
||||
|
||||
$instructions.add(new Instruction3rc(opcode, (short)registerCount, startRegister, typeIdItem));
|
||||
}
|
||||
| //e.g. const-class/jumbo v2, org/jf/HelloWorld2/HelloWorld2
|
||||
^(I_STATEMENT_FORMAT41c_TYPE INSTRUCTION_FORMAT41c_TYPE REGISTER reference_type_descriptor)
|
||||
{
|
||||
Opcode opcode = Opcode.getOpcodeByName($INSTRUCTION_FORMAT41c_TYPE.text);
|
||||
int regA = parseRegister_short($REGISTER.text, $totalMethodRegisters, $methodParameterRegisters);
|
||||
|
||||
TypeIdItem typeIdItem = $reference_type_descriptor.type;
|
||||
|
||||
$instructions.add(new Instruction41c(opcode, regA, typeIdItem));
|
||||
}
|
||||
| //e.g. const-wide v0, 5000000000L
|
||||
^(I_STATEMENT_FORMAT51l INSTRUCTION_FORMAT51l REGISTER fixed_64bit_literal)
|
||||
{
|
||||
|
@ -562,6 +562,10 @@ Type = {PrimitiveType} | {ClassDescriptor} | {ArrayDescriptor}
|
||||
return newToken(INSTRUCTION_FORMAT3rms_METHOD);
|
||||
}
|
||||
|
||||
"check-cast/jumbo" | "new-instance/jumbo" | "const-class/jumbo" {
|
||||
return newToken(INSTRUCTION_FORMAT41c_TYPE);
|
||||
}
|
||||
|
||||
"const-wide" {
|
||||
return newToken(INSTRUCTION_FORMAT51l);
|
||||
}
|
||||
|
@ -222,4 +222,7 @@ filled-new-array/range
|
||||
execute-inline/range
|
||||
invoke-virtual-quick/range
|
||||
invoke-super-quick/range
|
||||
check-cast/jumbo
|
||||
new-instance/jumbo
|
||||
const-class/jumbo
|
||||
const-wide
|
@ -222,4 +222,7 @@ INSTRUCTION_FORMAT3rc_TYPE("filled-new-array/range")
|
||||
INSTRUCTION_FORMAT3rmi_METHOD("execute-inline/range")
|
||||
INSTRUCTION_FORMAT3rms_METHOD("invoke-virtual-quick/range")
|
||||
INSTRUCTION_FORMAT3rms_METHOD("invoke-super-quick/range")
|
||||
INSTRUCTION_FORMAT41c_TYPE("check-cast/jumbo")
|
||||
INSTRUCTION_FORMAT41c_TYPE("new-instance/jumbo")
|
||||
INSTRUCTION_FORMAT41c_TYPE("const-class/jumbo")
|
||||
INSTRUCTION_FORMAT51l("const-wide")
|
Loading…
x
Reference in New Issue
Block a user