<s>
In	O
computing	O
,	O
prebinding	B-Library
,	O
also	O
called	O
prelinking	B-Library
,	O
is	O
a	O
method	O
for	O
optimizing	O
application	O
load	B-Operating_System
times	I-Operating_System
by	O
resolving	O
library	O
symbols	O
prior	O
to	O
launch	O
.	O
</s>
<s>
Most	O
computer	B-Application
programs	I-Application
consist	O
of	O
code	O
that	O
requires	O
external	O
shared	O
libraries	O
to	O
execute	O
.	O
</s>
<s>
These	O
libraries	O
are	O
normally	O
integrated	O
with	O
the	O
program	B-Application
at	O
run	O
time	O
by	O
a	O
loader	B-Operating_System
,	O
in	O
a	O
process	O
called	O
dynamic	B-Application
linking	I-Application
.	O
</s>
<s>
While	O
dynamic	B-Application
linking	I-Application
has	O
advantages	O
in	O
code	O
size	O
and	O
management	O
,	O
there	O
are	O
drawbacks	O
as	O
well	O
.	O
</s>
<s>
Every	O
time	O
a	O
program	B-Application
is	O
run	O
,	O
the	O
loader	B-Operating_System
needs	O
to	O
resolve	O
(	O
find	O
)	O
the	O
relevant	O
libraries	O
.	O
</s>
<s>
Prelinking	B-Library
reduces	O
this	O
penalty	O
by	O
resolving	O
libraries	O
in	O
advance	O
.	O
</s>
<s>
Afterward	O
,	O
resolution	O
only	O
occurs	O
if	O
the	O
libraries	O
have	O
changed	O
since	O
being	O
prelinked	B-Library
,	O
such	O
as	O
following	O
perhaps	O
an	O
upgrade	O
.	O
</s>
<s>
Mac	O
OS	O
stores	O
executables	B-Application
in	O
the	O
Mach-O	B-Operating_System
file	O
format	O
.	O
</s>
<s>
Mac	B-Operating_System
OS	I-Operating_System
X	I-Operating_System
performs	O
prebinding	B-Library
in	O
the	O
"	O
Optimizing	O
"	O
stage	O
of	O
installing	O
system	O
software	O
or	O
certain	O
applications	O
.	O
</s>
<s>
Prebinding	B-Library
has	O
changed	O
a	O
few	O
times	O
within	O
the	O
Mac	B-Operating_System
OS	I-Operating_System
X	I-Operating_System
series	O
.	O
</s>
<s>
Before	O
10.2	O
,	O
prebinding	B-Library
only	O
happened	O
during	O
the	O
installation	O
procedure	O
(	O
the	O
aforementioned	O
"	O
Optimizing	O
"	O
stage	O
)	O
.	O
</s>
<s>
From	O
10.2	O
through	O
10.3	O
the	O
OS	O
checked	O
for	O
prebinding	B-Library
at	O
launch	O
time	O
for	O
applications	O
,	O
and	O
the	O
first	O
time	O
an	O
application	O
ran	O
it	O
would	O
be	O
prebound	O
,	O
making	O
subsequent	O
launches	O
faster	O
.	O
</s>
<s>
In	O
10.5	O
and	O
later	O
,	O
Apple	O
replaced	O
prebinding	B-Library
with	O
a	O
dyld	B-Application
shared	O
cache	B-General_Concept
mechanism	O
,	O
which	O
provided	O
better	O
OS	O
performance	O
.	O
</s>
<s>
On	O
Linux	O
,	O
prelinking	B-Library
is	O
accomplished	O
via	O
the	O
prelink	B-Library
program	B-Application
,	O
a	O
free	B-Application
program	B-Application
written	O
by	O
Jakub	O
Jelínek	O
of	O
Red	O
Hat	O
for	O
ELF	O
binaries	B-Application
.	O
</s>
<s>
Performance	O
results	O
have	O
been	O
mixed	O
,	O
but	O
it	O
seems	O
to	O
aid	O
systems	O
with	O
a	O
large	O
number	O
of	O
libraries	O
,	O
such	O
as	O
KDE	B-Application
.	O
</s>
<s>
When	O
run	O
with	O
the	O
"	O
-R	O
"	O
option	O
,	O
prelink	B-Library
will	O
randomly	O
select	O
the	O
address	O
base	O
where	O
libraries	O
are	O
loaded	O
.	O
</s>
<s>
This	O
selection	O
makes	O
a	O
return-to-libc	B-Language
attack	I-Language
harder	O
to	O
perform	O
because	O
the	O
addresses	O
are	O
unique	O
to	O
that	O
system	O
.	O
</s>
<s>
The	O
reason	O
prelink	B-Library
does	O
this	O
is	O
because	O
kernel	O
facilities	O
supplying	O
address	O
space	O
layout	O
randomization	O
(	O
ASLR	O
)	O
for	O
libraries	O
cannot	O
be	O
used	O
in	O
conjunction	O
with	O
prelink	B-Library
without	O
defeating	O
the	O
purpose	O
of	O
prelink	B-Library
and	O
forcing	O
the	O
dynamic	B-Application
linker	I-Application
to	O
perform	O
relocations	B-Library
at	O
program	B-Application
load	B-Operating_System
time	I-Operating_System
.	O
</s>
<s>
As	O
stated	O
,	O
prelink	B-Library
and	O
per-process	O
library	O
address	O
randomization	O
cannot	O
be	O
used	O
in	O
conjunction	O
.	O
</s>
<s>
In	O
order	O
to	O
avoid	O
completely	O
removing	O
this	O
security	O
enhancement	O
,	O
prelink	B-Library
supplies	O
its	O
own	O
randomization	O
;	O
however	O
,	O
this	O
does	O
not	O
help	O
a	O
general	O
information	O
leak	O
caused	O
by	O
prelink	B-Library
.	O
</s>
<s>
Attackers	O
with	O
the	O
ability	O
to	O
read	O
certain	O
arbitrary	O
files	O
on	O
the	O
target	O
system	O
can	O
discover	O
where	O
libraries	O
are	O
loaded	O
in	O
privileged	O
daemons	O
;	O
often	O
libc	O
is	O
enough	O
as	O
it	O
is	O
the	O
most	O
common	O
library	O
used	O
in	O
return-to-libc	B-Language
attacks	O
.	O
</s>
<s>
Because	O
prelink	B-Library
is	O
often	O
run	O
periodically	O
,	O
typically	O
every	O
two	O
weeks	O
,	O
the	O
address	O
of	O
any	O
given	O
library	O
has	O
a	O
chance	O
of	O
changing	O
over	O
time	O
.	O
</s>
<s>
prelink	B-Library
is	O
often	O
used	O
in	O
an	O
incremental	O
mode	O
in	O
which	O
already	O
prelinked	B-Library
libraries	O
are	O
not	O
altered	O
unless	O
absolutely	O
necessary	O
,	O
so	O
a	O
library	O
may	O
not	O
change	O
its	O
base	O
address	O
when	O
prelink	B-Library
is	O
re-run	O
.	O
</s>
<s>
This	O
gives	O
any	O
address	O
derived	O
a	O
half-life	O
of	O
the	O
period	O
in	O
which	O
prelink	B-Library
is	O
run	O
.	O
</s>
<s>
Jakub	O
Jelínek	O
points	O
out	O
that	O
position	B-Operating_System
independent	I-Operating_System
executables	I-Operating_System
(	O
PIE	O
)	O
ignore	O
prelinking	B-Library
on	O
Red	O
Hat	O
Enterprise	O
Linux	O
and	O
Fedora	O
,	O
and	O
recommends	O
that	O
network	O
and	O
SUID	O
programs	O
be	O
built	O
PIE	O
to	O
facilitate	O
a	O
more	O
secure	O
environment	O
.	O
</s>
<s>
Occasionally	O
,	O
prelinking	B-Library
can	O
cause	O
issues	O
with	O
application	B-General_Concept
checkpoint	I-General_Concept
and	O
restart	O
libraries	O
like	O
blcr	O
,	O
as	O
well	O
as	O
other	O
libraries	O
(	O
like	O
OpenMPI	B-Library
)	O
that	O
use	O
blcr	O
internally	O
.	O
</s>
<s>
Specifically	O
when	O
checkpointing	B-General_Concept
a	O
program	B-Application
on	O
one	O
host	O
,	O
and	O
trying	O
to	O
restart	O
on	O
a	O
different	O
host	O
,	O
the	O
restarted	O
program	B-Application
may	O
fail	O
with	O
a	O
segfault	B-Error_Name
due	O
to	O
differences	O
in	O
host-specific	O
library	O
memory	O
address	O
randomization	O
.	O
</s>
