细说dex2oat(2)

简介: 本节我们分析一下生成boot.art和boot.oat,与编译普通应用的不同

生成boot.art和boot.oat

前面讲的参数中,有一项是--boot-image。我们先看一下这个boot-image是如何编出来的,正好是一个完整的dex2oat的例子.

我们看下在MediaTek MT6753平台下,是如何生成的。
MT6753是64位Cortex-A53的架构,所以boot.art也是64位和32位两套。

64位的boot.art

先看64位的吧:

out/host/linux-x86/bin/dex2oat
--runtime-arg -Xms64m
--runtime-arg -Xmx64m

初始堆大小和最大堆大小。

--image-classes=frameworks/base/preloaded-classes

预加载类的路径

--dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/org.apache.http.legacy.boot_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-common_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-framework_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-telephony-common_intermediates/javalib.jar

以上是一大堆的dex文件

--dex-location=/system/framework/core-libart.jar
--dex-location=/system/framework/conscrypt.jar
--dex-location=/system/framework/okhttp.jar
--dex-location=/system/framework/core-junit.jar
--dex-location=/system/framework/bouncycastle.jar
--dex-location=/system/framework/ext.jar
--dex-location=/system/framework/framework.jar
--dex-location=/system/framework/telephony-common.jar
--dex-location=/system/framework/voip-common.jar
--dex-location=/system/framework/ims-common.jar
--dex-location=/system/framework/apache-xml.jar
--dex-location=/system/framework/org.apache.http.legacy.boot.jar
--dex-location=/system/framework/mediatek-common.jar
--dex-location=/system/framework/mediatek-framework.jar
--dex-location=/system/framework/mediatek-telephony-common.jar

以上是上面那一大堆dex对应的jar文件路径

--oat-symbols=out/target/product/6753_65t_m/symbols/system/framework/arm64/boot.oat

符号表的位置

--oat-file=out/target/product/6753_65t_m/dex_bootjars/system/framework/arm64/boot.oat
--oat-location=/system/framework/arm64/boot.oat
--image=out/target/product/6753_65t_m/dex_bootjars/system/framework/arm64/boot.art

输出文件有两个:一个是boot.oat,一个是boot.art。

--base=0x70000000

基地址0x70000000

--instruction-set=arm64
--instruction-set-variant=cortex-a53
--instruction-set-features=default

对于指令架构,除了arm64,更细的是cortex-a53

--android-root=out/target/product/6753_65t_m/system
--include-patch-information
--runtime-arg -Xnorelocate
--no-generate-debug-info

最后这几个前面都说过了。

32位的boot.art

out/host/linux-x86/bin/dex2oat
--runtime-arg -Xms64m
--runtime-arg -Xmx64m
--image-classes=frameworks/base/preloaded-classes
--dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/org.apache.http.legacy.boot_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-common_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-framework_intermediates/javalib.jar
--dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-telephony-common_intermediates/javalib.jar
--dex-location=/system/framework/core-libart.jar
--dex-location=/system/framework/conscrypt.jar
--dex-location=/system/framework/okhttp.jar
--dex-location=/system/framework/core-junit.jar
--dex-location=/system/framework/bouncycastle.jar
--dex-location=/system/framework/ext.jar
--dex-location=/system/framework/framework.jar
--dex-location=/system/framework/telephony-common.jar
--dex-location=/system/framework/voip-common.jar
--dex-location=/system/framework/ims-common.jar
--dex-location=/system/framework/apache-xml.jar
--dex-location=/system/framework/org.apache.http.legacy.boot.jar
--dex-location=/system/framework/mediatek-common.jar
--dex-location=/system/framework/mediatek-framework.jar
--dex-location=/system/framework/mediatek-telephony-common.jar

上面都是java和dex,所以跟64位没有什么区别。

--oat-symbols=out/target/product/6753_65t_m/symbols/system/framework/arm/boot.oat
--oat-file=out/target/product/6753_65t_m/dex_bootjars/system/framework/arm/boot.oat
--oat-location=/system/framework/arm/boot.oat
--image=out/target/product/6753_65t_m/dex_bootjars/system/framework/arm/boot.art

