464 Commits

Author SHA1 Message Date
Ben Gruver
41a5b4953c Fix the dump command to work with dex files in an oat file 2016-08-30 22:16:16 -07:00
Ben Gruver
4254a2073a Use a java 6-friendly string joiner 2016-08-27 12:01:35 -07:00
Ben Gruver
3735d4778f Merge branch 'master' into v2.2_WIP 2016-08-27 12:01:22 -07:00
Ben Gruver
7079014a29 Add more error detail when interfaces can't be fully resolved 2016-08-23 11:38:40 -07:00
Narayan Kamath
99b80bbc5a Revert "Add lambda experimental dalvik opcodes"
This reverts commit 144951a9e9e6c87866245f2bdeebf0ebedaa0e38.
2016-08-17 13:15:18 +01:00
Narayan Kamath
afc1f15939 smali/dexlib: deal with invoke-polymorphic / invoke-polymorphic/range.
- Introduces two new instruction formats, 45cc and 4rcc. As the name suggests,
  these instructions are similar to 35c and 3rc, expect that they encode an
  additional constant pool reference in their 4th byte.

- Introduce two new instructions, invoke-polymorphic and
  invoke-polymorphic/range - used to implement signature polymorphism.

- Allow instructions to directly reference the proto_id section of the
  dex file. This involves the introduction of a new kind of reference
  (MethodProtoReference) and has the side effect of cleaning up a fair
  amount of special casing in ProtoPool.

- Disable support for ART version based switches (and remove LambdaTest
  which depends on it). Experimental lambda support and support for ART
  version based switches will be removed in a follow up change.

Bug: 30550796
Test: test-art
Test: ./gradlew build
2016-08-17 13:03:12 +01:00
Ben Gruver
c347e68b46 Allow invalid register references in debug items related to locals.
Art doesn't complain about this, so we shouldn't throw an error when
encountering a dex file with something like this.
2016-07-10 21:35:07 -07:00
Ben Gruver
db49ae1d03 Track register narrowing via instance-of after a move 2016-05-28 18:52:26 -07:00
Ben Gruver
e474301e60 Revamp how classpath loading works 2016-05-28 18:51:42 -07:00
Ben Gruver
f84e0f4562 Fix up some nullness and other minor issues in MethodAnalyzer/AnalyzedInstruction 2016-05-16 16:58:54 -07:00
Ben Gruver
c4948a5c49 Add initial support for N preview odexes 2016-05-16 16:58:54 -07:00
Ben Gruver
bccdc809fa Add "list field offsets" and "list vtables" commands to baksmali
This is a reimplementation of the "DumpFields" and "DumpVtables" entry
points that were previously in dexlib2
2016-05-16 16:58:54 -07:00
Ben Gruver
90cacb9d0d Implement various list commands in baksmali
This adds commands to list strings, methods, fields, types and classes
2016-05-16 16:58:54 -07:00
Ben Gruver
735746595f Implement a new command line interface for smali 2016-05-16 16:58:54 -07:00
Ben Gruver
93100e57b2 Improve how the instance-of + if-eqz/if-nez type propagation works
We now perform the type propagation while analyzing the if-eqz/if-nez
instruction. Additionally, AnalyzedInstruction.setsRegister now has
special case logic to check for this case, so we don't incorrectly
propagate the original type past the if-eqz/if-nez
2016-04-23 14:01:36 -07:00
Ben Gruver
9802cf3428 Propagate the narrowed type for an if-nez after an instance-of 2016-04-23 11:08:21 -07:00
Alex Light
40bbf5c347 Dex version 37 support
Make dexlib able to read and write version 37 dex files.

Bug: 27809626

Change-Id: I3d0ca6201c7abe7763d2fb925e9ee1edbef24230
2016-04-04 11:00:02 -07:00
Ben Gruver
6417e812e1 Refactor ClassPath to take ClassProviders
This allows for a more general mechanism for providing defined classes
2016-02-26 21:13:29 -08:00
Ben Gruver
5b2943d89b Check for switch offset validity in the MethodAnalyzer 2016-02-20 12:04:47 -08:00
Ben Gruver
8533ab7429 Merge branch 'master' into smalidea 2016-02-13 15:43:37 -08:00
Ben Gruver
3e265038f5 Implement support for adding new labels to a MutableMethodImplementation 2015-10-18 13:24:34 -07:00
Ben Gruver
b8e255f389 Add support for 64-bit oat files 2015-10-17 14:47:10 -07:00
Ben Gruver
e202aeede5 Pass in the Opcodes to use for SyntheticAccessorFSM 2015-10-17 13:50:26 -07:00
Ben Gruver
4c66761aea Minor javadoc fix for AnalyzedInstruction.setPostRegisterType 2015-10-17 13:48:54 -07:00
Ben Gruver
da58cc8991 Only use the instance-of/if-eqz type info if we're getting more information
We should only use the type info from an instance-of/if-eqz combo if we're
going from an interface to a class, or going from a class to a subtype
of that class -- otherwise, we're actually losing information.
2015-10-17 13:18:55 -07:00
Ben Gruver
3124e94d4b Add support for static volatile opcodes in OdexedFieldInstructionMapper
This fixes a regression introduced in 2.1
2015-10-16 19:07:50 -07:00
Ben Gruver
37d14becd1 Fix register propagation when overriding a register type from a predecessor 2015-10-14 21:57:23 -07:00
Ben Gruver
398630dde5 Infer the register type based on the result of an instance-of instruction
In oat files, it's possible that a check-cast is removed based on the
register being provably of the type being cast to, based on the result
of an instance-of check.

