anestisb / android-prepare-vendor

Set of scripts to automate AOSP compatible vendor blobs generation from factory images
347 stars 155 forks source link

Enable decompile_return_instruction in oatdump unquicken patch #105

Closed anestisb closed 6 years ago

anestisb commented 6 years ago

ART runtime is not complaining when the return-void instructions are not decompiled back. However, it would be nice if we can have a fully compatible bytecode export matching the original input bytecode.

$ diff -u LLKAgent.apk.dump LLKAgent.apk_export.dex.dump
--- LLKAgent.apk.dump   2017-10-08 10:36:21.000000000 +0300
+++ LLKAgent.apk_export.dex.dump    2017-10-08 10:36:21.000000000 +0300
@@ -1,5 +1,5 @@
-Processing '/tmp/LLKAgent.apk'...
-Opened '/tmp/LLKAgent.apk', DEX version '037'
+Processing '/tmp/LLKAgent.apk_export.dex'...
+Opened '/tmp/LLKAgent.apk_export.dex', DEX version '037'
 Class #0            -
   Class descriptor  : 'Lcom/verizon/llkagent/EmailUtils$1;'
   Access flags      : 0x0010 (FINAL)
@@ -47,7 +47,6 @@
 000df0:                                        |[000df0] com.verizon.llkagent.EmailUtils.1.onAccountsUpdated:([Landroid/accounts/Account;)V
 000e00: 5410 0200                              |0000: iget-object v0, v1, Lcom/verizon/llkagent/EmailUtils$1;.val$countDownLatch:Ljava/util/concurrent/CountDownLatch; // field@0002
 000e04: 6e10 6100 0000                         |0002: invoke-virtual {v0}, Ljava/util/concurrent/CountDownLatch;.countDown:()V // method@0061
-000e0a: 0e00                                   |0005: return-void
       catches       : (none)
       positions     :
         0x0000 line=39
@@ -77,7 +76,6 @@
       insns size    : 4 16-bit code units
 000e0c:                                        |[000e0c] com.verizon.llkagent.EmailUtils.<init>:()V
 000e1c: 7010 5300 0000                         |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0053
-000e22: 0e00                                   |0003: return-void
       catches       : (none)
       positions     :
         0x0000 line=18
@@ -346,7 +344,6 @@
 001044: 7010 1c00 0100                         |0000: invoke-direct {v1}, Landroid/os/Binder;.<init>:()V // method@001c
 00104a: 1b00 8e00 0000                         |0003: const-string/jumbo v0, "com.verizon.llkagent.IStoreDemoModeService" // string@0000008e
 001050: 6e30 3000 1100                         |0006: invoke-virtual {v1, v1, v0}, Lcom/verizon/llkagent/IStoreDemoModeService$Stub;.attachInterface:(Landroid/os/IInterface;Ljava/lang/String;)V // method@0030
-001056: 0e00                                   |0009: return-void
       catches       : (none)
       positions     :
         0x0000 line=13
@@ -538,7 +535,6 @@
 001212: 1302 0900                              |0047: const/16 v2, #int 9 // #9
 001216: 4d01 0002                              |0049: aput-object v1, v0, v2
 00121a: 6900 0300                              |004b: sput-object v0, Lcom/verizon/llkagent/LauncherUtils;.COLUMNS_LAUNCHER:[Ljava/lang/String; // field@0003
-00121e: 0e00                                   |004d: return-void
       catches       : (none)
       positions     :
         0x0000 line=20
@@ -560,7 +556,6 @@
       insns size    : 4 16-bit code units
 001220:                                        |[001220] com.verizon.llkagent.LauncherUtils.<init>:()V
 001230: 7010 5300 0000                         |0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0053
-001236: 0e00                                   |0003: return-void
       catches       : (none)
       positions     :
         0x0000 line=16
@@ -1003,7 +998,6 @@
 001756: 0c04                                   |0049: move-result-object v4
 001758: 1b05 8b00 0000                         |004a: const-string/jumbo v5, "com.google.android.apps.nexuslauncher.settings" // string@0000008b
 00175e: 6e30 0b00 5402                         |004d: invoke-virtual {v4, v5, v2}, Landroid/content/ContentResolver;.applyBatch:(Ljava/lang/String;Ljava/util/ArrayList;)[Landroid/content/ContentProviderResult; // method@000b
-001764: 0e00                                   |0050: return-void
       catches       : (none)
       positions     :
         0x0002 line=65
@@ -1433,7 +1427,6 @@
 001aec:                                        |[001aec] com.verizon.llkagent.StoreDemoModeService.2.onRemoveCompleted:(Ljava/lang/String;Z)V
 001afc: 5410 0700                              |0000: iget-object v0, v1, Lcom/verizon/llkagent/StoreDemoModeService$2;.val$countDownLatch:Ljava/util/concurrent/CountDownLatch; // field@0007
 001b00: 6e10 6100 0000                         |0002: invoke-virtual {v0}, Ljava/util/concurrent/CountDownLatch;.countDown:()V // method@0061
-001b06: 0e00                                   |0005: return-void
       catches       : (none)
       positions     :
         0x0000 line=108
anestisb commented 6 years ago

Implemented by https://github.com/anestisb/android-prepare-vendor/commit/2c51d0f4850d6e907441fb561bb2166584a98ab2. macOS binaries update to follow soon.

Latest version of the unquicken patch can be found here

anestisb commented 6 years ago

Darwin updates too (https://github.com/anestisb/android-prepare-vendor/commit/1118d4e80e2e9434654cce7e5ed97c4b284d1686).

All tests successfully passed. Current binaries are capable to fully revert the optimized bytecode when vdex support is activated on target. Hopefully, Google will not change often the VDEX version so we can keep maintaining this functionality until PR is merged with upstream and reaches production releases.

anestisb commented 6 years ago

For the record an updated version of the patches to be compatible with current master has been uploaded for review.