[英]Format of .dex files for Android 2.1 (Eclair), i.e. API level 7
I'm writing an assembler for Android/Dalvik .dex files. 我正在为Android / Dalvik .dex文件编写一个汇编程序 。 The official Android docs seem to only describe the newest version of the .dex format (apparently 038
as of May 2019), with a few short notes describing differences back to version 035
. 官方的Android文档似乎仅描述了最新版本的.dex格式 (截至2019年5月,显然是038
),并有一些简短的说明描述了与035
版本的区别。 A quick glimpse into Android sources seems to suggest, that version 035
of the format corresponds to Android API level 13 , meaning Android 3.2.x (Honeycomb). 快速浏览一下Android来源似乎表明,该格式的035
版本对应于Android API级别13 ,即Android 3.2.x (Honeycomb)。 I own a device with Android 2.1 (Eclair), which apparently means API level 7 . 我自己的装置与Android 2.1(埃克莱尔),这显然意味着API级7。 I would like to be able to learn how to emit correct .dex and .apk files for that device, to hopefully add support for those to my assembler. 我希望能够学习如何为该设备发出正确的.dex和.apk文件,希望将这些文件的支持添加到我的汇编器中。
Where can I find information that could help me emit correct .dex files for Android 2.1 (Eclair), ie API level 7? 在哪里可以找到可以帮助我为Android 2.1(Eclair)发出正确的.dex文件(即API级别7)的信息? I don't even know what's the .dex format version string for that API level! 我什至不知道该API级别的.dex格式版本字符串是什么!
For "bonus points", I would really love to find some good reference explaining the differences in .dex format between all API levels (at least back to API level 7). 对于“加分点”,我真的很想找到一些很好的参考资料,以解释所有API级别(至少回到API级别7)之间.dex格式的差异。 I would be also interested if there are any substantial differences in the format of the binary .xml and resource files (as emitted by the aapt
tool) between Android API levels. 如果Android API级别之间的二进制.xml和资源文件(由aapt
工具发出)的格式存在实质性差异,我也将感兴趣。 I assume that there's a high chance the .apk format itself, as well as the signing algorithm, hopefully didn't change at all , given that it's the same format used to sign Java .jar files (ie a regular .zip with a few simple special files in the META-INF/
subdirectory). 我认为有一个高的机会.apk文件格式本身,以及签名算法,希望一点都没有因为它是用来签名的Java .jar文件(即一个普通的.zip有一些相同的格式改变, META-INF/
子目录中的简单特殊文件)。 But the .dex format spec (including bytecodes) is probably the most important part, or at least a good starting point. 但是.dex格式规范(包括字节码)可能是最重要的部分,或者至少是一个很好的起点。
https://source.android.com/devices/tech/dalvik/dex-format has some quick blurbs on the differences between the versions. https://source.android.com/devices/tech/dalvik/dex-format对版本之间的差异进行了一些简短的介绍。
Note: Support for version 037 of the format was added in the Android 7.0
release. Prior to version 037 most versions of Android have used version 035 of
the format. The only difference between versions 035 and 037 is the addition of
default methods and the adjustment of the invoke.
Note: Support for version 038 of the format was added in the Android 8.0
release. Version 038 added new bytecodes (invoke-polymorphic and invoke-
custom) and data for method handles.
Although, note that the newest version is 039, which doesn't seem to be mentioned in the doc. 不过,请注意,最新版本是039,似乎在文档中并未提及。 iirc, 039 added the invoke-custom/range
, const-method-handle
and const-method-type
instructions. iirc,039添加了invoke-custom/range
, const-method-handle
和const-method-type
指令。
Other sources of information include looking at the changelog of those documents: https://android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/dex-format.html https://android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/dalvik-bytecode.html 其他信息来源包括查看这些文档的变更日志: https : //android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/ dex-format.html https://android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/dalvik-bytecode.html
And prior to that, before the files were moved: 在此之前,在移动文件之前:
https://android.googlesource.com/platform/docs/source.android.com/+log/a3b748b40bab557fb47fe5a48a5bfb642837fb05/src/devices/tech/dalvik/dex-format.jd https://android.googlesource.com/platform/docs/source.android.com/+log/a3b748b40bab557fb47fe5a48a5bfb642837fb05/src/devices/tech/dalvik/dalvik-bytecode.jd https://android.googlesource.com/platform/docs/source.android.com/+log/a3b748b40bab557fb47fe5a48a5bfb642837fb05/src/devices/tech/dalvik/dex-format.jd https://android.googlesource.com/platform/文档/ source.android.com / +登录/ a3b748b40bab557fb47fe5a48a5bfb642837fb05 / src目录/设备/技术/达尔维克/达尔维克bytecode.jd
Also, you should be able to glean some info from the smali source. 另外,您应该能够从smali来源中收集一些信息。 It has the min/max api levels , where applicable, for every instruction. 它具有适用于每条指令的最小/最大api级别 。
For the instructions with the min/max set as an art version, you can use this mapping to map back to an api level. 对于将最小/最大设置为艺术版本的说明,您可以使用此映射映射回api级别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.