android art elf 和 Linux elf 文件有什么区别?

What is the difference between android art elf and Linux elf files?

在 ART wiki 中有描述: https://en.m.wikipedia.org/wiki/Android_Runtime?_e_pi_=7%2CPAGE_ID10%2C1898354483 ,ART 在安装时将 apk 文件编译为 ELF 文件。

GNU/Linux 上的 GCC 也创建 ELF 文件作为输出,最近取代了 a.out 格式。

我知道这两种环境在 API 和架构方面存在差异,但这两种格式是否存在任何结构差异或其他显着差异?

如果架构相同(因为 android 已移植到 x86),这些格式是否相互兼容?

或者这两种文件格式完全不同?

自制解释:在PDF (Dalvik and ART) you could find that "OAT files are actually embedded in ELF object files" (on page 16 of PDF you could see the OAT structure). The file structure is same as on wiki. It's possible because ELF "is flexible and extensible by design, and it is not bound to any particular processor or architecture".

来自 elf format on wikipedia:使用 Android 运行时 (ART),自 Android 5.0 "Lollipop" 以来的默认设置,所有应用程序在安装时都编译为本机 ELF 二进制文件。

结论:你的问题的答案是gcc elf和android elf是同一种文件格式。您可以在 wiki.

上找到有关格式的更多信息

更新

"Are these formats compatible with each other, if the architecture is same"

Readelf for android oat file (checked with one of the apps I have) shows that the oat file type is "DYN (Shared object file)". It's similar to .so files you could see if your project uses JNI libs. Those elf files are not compatible to usual GNU/Linux elf files if even built for the same architecture because of "bionic's system library functions and dynamic linker" (which used in android). More description about why they are not compatible you can find here. Bionic on wiki.