Tweak dexlib's "skip instructions" functionality so that it doesn't read in the CodeItems or DebugInfoItems at all

git-svn-id: https://smali.googlecode.com/svn/trunk@635 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2010-02-22 00:56:26 +00:00
parent 2bdbf739bf
commit d79d9ebbe9
3 changed files with 53 additions and 66 deletions

View File

@ -478,8 +478,13 @@ public class ClassDataItem extends Item<ClassDataItem> {
int previousIndex = previousEncodedMethod==null?0:previousEncodedMethod.method.getIndex(); int previousIndex = previousEncodedMethod==null?0:previousEncodedMethod.method.getIndex();
method = dexFile.MethodIdsSection.getItemByIndex(in.readUnsignedLeb128() + previousIndex); method = dexFile.MethodIdsSection.getItemByIndex(in.readUnsignedLeb128() + previousIndex);
accessFlags = in.readUnsignedLeb128(); accessFlags = in.readUnsignedLeb128();
if (dexFile.skipInstructions()) {
in.readUnsignedLeb128();
codeItem = null;
} else {
codeItem = (CodeItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_CODE_ITEM, codeItem = (CodeItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_CODE_ITEM,
in.readUnsignedLeb128()); in.readUnsignedLeb128());
}
if (codeItem != null) { if (codeItem != null) {
codeItem.setParent(this); codeItem.setParent(this);
} }

View File

@ -151,27 +151,6 @@ public class CodeItem extends Item<CodeItem> {
int instructionCount = in.readInt(); int instructionCount = in.readInt();
if (dexFile.skipInstructions()) {
in.skipBytes(instructionCount * 2);
if (triesCount > 0) {
in.alignTo(4);
in.skipBytes(8 * triesCount);
int handlerCount = in.readUnsignedLeb128();
for (int i=0; i<handlerCount; i++) {
int size = in.readSignedLeb128();
int absSize = Math.abs(size);
for (int j=0; j<absSize; j++) {
in.readUnsignedLeb128();
in.readUnsignedLeb128();
}
if (size <= 0) {
in.readUnsignedLeb128();
}
}
}
} else {
final ArrayList<Instruction> instructionList = new ArrayList<Instruction>(); final ArrayList<Instruction> instructionList = new ArrayList<Instruction>();
byte[] encodedInstructions = in.readBytes(instructionCount * 2); byte[] encodedInstructions = in.readBytes(instructionCount * 2);
@ -223,7 +202,6 @@ public class CodeItem extends Item<CodeItem> {
in.setCursor(codeItemEnd); in.setCursor(codeItemEnd);
} }
} }
}
/** {@inheritDoc} */ /** {@inheritDoc} */
protected int placeItem(int offset) { protected int placeItem(int offset) {

View File

@ -409,6 +409,10 @@ public class DexFile
continue; continue;
} }
if (skipInstructions && (section == CodeItemsSection || section == DebugInfoItemsSection)) {
continue;
}
int sectionOffset = readContext.getSectionOffset(section.ItemType); int sectionOffset = readContext.getSectionOffset(section.ItemType);
if (sectionOffset > 0) { if (sectionOffset > 0) {
int sectionSize = readContext.getSectionSize(section.ItemType); int sectionSize = readContext.getSectionSize(section.ItemType);