Commit Graph

1833 Commits

Author SHA1 Message Date
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
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
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
ad8f15d61d Add the new type and string bss mapping offsets in the oat header 2019-08-07 14:05:34 -07:00
2f31502924 Update OatVersions.txt and VdexVersions.txt 2019-08-07 14:05:34 -07:00
77afc7caa0 Implement immutable instructions 45cc and 4rcc 2019-08-01 19:42:47 -07:00
29f9020de4 Implement postponed immutable instruction assertions 2019-08-01 19:38:33 -07:00
9340652ff6 Add unit tests for org.jf.util.Hex
These tests were written using Diffblue Cover.
2019-06-13 11:47:05 -07:00
c70a7008f6 Upgraded to Gradle 5.1; fixed two issues, caused by the changes of the version upgrade; RESULT: build succeeds on Ubuntu 18.04 with openJDK 11; version details see below
Gradle        5.1
Build time:   2019-01-02 18:57:47 UTC
Revision:     d09c2e354576ac41078c322815cc6db2b66d976e

Kotlin DSL:   1.1.0
Kotlin:       1.3.11
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.2 (Oracle Corporation 11.0.2+9-Ubuntu-3ubuntu118.04.3)
OS:           Linux 4.15.0-47-generic amd64
Distro:       Ubuntu 18.04.2 LTS
2019-05-17 15:42:24 -07:00
76867f0ae9 Bump the version to v2.2.7 2019-04-04 11:15:17 -07:00
0d4443a19a Gracefully deal with code addresses that are out of range in MutableMethodImplementation
The code addresses in debug info items are not verified, and may be out of
bounds. If this happens, we just clamp them to the maximum code address.
2019-03-21 13:41:00 -07:00
580b27f379 Bump the version to v2.2.6 2019-01-23 00:23:56 -08:00
72c0d9d89a make opcodes nullable in loadDexContainer 2019-01-23 00:17:12 -08:00
5935fe6ef8 Remove usage of sput-object-volatile into FieldUsageTypeTest
- Since 2db1dec703, sput-object-volatile is no longer supported at default api level.
Thus remove his usage until Smalidea has a way to define the api level to use.
2018-10-07 14:01:36 -07:00
cb4a44bdd1 Update results of testPackedSwitch and testSparseSwitch
- Computation of switch target offsets was modified into
10fd792f59,
thus update expected results to reflect this change.
2018-10-07 14:00:51 -07:00
7f46be6473 Align smallidea tokens and grammar on smali
- Now the following tests are fixed:
 * org.jf.smalidea.MethodRenameTest.testMethodRename
 * org.jf.smalidea.dexlib.SmalideaMethodTest.testArrayData
 * org.jf.smalidea.dexlib.SmalideaMethodTest.testCatchBlocks
 * org.jf.smalidea.MethodReferenceTest.testJavaReferenceFromSmali
 * org.jf.smalidea.MethodReferenceTest.testSmaliReferenceFromSmali
 * org.jf.smalidea.SmaliCodeFragmentFactoryTest.testUnknownClass
 * org.jf.smalidea.SmaliCodeFragmentFactoryTest.testRegisterType
 * org.jf.smalidea.findUsages.MethodUsageTypeTest.testMethodUsageTypes
 * org.jf.smalidea.findUsages.HighlightLocalClassUsagesTest.testHighlightLocalClassUsage
 * org.jf.smalidea.findUsages.FindClassUsagesTest.testSmaliUsageInSmaliFile
 * org.jf.smalidea.findUsages.FindClassUsagesTest.testJavaUsageInSmaliFile
2018-10-07 13:59:22 -07:00
280fe36112 Update gradle wrapper as defined by the gradle version into the wrapper task
- Now the used gradle wrapper is the same than the gradle wrapper specified
into the wrapper task of build.gradle.
2018-10-07 13:58:05 -07:00
b8638eccee Bump the version to 2.2.5 2018-08-28 12:28:43 -07:00
1bf8f2544b Refactor LocatedItems to use the function addItem() instead of
initItemsIfNull().
2018-08-27 12:59:22 -07:00
af8bc1d9cd Refactor LocatedItems::mergeItemsIntoNext
Add test for mergeInto to make sure the order is kept.
2018-08-27 12:59:05 -07:00
dd242aa735 Remove code duplication - extract Labels and debugItems from MethodLocation. 2018-08-27 12:41:41 -07:00
7542a6b531 Simplify getLabels() by using two separate methods. 2018-08-22 12:43:34 -07:00
86963ccb43 Change BlankReader to the correct location in SmaliLexer for idea 2018-08-20 12:55:29 -07:00
d33818773e Update the tests to handle MethodHandle kind fixes 2018-08-20 12:55:29 -07:00
c6b0408092 Fix support for the kind values of MethodHandle
The current implementation only supported 6 of the possible kind values for a MethodHandle object.
However, as the link below shows there are in fact 9. All 9 can be seen in the MethodHandleType
class which is used by dexdump to translate the kind value of a MethodHandle object to a string
representation.

https://android.googlesource.com/platform/art/+/android-8.1.0_r41/runtime/dex_file.h

Moreover, this in fact lines up with the 9 different kinds for a MethodHandle object in standard
java bytecode (though the values are swapped around for some reason).

https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/MethodHandleInfo.html

These changes add in the additional 3 kind values and make sure all nesscary hooks using the
kind values of MethodHandle reference them.