Supporting this in general would require more sophisticated static analysis
than is currently done. Instead, this adds a special-case specifically
for the case of an instance-of followed immediately by an if-eqz
2015-10-13 21:59:47 -07:00
Ben Gruver
ccf087b0dd Bump up MAX_OAT_VERSION to 71 2015-10-01 22:51:10 -07:00
Ben Gruver
7844089286 Add support for alternate field ordering starting at oat version 67 2015-10-01 22:50:35 -07:00
Ben Gruver
ea3fdd7e86 Merge branch 'master' into smalidea 2015-10-01 08:34:21 -07:00
Ben Gruver
827e2db34d Add support for normalizing virtual methods
This is useful, for example, when comparing the result of deodexing with
the original dex file, to remove the "false" differences caused by the
different potential ways to reference a given virtual method.
2015-09-30 20:36:12 -07:00
Ben Gruver
c8c70ac58e Add support for calculating field offsets for art 2015-09-30 20:36:12 -07:00
Ben Gruver
64785d79a3 Add support for using an oat file as the boot class path 2015-09-30 20:36:12 -07:00
Ben Gruver
8920228819 Add oat support in DexFileFactory 2015-09-30 20:36:12 -07:00
Ben Gruver
3ff884b1c3 Add art-specific opcodes and opcode values 2015-09-29 23:41:30 -07:00
Ben Gruver
e5266afb14 Add a minimal parser for oat files 2015-09-29 23:40:52 -07:00
Alex Light
c456c55c40 Make smali respect order of implements
Previously smali would reorder implements directives to be
alphabetical in the dex file. In the Java 8 Language the order of
interfaces may affect the order of initializer invocation when using
default methods. Therefore we will preserve this order in
smali/baksmai.

Bug: 24338722

Change-Id: I6851b02a5402c7d4cd4b60af54052c320e48d0bf
2015-09-24 13:04:30 -07:00
Ben Gruver
0c7e7b7ffc Add ability to list methods/fields/types when assembling with smali
This can be useful in analyzing why you are going over the 64k
method/field/type limit
2015-09-05 16:11:21 -07:00
Ben Gruver
4d8ec4c795 Handle invalid debug item offsets more gracefully 2015-08-26 15:55:30 -07:00
Ben Gruver
3065d6b7de Add backwards compatible version of DexFileFactory.loadDexFile and Opcodes
Keep the old prototype, so we don't break existing code.
2015-06-18 17:44:30 -07:00
Ben Gruver
b960e8950b Replace a missed usage of Iterators.emptyIterator() 2015-06-18 17:40:57 -07:00
Ben Gruver
7c97ddbb45 Remove usages of the deprecated Iterators.emptyIterator() method 2015-06-18 13:34:12 -07:00
Ben Gruver
0f1e995099 Add the generated accessorTest to source control
Some java compilers don't generate the synthetic accessor methods in the
way that the accessorTest is trying to test. So we build the test dex
file using a known-good compiler and check it in, ensuring the test is
always run using an appropriate dex file.
2015-05-23 11:26:35 -07:00
Ben Gruver
abd113eb3b Ensure the stream is closed in DexFileFactory.loadDexFile 2015-04-09 21:33:33 -07:00
Ben Gruver
75bef01d10 Merge branch 'master' into smalidea 2015-03-18 21:00:32 -07:00
Ben Gruver
1aad736c20 Ensure that sparse switch items are written out in the correct order 2015-03-17 21:18:19 -07:00
Ben Gruver
0c982a02f1 Add Member and Annotatable interfaces 2015-03-16 20:52:55 -07:00
Ben Gruver
bf167c2f0e Make sure the elements are sorted in an encoded annotation 2015-03-16 20:36:34 -07:00
Ben Gruver
b76dee7ebd Don't assume dx is on-path. Rather, grab it from maven central
The version of dx in maven central seems to be fairly old, but it works
well enough for our purposes.
2015-03-16 19:54:57 -07:00