Android bionic和GNU glibc

insert image description here

Android bionic和GNU glibc

Android runs bionic not glibc. Bionic is an implementation of the standard C library, developed by Google for its Android operating system. It differs from the GNU C library (glibc) (which runs on standard linux distributions) in that it is designed for devices with less memory and processor power than a typical linux system. Android also doesn't include all the GNU libraries you'd find on a typical Linux distribution. It also doesn't include an X server like Xorg, so you can't run standard graphical Linux applications.

This means that all libraries compiled for standard linux will not work with android unless you cross compile them with android NDK to use bionic. This seems like a lot of work, and there's simply no guarantee that all libraries used by openpilot will compile with bionic for the arm architecture. The problem is not the arm architecture, it is widely supported and almost all libraries available on standard x86-linux distributions are also available for arm. The main problem is bionic. Almost none of the libraries are precompiled based on bionic.

Summarize

libc is a standard. GNU C (glibc) is an implementation based on the libc standard, and the GNU compilation tool chain defaults to this glibc library, so when you use window to compile C language, Ubuntu to compile C language, or cross compiler to compile C language, the default Will link the glibc library. So you can use functions like printf and fopen across multiple platforms.

Bionic is also an implementation based on the libc standard. It is not in a compilation toolchain such as GNU. It is a new implementation of Google based on libc for android. It's in the android NDK compilation toolchain.

In the system of ubuntu and window image interface, the bottom layer is Linux Kernel or other kernels, and the kernel supports libc, so the upper layer supports glibc, and can also support bionic.
However, in the system of ubuntu and window image interface, there are many other various libraries in the upper layer, and these libraries will depend on glibc. So you can't transplant some upper-layer applications of ubuntu and window to Android

For the TEE system, you must be very curious, does it support glibc? Does he support libc? How to support?
Since the tee kernel does not support libc, you cannot support glibc or bionic in the upper layer.
For example, optee does not support libc, but he has created an original one, which supports libutee. But there is no standard for this one, and each TEE needs to implement its own C library independently.
But it’s okay, in the development concept of TEE, you don’t need to care about the support of the C library, you only need to care about whether the GP API is supported.

Code guide:

GNU glibc
Android bionic
libutee

Guess you like

Origin blog.csdn.net/weixin_42135087/article/details/131513877