<s>
Bionic	B-Application
is	O
an	O
implementation	O
of	O
the	O
standard	B-Language
C	I-Language
library	I-Language
,	O
developed	O
by	O
Google	B-Application
for	O
its	O
Android	B-Application
operating	I-Application
system	I-Application
.	O
</s>
<s>
It	O
differs	O
from	O
the	O
GNU	B-Language
C	I-Language
Library	I-Language
(	O
glibc	B-Language
)	O
in	O
being	O
designed	O
for	O
devices	O
with	O
less	O
memory	O
and	O
processor	O
power	O
than	O
a	O
typical	O
Linux	B-Operating_System
system	O
.	O
</s>
<s>
It	O
is	O
a	O
combination	O
of	O
new	O
code	O
and	O
code	O
from	O
FreeBSD	B-Operating_System
,	O
NetBSD	B-Device
,	O
and	O
OpenBSD	B-Operating_System
released	O
under	O
a	O
BSD	B-Operating_System
license	I-Operating_System
,	O
rather	O
than	O
glibc	B-Language
,	O
which	O
uses	O
the	O
GNU	B-Application
Lesser	I-Application
General	I-Application
Public	I-Application
License	I-Application
.	O
</s>
<s>
This	O
difference	O
was	O
important	O
in	O
the	O
early	O
days	O
of	O
Android	B-Application
,	O
when	O
static	B-Library
linking	I-Library
was	O
common	O
,	O
and	O
is	O
still	O
helpful	O
in	O
introducing	O
Android	B-Application
to	O
software	O
companies	O
used	O
to	O
proprietary	B-Application
operating	B-General_Concept
systems	I-General_Concept
,	O
who	O
can	O
be	O
wary	O
of	O
the	O
LGPL	B-Application
,	O
and	O
unclear	O
about	O
the	O
differences	O
between	O
it	O
and	O
the	O
full	O
GNU	B-License
General	I-License
Public	I-License
License	I-License
(	O
GPL	B-License
)	O
.	O
</s>
<s>
Bionic	B-Application
is	O
a	O
C	B-Language
library	I-Language
for	O
use	O
with	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
and	O
provides	O
libc	B-Language
,	O
libdl	O
,	O
and	O
libm	O
(	O
libpthread	B-Operating_System
functionality	O
is	O
part	O
of	O
libc	B-Language
,	O
not	O
a	O
separate	O
library	O
as	O
on	O
some	O
other	O
systems	O
)	O
.	O
</s>
<s>
This	O
differs	O
from	O
the	O
BSD	B-Operating_System
C	B-Language
libraries	I-Language
that	O
bionic	B-Application
shares	O
code	O
with	O
,	O
because	O
they	O
require	O
a	O
BSD	B-Operating_System
kernel	B-Operating_System
.	O
</s>
<s>
The	O
original	O
publicly	O
stated	O
goals	O
for	O
Bionic	B-Application
were	O
the	O
following	O
:	O
</s>
<s>
BSD-licensed	B-Operating_System
:	O
Google	B-Application
wanted	O
to	O
isolate	O
Android	B-Application
applications	I-Application
from	O
the	O
effect	O
of	O
copyleft	B-License
licenses	I-License
to	O
create	O
a	O
proprietary	B-Application
user-space	B-Operating_System
and	O
application	O
ecosystem	O
,	O
but	O
:	O
</s>
<s>
Android	B-Application
is	O
based	O
on	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
which	O
is	O
subject	O
to	O
the	O
copyleft	B-License
GNU	B-License
General	I-License
Public	I-License
License	I-License
(	O
GPL	B-License
)	O
version	O
2	O
.	O
</s>
<s>
The	O
most	O
widespread	O
standard	B-Language
C	I-Language
library	I-Language
for	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
is	O
the	O
GNU	B-Language
C	I-Language
Library	I-Language
(	O
glibc	B-Language
)	O
,	O
which	O
is	O
subject	O
to	O
the	O
GNU	B-Application
Lesser	I-Application
General	I-Application
Public	I-Application
License	I-Application
(	O
LGPL	B-Application
)	O
,	O
also	O
a	O
copyleft	B-License
license	I-License
.	O
</s>
<s>
In	O
contrast	O
to	O
the	O
GPL	B-License
,	O
the	O
LGPL	B-Application
explicitly	O
allows	O
for	O
dynamic	O
linking	O
but	O
it	O
does	O
not	O
allow	O
static	B-Library
linking	I-Library
of	O
proprietary	B-Application
software	I-Application
without	O
providing	O
source	O
code	O
or	O
linkable	O
object	O
files	O
.	O
</s>
<s>
The	O
permissive	B-License
BSD	B-Operating_System
license	I-Operating_System
is	O
a	O
non-copyleft	B-License
license	O
that	O
is	O
compatible	O
in	O
both	O
directions	O
.	O
</s>
<s>
A	O
BSD-licensed	B-Operating_System
glibc	B-Language
substitute	B-General_Concept
could	O
act	O
as	O
an	O
isolation	O
layer	O
between	O
the	O
copyleft	B-License
core	O
(	O
kernel	B-Operating_System
)	O
and	O
the	O
non-copyleft	B-License
applications	O
,	O
and	O
was	O
therefore	O
chosen	O
by	O
Google	B-Application
for	O
its	O
Bionic	B-Application
as	O
a	O
glibc	B-Language
substitute	B-General_Concept
.	O
</s>
<s>
Small	O
size	O
:	O
Bionic	B-Application
was	O
much	O
smaller	O
than	O
the	O
GNU	B-Language
C	I-Language
Library	I-Language
;	O
more	O
importantly	O
its	O
memory	O
requirements	O
were	O
(	O
and	O
remain	O
)	O
much	O
lower	O
.	O
</s>
<s>
Speed	O
:	O
Bionic	B-Application
was	O
designed	O
for	O
CPUs	O
at	O
relatively	O
low	O
clock	O
frequencies	O
.	O
</s>
<s>
Bionic	B-Application
only	O
supports	O
Linux	B-Operating_System
kernels	I-Operating_System
,	O
but	O
currently	O
supports	O
the	O
arm	B-Architecture
,	O
arm64	B-Architecture
,	O
riscv64	B-Device
,	O
x86	B-Operating_System
,	O
and	O
x86-64	B-Device
architectures	O
.	O
</s>
<s>
The	O
platform	O
itself	O
required	O
armv7	O
with	O
Neon	O
since	O
Marshmallow	B-Application
,	O
though	O
the	O
Android	B-Application
Native	O
Development	O
Kit	O
(	O
NDK	O
)	O
continued	O
to	O
support	O
armv5	O
(	O
which	O
it	O
called	O
armeabi	O
)	O
up	O
until	O
NDK	O
r16	O
.	O
</s>
<s>
Some	O
parts	O
of	O
the	O
libc	B-Language
source	O
,	O
such	O
as	O
stdio	B-Language
,	O
are	O
from	O
the	O
BSDs	B-Operating_System
(	O
mainly	O
OpenBSD	B-Operating_System
)	O
,	O
whereas	O
others	O
,	O
such	O
as	O
the	O
pthread	B-Operating_System
implementation	O
,	O
were	O
written	O
from	O
scratch	O
.	O
</s>
<s>
The	O
dynamic	B-Language
memory	I-Language
allocator	I-Language
implementation	O
has	O
changed	O
over	O
time	O
.	O
</s>
<s>
Before	O
Lollipop	B-Application
there	O
was	O
a	O
single	O
native	O
memory	O
allocator	O
,	O
Doug	O
Lea	O
's	O
dlmalloc	O
.	O
</s>
<s>
For	O
Lollipop	B-Application
and	O
Marshmallow	B-Application
there	O
were	O
two	O
implementations	O
:	O
dlmalloc	O
and	O
jemalloc	O
.	O
</s>
<s>
For	O
Nougat	B-Application
through	O
Android	B-Application
10	I-Application
,	O
all	O
devices	O
use	O
jemalloc	O
.	O
</s>
<s>
In	O
Android	B-Application
11	I-Application
,	O
the	O
memory	O
allocator	O
for	O
most	O
devices	O
was	O
switched	O
to	O
Scudo	O
,	O
which	O
sacrifices	O
some	O
of	O
jemalloc	O
's	O
high	O
performance	O
for	O
additional	O
security	O
hardening	O
features	O
.	O
</s>
<s>
(	O
Zygote	O
is	O
an	O
Android	B-Application
system	I-Application
service	O
that	O
is	O
the	O
parent	O
of	O
all	O
Android	B-Application
application	I-Application
processes	O
.	O
)	O
</s>
<s>
The	O
libm	O
source	O
is	O
largely	O
FreeBSD	B-Operating_System
's	O
,	O
but	O
with	O
optimized	O
assembler	O
contributed	O
by	O
the	O
various	O
SoC	B-Architecture
vendors	O
.	O
</s>
<s>
Bionic	B-Application
does	O
n't	O
include	O
libthread_db	O
(	O
used	O
by	O
gdbserver	B-Application
)	O
,	O
but	O
the	O
NDK	O
does	O
.	O
</s>
<s>
The	O
Android	B-Application
platform	I-Application
includes	O
a	O
statically	O
linked	O
gdbserver	B-Application
,	O
so	O
that	O
developers	O
can	O
use	O
the	O
latest	O
gdb	B-Language
even	O
on	O
old	O
devices	O
.	O
</s>
<s>
There	O
is	O
no	O
separate	O
libpthread	B-Operating_System
,	O
libresolv	O
,	O
or	O
librt	O
on	O
Android	B-Application
the	O
functionality	O
is	O
all	O
in	O
libc	B-Language
.	O
</s>
<s>
For	O
libpthread	B-Operating_System
,	O
there	O
's	O
no	O
attempt	O
to	O
optimize	O
for	O
the	O
single-threaded	O
case	O
because	O
apps	O
are	O
in	O
a	O
multi-threaded	O
environment	O
even	O
before	O
the	O
first	O
instruction	O
of	O
third-party	O
code	O
is	O
ever	O
run	O
.	O
</s>
<s>
The	O
Android	B-Application
platform	I-Application
uses	O
libc++	O
for	O
the	O
C++	O
standard	O
library	O
(	O
releases	O
up	O
to	O
and	O
including	O
Lollipop	B-Application
used	O
stlport	B-Application
)	O
.	O
</s>
<s>
The	O
NDK	O
historically	O
offered	O
stlport	B-Application
and	O
GNU	O
libstdc++	O
,	O
but	O
those	O
were	O
removed	O
as	O
of	O
NDK	O
r18	O
.	O
</s>
<s>
Note	O
that	O
if	O
any	O
native	O
code	O
in	O
an	O
Android	B-Application
app	O
uses	O
C++	O
,	O
all	O
the	O
C++	O
must	O
use	O
the	O
same	O
STL	B-Application
.	O
</s>
<s>
The	O
STL	B-Application
is	O
not	O
provided	O
by	O
the	O
Android	B-Application
OS	I-Application
,	O
and	O
must	O
be	O
bundled	O
with	O
each	O
app	O
.	O
</s>
<s>
Although	O
Bionic	B-Application
aims	O
to	O
implement	O
all	O
of	O
C11	O
and	O
POSIX	O
,	O
there	O
are	O
still	O
(	O
as	O
of	O
Oreo	B-Application
)	O
about	O
70	O
POSIX	O
functions	O
missing	O
from	O
libc	B-Language
.	O
</s>
<s>
There	O
are	O
also	O
POSIX	O
functions	O
such	O
as	O
the	O
endpwent/getpwent/setpwent	O
family	O
that	O
are	O
inapplicable	O
to	O
Android	B-Application
because	O
it	O
lacks	O
a	O
passwd	B-Protocol
database	O
.	O
</s>
<s>
As	O
of	O
Oreo	B-Application
,	O
libm	O
is	O
complete	O
.	O
</s>
<s>
Some	O
functions	O
deliberately	O
do	O
not	O
conform	O
to	O
the	O
POSIX	O
or	O
C	O
standards	O
for	O
security	O
reasons	O
,	O
such	O
as	O
printf	B-Language
which	O
does	O
not	O
support	O
the	O
%n	O
format	B-Language
string	I-Language
.	O
</s>
<s>
Many	O
of	O
the	O
most-used	O
GNU	O
extensions	O
are	O
implemented	O
in	O
Bionic	B-Application
,	O
as	O
are	O
various	O
BSD	B-Operating_System
extensions	O
.	O
</s>
<s>
Platform	O
code	O
uses	O
Bionic	B-Application
directly	O
,	O
but	O
third-party	O
developers	O
use	O
the	O
Android	B-Application
Native	O
Development	O
Kit	O
(	O
NDK	O
)	O
.	O
</s>
<s>
Many	O
third-party	O
developers	O
still	O
target	O
older	O
OS	O
releases	O
,	O
which	O
contributes	O
to	O
a	O
widespread	O
belief	O
that	O
bionic	B-Application
lacks	O
many	O
features	O
.	O
</s>
<s>
Gingerbread	B-Application
exported	O
803	O
functions	O
from	O
libc	B-Language
but	O
Oreo	B-Application
exports	O
1278	O
(	O
a	O
1.6x	O
increase	O
)	O
.	O
</s>
<s>
This	O
work	O
initially	O
focused	O
on	O
the	O
GCC	B-Application
and	O
Clang	B-Application
compilers	O
.	O
</s>
<s>
In	O
the	O
Oreo	B-Application
development	O
period	O
the	O
platform	O
headers	O
were	O
annotated	O
with	O
API	O
level	O
information	O
so	O
that	O
the	O
same	O
set	O
of	O
headers	O
can	O
be	O
used	O
for	O
all	O
API	O
levels	O
,	O
with	O
only	O
those	O
functions	O
available	O
at	O
the	O
developer	O
's	O
targeted	O
API	O
level	O
being	O
visible	O
.	O
</s>
<s>
Prior	O
to	O
NDK	O
r16	O
,	O
the	O
NDK	O
linked	O
a	O
library	O
called	O
libandroid_support.a	O
to	O
code	O
using	O
libc++	O
.	O
</s>
<s>
This	O
provided	O
functions	O
required	O
by	O
libc++	O
that	O
were	O
n't	O
in	O
old	O
OS	O
releases	O
.	O
</s>
<s>
This	O
was	O
n't	O
the	O
same	O
code	O
used	O
by	O
the	O
platform	O
and	O
introduced	O
numerous	O
bugs	O
(	O
such	O
as	O
breaking	O
positional	O
arguments	O
to	O
the	O
printf	B-Language
family	O
in	O
any	O
code	O
that	O
used	O
libc++	O
)	O
.	O
</s>
<s>
As	O
of	O
Android	B-Application
Jelly	I-Application
Bean	I-Application
MR1	O
(	O
4.2	O
)	O
,	O
Bionic	B-Application
supports	O
similar	O
functionality	O
to	O
glibc	B-Language
's	O
_FORTIFY_SOURCE	O
,	O
which	O
is	O
a	O
feature	O
where	O
unsafe	O
string	O
and	O
memory	O
functions	O
(	O
such	O
as	O
strcpy( )	O
,	O
strcat( )	O
,	O
and	O
memcpy( )	O
)	O
include	O
checks	O
for	O
buffer	O
overruns	O
.	O
</s>
<s>
Because	O
fortify	O
relies	O
on	O
runtime	O
support	O
from	O
libc	B-Language
,	O
its	O
portability	O
to	O
older	O
Android	B-Application
releases	O
is	O
limited	O
.	O
</s>
<s>
Historically	O
,	O
one	O
of	O
the	O
shortcomings	O
of	O
fortify	O
has	O
been	O
that	O
it	O
is	O
closely	O
tied	O
with	O
GCC	B-Application
,	O
which	O
makes	O
it	O
very	O
difficult	O
to	O
support	O
well	O
in	O
other	O
compilers	O
,	O
like	O
Clang	B-Application
.	O
</s>
<s>
This	O
meant	O
that	O
when	O
Android	B-Application
swapped	O
to	O
Clang	B-Application
as	O
its	O
default	O
compiler	O
,	O
Bionic	B-Application
's	O
fortify	O
implementation	O
became	O
substantially	O
less	O
useful	O
.	O
</s>
<s>
In	O
Android	B-Application
Oreo	I-Application
(	O
8.0	O
)	O
,	O
Bionic	B-Application
's	O
fortify	O
was	O
overhauled	O
with	O
Clang	B-Application
in	O
mind	O
,	O
resulting	O
in	O
fortify	O
on	O
Clang	B-Application
providing	O
an	O
experience	O
on	O
par	O
with	O
fortify	O
on	O
GCC	B-Application
.	O
</s>
<s>
Since	O
this	O
overhaul	O
,	O
some	O
checks	O
were	O
added	O
above	O
and	O
beyond	O
glibc	B-Language
's	O
to	O
catch	O
code	O
that	O
—	O
while	O
not	O
necessarily	O
causing	O
undefined	O
behavior	O
—	O
is	O
obviously	O
incorrect	O
.	O
</s>
<s>
Because	O
this	O
new	O
implementation	O
requires	O
no	O
more	O
libc	B-Language
support	O
than	O
the	O
prior	O
one	O
,	O
the	O
Clang-specific	O
enhancements	O
are	O
available	O
to	O
applications	O
targeting	O
versions	O
of	O
Android	B-Application
before	O
Oreo	B-Application
.	O
</s>
<s>
For	O
the	O
creation	O
of	O
Bionic	B-Application
,	O
Google	B-Application
used	O
GPLv2-licensed	O
Linux	B-Operating_System
kernel	I-Operating_System
header	B-Language
files	I-Language
.	O
</s>
<s>
To	O
get	O
rid	O
of	O
the	O
GPL	B-License
,	O
Google	B-Application
claimed	O
that	O
it	O
cleaned	O
the	O
header	B-Language
files	I-Language
from	O
any	O
copyright-able	O
work	O
,	O
reducing	O
them	O
to	O
non-copyrightable	O
"	O
facts	O
"	O
.	O
</s>
<s>
Linux	B-Operating_System
creator	O
Linus	O
Torvalds	O
considered	O
Google	B-Application
's	I-Application
behaviour	O
to	O
be	O
acceptable	O
,	O
but	O
Google	B-Application
's	I-Application
interpretation	O
of	O
the	O
GPL	B-License
has	O
been	O
challenged	O
,	O
for	O
instance	O
by	O
Raymond	O
Nimmer	O
,	O
a	O
law	O
professor	O
at	O
the	O
University	O
of	O
Houston	O
Law	O
Center	O
.	O
</s>