输出文件从arm64目录换到了arm目录

--base=0x70000000

基地址没变,反正patchoat的时候也还要改。

--instruction-set=arm
--instruction-set-variant=cortex-a53
--instruction-set-features=default

指令集从arm64变成了arm,其它的参数都不变

--android-root=out/target/product/6753_65t_m/system
--include-patch-information
--runtime-arg -Xnorelocate
--no-generate-debug-info

dex2oat编译应用的例子

out/host/linux-x86/bin/dex2oat
--runtime-arg -Xms64m
--runtime-arg -Xmx512m

这两个值在前面分析Android.oat.mak时已经分析过了,这里验证了我们的分析是正确的。

--boot-image=out/target/product/6753_65t_m/dex_bootjars/system/framework/boot.art

这个boot.art就是上一节讲的命令刚刚生成的。

--dex-file=out/target/product/6753_65t_m/obj/APPS/MusicFX_intermediates/oat/arm64/package.odex.input
--dex-location=/system/app/MusicFX/MusicFX.apk

输入的dex文件

--oat-file=out/target/product/6753_65t_m/obj/APPS/MusicFX_intermediates/oat/arm64/package.odex

输出到odex文件,虽然名字叫odex,但是实际上是个oat。普通的应用就不像上节讲的输出boot.oat和boot.art的时候那样输出那么多了,只有一个odex文件,符号表和image都不用。

--android-root=out/target/product/6753_65t_m/system
--instruction-set=arm64
--instruction-set-variant=cortex-a53
--instruction-set-features=default
--include-patch-information
--runtime-arg -Xnorelocate
--no-generate-debug-info
--abort-on-hard-verifier-error
目录
相关文章
|
2月前
|
Android开发
安卓逆向 -- Hook多个dex文件
安卓逆向 -- Hook多个dex文件
19 1
|
8月前
|
安全 Android开发
反编译之将脱壳后的dex文件重新打包成apk
反编译之将脱壳后的dex文件重新打包成apk
|
Java Android开发
Android反编译:使用dex2jar查看dex文件
Android反编译:使用dex2jar查看dex文件
442 0
|
Android开发
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | aosp 中搜索 dex2oat 源码 | dex2oat.cc#main 主函数源码 )
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | aosp 中搜索 dex2oat 源码 | dex2oat.cc#main 主函数源码 )
174 0
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | aosp 中搜索 dex2oat 源码 | dex2oat.cc#main 主函数源码 )
|
Android开发
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | /art/dex2oat/dex2oat.cc#Dex2oat 函数源码 )(二)
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | /art/dex2oat/dex2oat.cc#Dex2oat 函数源码 )(二)
268 0
|
Android开发
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | /art/dex2oat/dex2oat.cc#Dex2oat 函数源码 )(一)
【Android 逆向】ART 脱壳 ( dex2oat 脱壳 | /art/dex2oat/dex2oat.cc#Dex2oat 函数源码 )(一)
211 0
|
Android开发
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | exec_utils.cc 中执行 Dex 编译为 Oat 文件的 Exec 和 ExecAndReturnC函数 )
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | exec_utils.cc 中执行 Dex 编译为 Oat 文件的 Exec 和 ExecAndReturnC函数 )
131 0
|
Android开发
【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | dex_file.cc 中创建 DexFile 实例对象的相关函数分析 )
【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | dex_file.cc 中创建 DexFile 实例对象的相关函数分析 )
157 0
|
Android开发
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | oat_file_assistant.cc 中涉及的 oat 文件生成流程 )(二)
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | oat_file_assistant.cc 中涉及的 oat 文件生成流程 )(二)
282 0
|
Java Android开发
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | oat_file_assistant.cc 中涉及的 oat 文件生成流程 )(一)
【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | oat_file_assistant.cc 中涉及的 oat 文件生成流程 )(一)
331 0