细说dex2oat(2)

生成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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>