1880 Commits

Author SHA1 Message Date
Ben Gruver
8eb2595f87 Set the oat version based on the api level in AnalysisArguments
This ensures the oat version is set to NOT_ART for api 19 and lower, and
fixes deodexing for those api levels.
2020-02-02 19:26:14 -08:00
Ben Gruver
210e36dc19 Update VersionMap for Android 10 2020-02-02 18:38:24 -08:00
Ben Gruver
c3bbc771f5 Add support for hidden api restrictions to smali and baksmali
The hidden api restrictions are exposed in the smali language as
additional access flags for fields and methods
2020-02-02 16:32:35 -08:00
Ben Gruver
721fffc60e Add support to dexlib2 for writing hidden api restrictions 2020-02-02 16:32:35 -08:00
Ben Gruver
36c94ad653 Add support for reading the new hidden api restrictions in dexlib2 2020-02-02 16:32:35 -08:00
Ben Gruver
1590b4a05e Use HeaderItem.ITEM_SIZE in the new DexBackedDexFile constructor 2020-01-22 16:50:28 -08:00
Huaxin Li
b7a1052c66 Add support for constructing a DexBackedDexFile from a DexBuffer 2020-01-22 16:50:20 -08:00
Ben Gruver
bf65e575a0 Bump the version to 2.3.4 2019-10-02 16:37:23 -07:00
Ben Gruver
b3b8778ef8 Add support for Oat versions up to 173
The only relevant differences are some added/removed fields in the
OatHeader that affect the offsets of some fields we use.
2019-10-02 16:36:26 -07:00
Ben Gruver
539353a85c Use the correct path separator character when looking for classpath entries 2019-10-02 16:34:04 -07:00
Ben Gruver
7f5e1cc633 Bump the version to 2.3.3 2019-09-19 15:13:35 -07:00
Ben Gruver
ae2efe146b Fix lexing regression in certain types of method parameter lists
It was mis-lexing the case when a class descriptor is immediately
followed by a primitive type. The primitive type was being lexed as
PARAM_LIST_OR_ID_PRIMITIVE_TYPE instead of PRIMITIVE_TYPE.

The root cause was due to an incorrect state change. Since the
CLASS_DESCRIPTOR state can be started from within the PARAM_LIST state,
but when the CLASS_DESCRIPTOR state ends it just went back to YYINITIAL,
instead of going back to PARAM_LIST.

This adds a state stack to track these state changes
2019-09-19 15:11:55 -07:00
Ben Gruver
2598dff4b1 Bump the version to v2.3.2 2019-09-17 13:42:15 -07:00
Ben Gruver
b0ebe0b662 Add a lexer test for api 29
This tests that spaces are not supported in simple names and class
descriptors prior to api 30
2019-09-17 13:31:39 -07:00
Ben Gruver
0e5421cacb Fix how quoted simple names are handled in class descriptors
This unifies the handling of simple names between class descriptors and
member names, and ensures that spaces are only allowed for the appropriate
api levels in both cases
2019-09-17 13:31:27 -07:00
Ben Gruver
d762deacc9 Add a hidden command for printing out the lexical tokens of a smali file
This is useful for creating/updating the .tokens file for the lexer tests.
2019-09-17 13:31:22 -07:00
Ulya Trafimovich
209ba3b0a6 Disallow spaces in Simple name prior to the future API level 30. 2019-09-17 13:31:12 -07:00
Ulya Trafimovich
586ec594e2 Allow space characters in SimpleName.
DEX format allows Unicode space characters in SimpleName since version 040.
Allowed space characters include everything in Unicode category 'Zs':

  0x20, 0xa0, 0x1680, 0x2000..0x200a, 0x202f, 0x205f, 0x3000

Smali now supports symtax `method with spaces` (spaces are allowed in
backtick-quoted names).
2019-09-17 13:31:03 -07:00
Ben Gruver
751fe1ce61 Fix Preconditions.checkArrayPayloadElements
The previous implementation did not correctly handle negative numbers.
2019-09-12 11:30:27 -07:00
Ben Gruver
f8d6f15768 Bump the version to v2.3.1 2019-08-28 12:15:05 -07:00
Ben Gruver
cf73ce28fd Fix the getters in ImmutableInstruction45cc 2019-08-28 12:15:05 -07:00
Ben Gruver
519f41e655 Upgrade guava dependency to v27.1
This matches the version currently used in the android master tree
2019-08-28 11:59:00 -07:00
Ben Gruver
4cf7ce758e Fix issue when parsing method handle references 2019-08-26 14:34:55 -07:00
Ben Gruver
14dc37370b Use anonymous inner classes instead of lambdas
The lambdas were causing strange errors when running baksmali on
Android P - e.g. #676
2019-08-26 12:29:10 -07:00
Ben Gruver
3b70c36296 Add better error messages when finding embedded dex files for oat files 2019-08-23 14:19:07 -07:00
Ben Gruver
bdbea44b98 Gracefully handle malformed array payload instructions with element width=0
These get handled as if they had element width=1 and element count=0
2019-08-23 14:04:40 -07:00
Ben Gruver
225a00c768 Use DexBacked* classes for the various sections in DexBackedDexFile 2019-08-23 11:22:13 -07:00
Alex Melkonyan
b044a00353 Fix bug #709 2019-08-23 11:16:30 -07:00
Ben Gruver
3cccf68502 Bump the version to 2.3 2019-08-07 14:49:40 -07:00
Ben Gruver
a29a420d2f Update the version map to reflect the released version of api 28 2019-08-07 14:49:31 -07:00
Ben Gruver
1ac14a1082 Add a workaround for the sym linked vdex files in api 28
In api 28, the vdex files in, e.g. the framework/arm directory are actually
just sym links to a shared vdex file in the framework directory. However,
the sym links use an absolute path, and so they don't resolve correctly in
the loop mounted system image.

