ART虚拟机使用的是oat文件,oat文件其实已经是一种可执行文件了,就跟system/bin下面的文件是同一个类型。可执行文件里面就是一些机器码,所以ART虚拟机就运行得很快啦。
1.OAT文件是ELF可执行文件
下面我们来看看优酷apk的oat文件罗。咦??oat文件怎么是已odex结尾呢??其实就是为了兼容之前的dalvick虚拟机啦。
youku通过file命令可以看到他是elf文件。
Paste_Image.png看看百度百科,ELF就是linux的可执行文件。
elf.png2.OatDumpe查看OAT文件信息
因为youku太大了,决定不是用youku来dump,直接用个自己写的apk dump吧
haha.png看看结果吧,好长,我就把头发出来吧,主要能够看到魔数,校验和等信息。
MAGIC: //魔数
oat
088
LOCATION: //位置
base.odex
CHECKSUM: //校验和
0x116572e6
INSTRUCTION SET: //架构
Arm64
INSTRUCTION SET FEATURES: //指令集的特点
smp,a53
DEX FILE COUNT: //dex文件数量
1
EXECUTABLE OFFSET: //可执行段的偏移
0x0016b000
INTERPRETER TO INTERPRETER BRIDGE OFFSET: //不清楚,哪位大哥告诉下我
0x00000000
INTERPRETER TO COMPILED CODE BRIDGE OFFSET://不清楚,哪位大哥告诉下我
0x00000000
JNI DLSYM LOOKUP OFFSET: //不清楚,哪位大哥告诉下我
0x00000000
QUICK GENERIC JNI TRAMPOLINE OFFSET://不清楚,哪位大哥告诉下我
0x00000000
QUICK IMT CONFLICT TRAMPOLINE OFFSET://不清楚,哪位大哥告诉下我
0x00000000
QUICK RESOLUTION TRAMPOLINE OFFSET://不清楚,哪位大哥告诉下我
0x00000000
QUICK TO INTERPRETER BRIDGE OFFSET://不清楚,哪位大哥告诉下我
0x00000000
IMAGE PATCH DELTA: //patch的偏移
14487552 (0x00dd1000)
IMAGE FILE LOCATION OAT CHECKSUM: //image的checksum
0x9c540d19
IMAGE FILE LOCATION OAT BEGIN:
0x71d56000
KEY VALUE STORE:
classpath =
compiler-filter = interpret-only
debuggable = true
dex2oat-cmdline = --zip-fd=7 --zip-location=base.apk --oat-fd=9 --oat-location=/data/app/vmdl305997216.tmp/oat/arm64/base.odex --instruction-set=arm64 --instruction-set-variant=cortex-a53 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=interpret-only --swap-fd=10 --debuggable
dex2oat-host = Arm
has-patch-info = false
image-location = /data/dalvik-cache/arm64/system@framework@boot.art:/data/dalvik-cache/arm64/system@framework@boot-core-libart.art:/data/dalvik-cache/arm64/system@framework@boot-conscrypt.art:/data/dalvik-cache/arm64/system@framework@boot-okhttp.art:/data/dalvik-cache/arm64/system@framework@boot-core-junit.art:/data/dalvik-cache/arm64/system@framework@boot-bouncycastle.art:/data/dalvik-cache/arm64/system@framework@boot-ext.art:/data/dalvik-cache/arm64/system@framework@boot-framework.art:/data/dalvik-cache/arm64/system@framework@boot-telephony-common.art:/data/dalvik-cache/arm64/system@framework@boot-voip-common.art:/data/dalvik-cache/arm64/system@framework@boot-ims-common.art:/data/dalvik-cache/arm64/system@framework@boot-apache-xml.art:/data/dalvik-cache/arm64/system@framework@boot-org.apache.http.legacy.boot.art:/data/dalvik-cache/arm64/system@framework@boot-oppo-framework.art:/data/dalvik-cache/arm64/system@framework@boot-mediatek-common.art:/data/dalvik-cache/arm64/system@framework@boot-mediatek-framework.art:/data/dalvik-cache/arm64/system@framework@boot-mediatek-telephony-common.art:/data/dalvik-cache/arm64/system@framework@boot-ifaamanager.art
native-debuggable = false
pic = false
SIZE: //大小
1631156
APK只写了一个MainActivity,看看dump的信息是怎么描述他的
MainActivity.png主要包含 DEX CODE,OatMethodOffsets, QuickMethodFrameInfo, CODE信息。
786: Lcom/example/anrdemo/MainActivity; (offset=0x00159fd0) (type_idx=1440) (StatusVerified) (OatClassSomeCompiled)
0: void com.example.anrdemo.MainActivity.<init>() (dex_method_idx=10597)
DEX CODE:
0x0000: 7010 1700 0000 | invoke-direct {v0}, void android.app.Activity.<init>() // method@23
0x0003: 7300 | return-void-no-barrier
OatMethodOffsets (offset=0x00000000)
code_offset: 0x00000000
OatQuickMethodHeader (offset=0x00000000)
vmap_table: (offset=0x00000000)
QuickMethodFrameInfo
frame_size_in_bytes: 0
core_spill_mask: 0x00000000
fp_spill_mask: 0x00000000
vr_stack_locations:
ins: v0[sp + #8]
method*: v1[sp + #0]
outs: v0[sp + #8]
CODE: (code_offset=0x00000000 size_offset=0x00000000 size=0)
NO CODE!
1: void com.example.anrdemo.MainActivity.onCreate(android.os.Bundle) (dex_method_idx=10600)
DEX CODE:
0x0000: 6f20 2b00 5400 | invoke-super {v4, v5}, void android.app.Activity.onCreate(android.os.Bundle) // method@43
0x0003: 1501 037f | const/high16 v1, #int +2130903040 // 0x7f030000
0x0005: e920 7b01 1400 | invoke-virtual-quick {v4, v1}, // vtable@379
0x0008: e910 3800 0400 | invoke-virtual-quick {v4}, // vtable@56
0x000b: 0c01 | move-result-object v1
0x000c: 1a02 6013 | const-string v2, "android_id" // string@4960
0x000e: 7120 ad03 2100 | invoke-static {v1, v2}, java.lang.String android.provider.Settings$Secure.getString(android.content.ContentResolver, java.lang.String) // method@941
0x0011: 0c00 | move-result-object v0
0x0012: 1a01 be29 | const-string v1, "wenfeng" // string@10686
0x0014: 2202 de05 | new-instance v2, java.lang.StringBuilder // type@1502
0x0016: 1a03 f212 | const-string v3, "android id = " // string@4850
0x0018: 7020 032a 3200 | invoke-direct {v2, v3}, void java.lang.StringBuilder.<init>(java.lang.String) // method@10755
0x001b: e920 4e00 0200 | invoke-virtual-quick {v2, v0}, // vtable@78
0x001e: 0c02 | move-result-object v2
0x001f: e910 0700 0200 | invoke-virtual-quick {v2}, // vtable@7
0x0022: 0c02 | move-result-object v2
0x0023: 7120 e125 2100 | invoke-static {v1, v2}, int android.util.Log.i(java.lang.String, java.lang.String) // method@9697
0x0026: 7300 | return-void-no-barrier
OatMethodOffsets (offset=0x00159fdc)
code_offset: 0x00000000
OatQuickMethodHeader (offset=0x00181c60)
vmap_table: (offset=0x00163b05)
quickened data
QuickMethodFrameInfo
frame_size_in_bytes: 0
core_spill_mask: 0x00000000
fp_spill_mask: 0x00000000
vr_stack_locations:
locals: v0[sp + #4294967276] v1[sp + #4294967280] v2[sp + #4294967284] v3[sp + #4294967288]
ins: v4[sp + #8] v5[sp + #12]
method*: v6[sp + #0]
outs: v0[sp + #8] v1[sp + #12]
CODE: (code_offset=0x00000000 size_offset=0x00181c70 size=0)
NO CODE!
3.魔数
所谓魔数就是文件头四个字节用来记录文件类型的,是elf,还是jpg,rar之类的。我们可以用二进制查看器查看下这个oat文件。
魔数.png可以看到前四个字节是 7f 45 4c 46,Ascii码就是 ELF。
我们看下压缩包文件的二进制,也可以看到头部是RAR
RAR
网友评论