|
@@ -2,8 +2,8 @@
|
|
<title>Why do we use static linking?</title>
|
|
<title>Why do we use static linking?</title>
|
|
<?dbhtml filename="whystatic.html" dir="chapter05"?>
|
|
<?dbhtml filename="whystatic.html" dir="chapter05"?>
|
|
|
|
|
|
-<para>Thanks to Plasmatic for posting the text on which this is mainly
|
|
|
|
-based to one of the LFS mailing lists.</para>
|
|
|
|
|
|
+<para>(Thanks to Plasmatic for posting the text on which this is mainly
|
|
|
|
+based to one of the LFS mailing lists.)</para>
|
|
|
|
|
|
<para>When making (compiling) a program, rather than having to rewrite all the
|
|
<para>When making (compiling) a program, rather than having to rewrite all the
|
|
functions for dealing with the kernel, hardware, files, etc. every time you
|
|
functions for dealing with the kernel, hardware, files, etc. every time you
|
|
@@ -16,15 +16,15 @@ new program, so that it can use any of the functions that the library
|
|
has.</para>
|
|
has.</para>
|
|
|
|
|
|
<para>However, these libraries can be very large (for example, libc.a
|
|
<para>However, these libraries can be very large (for example, libc.a
|
|
-can often be around 2.5MB), so you may not want a separate copy of each
|
|
|
|
|
|
+can often be around 2.5 MB), so you may not want a separate copy of each
|
|
library attached to the program. Just imagine if you had a simple command
|
|
library attached to the program. Just imagine if you had a simple command
|
|
-like ls with an extra 2.5MB attached to it! Instead of making the library
|
|
|
|
|
|
+like ls with an extra 2.5 MB attached to it! Instead of making the library
|
|
an actual part of the program, or statically linked, the library is kept a
|
|
an actual part of the program, or statically linked, the library is kept a
|
|
separate file, which is loaded only when the program needs it. This is what
|
|
separate file, which is loaded only when the program needs it. This is what
|
|
we call dynamically linked, as the library is loaded and unloaded dynamically,
|
|
we call dynamically linked, as the library is loaded and unloaded dynamically,
|
|
as the program needs it.</para>
|
|
as the program needs it.</para>
|
|
|
|
|
|
-<para>So now we have a 1KB file and a 2.5MB file, but we still haven't saved any
|
|
|
|
|
|
+<para>So now we have a 1 KB file and a 2.5 MB file, but we still haven't saved any
|
|
space (except maybe RAM until the library is needed). The REAL advantage to
|
|
space (except maybe RAM until the library is needed). The REAL advantage to
|
|
dynamically linked libraries is that we only need one copy of the library.
|
|
dynamically linked libraries is that we only need one copy of the library.
|
|
If <filename>ls</filename> and <filename>rm</filename> both use the same
|
|
If <filename>ls</filename> and <filename>rm</filename> both use the same
|