For testing purposes, I found the easiest way to get correctly formatted invoke-custom and
invoke-polymorphic instructions was to use the already generated dex files used to test
dexdump. They can be found at the link below (invoke-custom.dex and invoke-polymorphic.dex).

https://android.googlesource.com/platform/art/+/android-8.1.0_r41/test/dexdump/
2018-08-20 12:55:29 -07:00
49ecdb334b Fix instructions 45cc and 4rcc (invoke-polymorphic)
Previously the offset of the method prototype was 3 bytes from the
instruction start for both instructions. This would put it somewhere in
the middle of the register values and method reference. Changed it to
the correct offset which is 6 bytes in both cases.

45cc Instruction Format
  op(8 bits)
  number_of_regs(4 bits)
  reg_g(4 bits)
  method_reference(16 bits)
  reg_d(4 bits)
  reg_c(4 bits)
  reg_f(4 bits)
  ref_e(4 bits)
  method_prototype(16 bits)

Example of invoke-polymorphic using 45cc
  Instruction: fa302f0021030800
  DexDump: invoke-polymorphic  {v1, v2, v3}, Ljava/lang/invoke/MethodHandle;
           .invoke:([Ljava/lang/Object;)Ljava/lang/Object;,
           (II)Ljava/lang/Object; // method@002f, proto@0008

4rcc Instruction Format
  op(8 bits)
  number_of_regs(8 bits)
  method_reference(16 bits)
  start_register(16 bits)
  method_prototype(16 bits)

Example of invoke-polymorphic using 4rcc
  Instruction: fb092f0000000800
  DexDump: invoke-polymorphic/range  {v0, v1, v2, v3, v4, v5, v6, v7, v8},
           Ljava/lang/invoke/MethodHandle;.invoke:([Ljava/lang/Object;)
           Ljava/lang/Object;, (IIIIIIILjava/lang/String;)Ljava/lang/Object;
           // method@002f, proto@0008
2018-07-11 13:43:01 -07:00
5a6b891ef0 Extract new class, PathEntryLoader from ClassPathResolver.
Extract method ClassPathResolver::getDefaultBootClassPath()
2018-07-10 16:16:45 -07:00
71ea09fc8e Add reminder to keep section arrays in sync 2018-07-10 16:09:40 -07:00
da571dbe71 Use similar formatting for section arrays 2018-07-10 16:09:40 -07:00
fef5569d25 Fix and extend hasOverflowed 2018-07-10 16:09:40 -07:00
2f29256bdf Use a switch statement in mapDexVersionToApi 2018-07-02 11:33:20 -07:00
a237739444 Make mapDexVersionToApi return NO_VERSION in the style of the other maps
Note that this commit silently changes the behavior of dexlib2 public API.
But mapDexVersionToApi was made available only a day ago in dexlib2 2.2.4,
and if the next version is published quickly, then this change should have
no real impact on clients.
2018-07-02 11:33:20 -07:00
9560bfe2a0 Remove the redundant SUPPORTED_DEX_VERSIONS array 2018-07-02 11:33:20 -07:00
1e984c2970 Use the same literals in mapDexVersionToApi and mapApiToDexVersion 2018-07-02 11:33:20 -07:00
dafcef3884 Refactor VersionMap.mapApiToDexVersion out of HeaderItem.getMagicForApi 2018-07-02 11:33:20 -07:00
fd3e00ab35 Refactor most of the utility classes from util into dexlib2
Now, util only contains the utilities that are needed by smali/baksmali,
but not dexlib2. E.g. the common command line parsing utilities, some path
utilities, etc.

This also reverses the dependency between the util module and dexlib2.
2018-07-01 14:08:33 -07:00
239b64ba00 Fix accidental dependencies on JCommander outside of dexlib2 2018-06-14 15:13:47 -07:00
2fcdad2078 Fix accidental dependency on JCommander on test 2018-06-13 22:43:25 -07:00
468a4eeba6 Fix mark/reset for new sections (closes #615) 2018-06-13 21:19:05 -07:00
d2b36e16da Fix accidental dependency on JCommander 2018-06-13 21:18:28 -07:00
08bef5f9c2 Fix Gradle's Task.leftShift(Closure) deprecation warning 2018-06-13 14:14:37 -07:00
f16b420b70 Fix for method reference sizes
The protos can be shared across methods so we should not be counting
them as part of private method size.
2018-06-13 14:12:40 -07:00
67e7b39dfc MemoryDataStore: Enforce min growth step and delay allocation of buffer 2018-06-13 14:11:46 -07:00
63896875d4 MemoryDataStore: Efficiently multiply by 1.25 2018-06-13 14:11:46 -07:00
f1c116241a MemoryDataStore: Fail fast on invalid offsets 2018-06-13 14:11:46 -07:00
c41c24a0c2 MemoryDataStore: Support InputStream mark/reset 2018-06-13 14:11:46 -07:00
b9a725e726 MemoryDataStore: Handle weird arguments values correctly
Namely:
- Negative arguments to InputStream::skip(n).
- Large arguments to readAt(offset).
2018-06-13 14:11:46 -07:00
c645b9d546 MemoryDataStore: More efficient overridable growth policy 2018-06-13 14:11:46 -07:00
b0a69fce34 MemoryDataStore: Add a data-trimming getData() method 2018-06-13 14:11:46 -07:00
53cdb13acc MemoryDataStore: Rename the buffer getter method 2018-06-13 14:11:46 -07:00