Tuesday, October 21, 2008

Google Android Native libc Bionic library

Google developed a custom library for the C compiler (libc) called Bionic. This was necessary for three main reasons:
  • License: they wanted to keep GPL out of user-space. Bionic code uses the BSD license.
  • Size: the library has to be loaded in each process, so it needs to be small. Bionic is about 200K, or half the size of glibc (the GNU version of libc).
  • Speed: limited CPU power means it needs to be fast. Bionic has a small size and fast code paths, including a very fast and small custom pthread implementation.
Bionic has built-in support for important Android-specific services such as system properties and logging. It doesn’t support certain POSIX features, like C++ exceptions and wide chars, which were not needed on Android. Thus it’s not quite compatible with the gnu libc. All native code must be compiled against bionic, not glibc.

12 comments:

Unknown said...

Static bins work, but busybox for instance has resolver issues that have me scratching my head (and strace won't strace it). Does the API include stuff for linking to this libc? I'm guessing no, since the offical way of creating apps is to use the sandbox'ed java environment..

Unknown said...

So, does this mean if I have a try/catch in my code, it won't compile on Bionic?

Unknown said...

"Size: the library has to be loaded in each process, so it needs to be small." -> Linux can reuse the page frames mapping the same shared library's code in multiple processes, so I don't understand this argument.

Unknown said...

Wow! I'm pretty sure that this caught up plenty of people's attention, Thumbs up for your work and Good writing skills!

i am jayne and i am a freelance writer..
see my related post here ------> Man Suits

Arghya Chakraborty said...

Very best regards from Arlington criminal lawyer Paul Previte for your well written article. I got many unknown information from this blog.

Konstantin Krstev said...

strace works fine. either use bionic or place ld-linux.so.3, libc.so.6, libresolv.so.2, libnss_dns.so.2 in your /system/lib.

glibc resolverr library has issues with static building since ages :)

Anonymous said...

I want to show gratitude for writing such a nice feature article, really will support me out in frequent ways…
Health Insurance Providers

Ducen said...

This is highly informative .....
auto financing bankruptcy

Ducen said...

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts...
Physiological response to stress 

Anubis said...
This comment has been removed by the author.
Anubis said...

I guess if BuxyBox can be compiled against uClibc.

Unknown said...

install google play store
Download Google Play Store app free - Play Store