As a simple workaround, we'll just search upward one directory in the path
if the vdex file can't be resolved.
2019-08-07 14:12:19 -07:00
Ben Gruver
c639d229c6 Add support for the new debug offset table for cdex files 2019-08-07 14:12:19 -07:00
Ben Gruver
8e4391262d Some dex files are listed in the oat file, but aren't present in the oat/vdex
Oat version 138 introduced the concept of an "uncompressed" dex file, where
the dex file is listed in the oat file, but it's not actually present in
the oat or vdex files, instead, it's in the apk as per usual.

This change makes dexlib2 ignore these files, treating them as if they are
not a part of the oat file.
2019-08-07 14:12:19 -07:00
Ben Gruver
6c110c1d96 Allow '!' as a separator char in embedded dex file names
Newer versions of art seem to use ! instead of : to separate the
inner dex filename from the name of the container containing it.

e.g.
/system/framework/framework.jar!classes2.dex
instead of
/system/framework/framework.jar:classes2.dex
2019-08-07 14:12:19 -07:00
Ben Gruver
732fe07403 Add initial support for cdex files
Loading cdex files is mostly supported, except for the new debug info
structures.

Dumping is somewhat supported, but only when there's a single cdex file
in the vdex.
2019-08-07 14:12:19 -07:00
Ben Gruver
eb3ab41fb1 Refactor CodeItem in preparation for cdex implementation
This extracts out the SectionAnnotator implementation into a named class,
which can be overridden by the cdex implementation
2019-08-07 14:05:34 -07:00
Ben Gruver
927a8b3c7c Refactor DexBackedDexFile in preparation for cdex implementation
This pulls out some of the functionality into protected methods that can
be overrided by the cdex implementation
2019-08-07 14:05:34 -07:00
Ben Gruver
dc79917ece Refactor DexBackedMethodImplementation in preparation for the cdex implementation
This pulls out some of the operations into protected methods, to be
overridden in the cdex implementation.
2019-08-07 14:05:34 -07:00
Ben Gruver
862c767d58 Let a section override how it calculates the item offsets
This will be needed for the cdex code_item section, whose format doesn't
allow direct enumeration like we use for everything else.
2019-08-07 14:05:34 -07:00
Ben Gruver
1eb12ffc68 Continue dumping other sections after an error in one section 2019-08-07 14:05:34 -07:00
Ben Gruver
a1fa38da8d Update all the data offset references to use the data buffer 2019-08-07 14:05:34 -07:00
Ben Gruver
587efc71dd Add a separate data buffer for DexBackedDexFile
For cdex files, offsets into the data section are specified relative to
the start of the data section, instead of relative to the start of the dex
file.

This adds a separate data buffer that can be used to resolve these
references.
2019-08-07 14:05:34 -07:00
Ben Gruver
52087a0c7c Add support for dumping dex files that begin at some offset within a file 2019-08-07 14:05:34 -07:00
Ben Gruver
783943ebff Change OatFile to return DexBackedDexFiles, instead of OatDexFiles 2019-08-07 14:05:34 -07:00
Ben Gruver
1a52897373 Delete RawDexFile
This was a thin wrapper around DexBackedDexFile that really had no purpose
itself.
2019-08-07 14:05:34 -07:00
Ben Gruver
906f4d67c1 Decouple the DexEntry for MultiDexContainer
Instead of having a DexFile subclass that extends DexEntry, it's now a
separate entity, which returns the associated dex file.
2019-08-07 14:05:34 -07:00
Ben Gruver
f8e5be6afe Decouple BaseDexBuffer from DexBackedDexFile
Instead of having DexBackedDexFile extend BaseDexBuffer itself, it is now a
separate class, and can be accessed via DexBackedDexFile.getBuffer()
2019-08-07 14:05:34 -07:00
Ben Gruver
8faa4b31ec Refactor how information about indexed items are exposed in DexBackedDexFile
This adds a unified IndexedSection/OptionalIndexedSection class for
all indexed items
2019-08-07 14:05:34 -07:00
Ben Gruver
2412f1f741 Remove isOdexFile, and rename hasOdexOpcodes to supportsOptimizedOpcodes
isOdexFile was no longer being used, and hasOdexOpcodes had a slightly
misleading name, since it could potentially return true for an odex or
oat embedded dex file that didn't actually have any odex opcodes.
2019-08-07 14:05:34 -07:00
Ben Gruver
4eb5e48578 Improve how invalid references are handled
This adds a validateReference() method to the Reference interface, where
subclasses can check themselves and throw an InvalidReferenceException
2019-08-07 14:05:34 -07:00