Bionic (software)

From Infogalactic: the planetary knowledge core
Jump to: navigation, search
Bionic
Developer(s) Open Handset Alliance
Initial release September 23, 2008; 15 years ago (2008-09-23)[1]
Operating system Android[2]
Platform x86, x86-64, ARM, ARM64, MIPS, MIPS64
Type C standard library
License Three-clause BSD licence
Website {{#property:P856}}

Bionic is the standard C library (including libc, libdl, libm, and libpthread) developed by Google for its Android operating system.[2]

The Android operating system replaces the GNU C Library with Bionic. Both libraries provide, among other functionality, wrappers around the system calls of the Linux kernel.

Original goals

The original publicly stated goals for Bionic were the following:[3][4]

  • BSD-licensed: Google wanted to isolate Android applications from the effect of copyleft licenses to create a proprietary user-space and application ecosystem,[5] but:
    • Android is based on the Linux kernel, which is subject to the copyleft GNU General Public License (GPL) version 2.
    • The most widespread standard C library for the Linux kernel is the GNU C Library (glibc), which is subject to the GNU Lesser General Public License (LGPL), also a copyleft license. In contrast to the GPL, the LGPL explicitly allows for dynamic linking but it does not allow static linking of proprietary software.
    • The permissive BSD license is a non-copyleft license that is compatible in both directions. A BSD-licensed glibc substitute could act as an isolation layer between the copyleft core (kernel) and the non-copyleft applications, and was therefore chosen by Google for its Bionic as a glibc substitute.[6]
  • Small size: Bionic was much smaller than the GNU C Library; more importantly its memory requirements were (and remain) much lower.
  • Speed: Bionic was designed for CPUs at relatively low clock frequencies.

Supported architectures

Bionic only supports Linux kernels, but currently supports the aarch64, arm, mips, mips64, x86, and x86-64 architectures.

Components

Some parts of the libc source, such as stdio, are from the BSDs (mainly OpenBSD), whereas others, such as the pthread implementation, were written from scratch.

The dynamic memory allocator is usually jemalloc, though it used to be dlmalloc, and still is on some memory-constrained devices; jemalloc gives much higher performance than dlmalloc, but at the cost of extra memory required for bookkeeping. Some 64-bit devices, like the Nexus 9, are effectively low-memory devices and use dlmalloc because of the extra space requirements of 64-bit pointers and hosting of two zygotes. (Zygote is an Android system service that is the parent of all Android application processes.[7])

The libm source is largely FreeBSD's, but with optimized assembler contributed by the various SoC vendors.

The dynamic linker (and libdl) were written from scratch.

Bionic doesn't include libthread_db (used by gdbserver), but there is one in the NDK; Android uses a statically-linked gdbserver so developers can use the latest gdb even on old devices.

There is no separate libpthread, libresolv, or librt on Android – the functionality is all in libc. For libpthread, there's no attempt to optimize for the single-threaded case because apps are in a multi-threaded environment even before the first instruction of third-party code is ever run.

The Android platform now uses libc++ for the C++ standard library (releases up to and including Lollipop used stlport). The NDK currently offers stlport, libc++, and the GNU STL.

Differences from POSIX

Although bionic aims to implement all of POSIX, there are still (as of Lollipop) almost 200 functions missing[citation needed] (though the long double complex math functions make up a large chunk of that). There are also POSIX functions such as the endpwent/getpwent/setpwent family that are inapplicable to Android because it lacks a passwd database.

Some functions deliberately to do not conform to the POSIX standard for security reasons, such as printf which does not support the %n format string.[8]

Relationship to the NDK

Platform code uses bionic directly, but third-party developers use the Android Native Development Kit (NDK). Many third-party developers still target Gingerbread, which contributes to a widespread belief that bionic lacks many features (Lollipop's bionic contains more than 200 functions missing from Gingerbread's[citation needed]).

Fortify source

As of Android Jelly Bean MR1 (4.2), bionic supports a growing subset of glibc's _FORTIFY_SOURCE,[9] which is a feature where unsafe string and memory functions (such as strcpy() strcat() and memcpy()) include checks for buffer overruns when buffer sizes can be determined at compile time. This feature works better with gcc than with Clang, and—because it relies on runtime support from libc—limits portability to older Android releases.[10] The platform itself is built with _FORTIFY_SOURCE enabled.

Controversies

For the creation of Bionic, Google used GPLv2-licensed Linux kernel header files. To get rid of the GPL, Google claimed that it cleaned the header files from any copyright-able work, reducing them to non-copyrightable "facts".[11][12] Google's behaviour was considered by Linus Torvalds as acceptable,[12] but their interpretation of the GPL has been challenged, for instance by Raymond Nimmer, a law professor at the University of Houston Law Center.[13]

See also

References

  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. 2.0 2.1 Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Anatomy Physiology of an Android on androidteam.googlecode.com, Page 36: "License: we want to keep GPL out of user-space"
  6. Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. Google android and the linux headers on theregister.com (2011)
  12. 12.0 12.1 Android: Sued by Microsoft, not by Linux "Microsoft launches new Android suit, Linus Torvalds' take on Linux kernel headers and Android" on ITworld (March 21, 2011)
  13. Infringement and disclosure risk in development on copyleft platforms on ipinfoblog.com by Raymond Nimmer (2011)

External links