mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 09:04:25 +02:00
Implemented verification for if-eq and if-ne
git-svn-id: https://smali.googlecode.com/svn/trunk@583 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
f1a74cea19
commit
aba6bb0bbd
@ -484,6 +484,9 @@ public class MethodAnalyzer {
|
|||||||
case CMPG_DOUBLE:
|
case CMPG_DOUBLE:
|
||||||
case CMP_LONG:
|
case CMP_LONG:
|
||||||
return handleWideCmp(analyzedInstruction);
|
return handleWideCmp(analyzedInstruction);
|
||||||
|
case IF_EQ:
|
||||||
|
case IF_NE:
|
||||||
|
return handleIfEqNe(analyzedInstruction);
|
||||||
}
|
}
|
||||||
assert false;
|
assert false;
|
||||||
return false;
|
return false;
|
||||||
@ -1248,6 +1251,37 @@ public class MethodAnalyzer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean handleIfEqNe(AnalyzedInstruction analyzedInstruction) {
|
||||||
|
TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction;
|
||||||
|
|
||||||
|
RegisterType registerType1 = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterA());
|
||||||
|
assert registerType1 != null;
|
||||||
|
if (registerType1.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterType registerType2 = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB());
|
||||||
|
assert registerType2 != null;
|
||||||
|
if (registerType2.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(
|
||||||
|
(ReferenceCategories.contains(registerType1.category) &&
|
||||||
|
ReferenceCategories.contains(registerType2.category))
|
||||||
|
||
|
||||||
|
(Primitive32BitCategories.contains(registerType1.category) &&
|
||||||
|
Primitive32BitCategories.contains(registerType2.category))
|
||||||
|
)) {
|
||||||
|
|
||||||
|
throw new ValidationException(String.format("%s cannot be used on registers of dissimilar types %s and " +
|
||||||
|
"%s. They must both be a reference type or a primitive 32 bit type.",
|
||||||
|
analyzedInstruction.instruction.opcode.name, registerType1.toString(), registerType2.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void checkRegister(RegisterType registerType, EnumSet validCategories) {
|
private static void checkRegister(RegisterType registerType, EnumSet validCategories) {
|
||||||
if (!validCategories.contains(registerType.category)) {
|
if (!validCategories.contains(registerType.category)) {
|
||||||
//TODO: add expected categories to error message
|
//TODO: add expected categories to error message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user