Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

It has been described in ART wiki: https://en.m.wikipedia.org/wiki/Android_Runtime?_e_pi_=7%2CPAGE_ID10%2C1898354483 ,that ART compiles the apk files to ELF files upon installation.

And GCC on GNU/Linux also creates ELF files as output, lately instead of a.out format.

I know there are differences in API and architechtural in both environments, but are there any structural or any other notable differences in these two formats?

Are these formats compatible to each other, if the architechture is same (As android has been ported to x86)?

Or are these two file formats entirely different?

like image 761
Aniruddha Sarkar Avatar asked Sep 16 '25 01:09

Aniruddha Sarkar


1 Answers

Homemade explanation: in 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".

From elf format on wikipedia: with Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries upon installation.

Conclusion: the answer to your question is that gcc elf and android elf are the same file format. More about the format you could find on wiki.

Update

"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.

like image 87
Yaroslav Havrylovych Avatar answered Sep 17 '25 14:09

Yaroslav Havrylovych