r1164 - in trunk/BOOK: . chapter01 chapter05

robert at linuxfromscratch.org robert at linuxfromscratch.org
Sat Jun 16 05:49:00 PDT 2007


Author: robert
Date: 2007-06-16 06:49:00 -0600 (Sat, 16 Jun 2007)
New Revision: 1164

Modified:
   trunk/BOOK/chapter01/changelog.xml
   trunk/BOOK/chapter05/embryo-toolchain.xml
   trunk/BOOK/general.ent
Log:
Clairify and explain why we need -fpic in the first toolchain

Modified: trunk/BOOK/chapter01/changelog.xml
===================================================================
--- trunk/BOOK/chapter01/changelog.xml	2007-06-16 12:08:45 UTC (rev 1163)
+++ trunk/BOOK/chapter01/changelog.xml	2007-06-16 12:49:00 UTC (rev 1164)
@@ -49,6 +49,16 @@
 -->
 
     <listitem>
+      <para>June 16th, 2007</para>
+      <itemizedlist>
+        <listitem>
+          <para>[robert]: Clairify and explain why we need -fpic in the first
+          toolchain.</para>
+        </listitem>
+      </itemizedlist>
+    </listitem>
+
+    <listitem>
       <para>June 14th, 2007</para>
       <itemizedlist>
         <listitem>

Modified: trunk/BOOK/chapter05/embryo-toolchain.xml
===================================================================
--- trunk/BOOK/chapter05/embryo-toolchain.xml	2007-06-16 12:08:45 UTC (rev 1163)
+++ trunk/BOOK/chapter05/embryo-toolchain.xml	2007-06-16 12:49:00 UTC (rev 1164)
@@ -59,22 +59,38 @@
     <filename class="directory">include</filename> directory, for
     binutils-&binutils-version; to compile correctly.</para>
 
-    <para role="aslr">There is a circular dependency issue when we will build
-    libc's utilities as Position Independent Executable's (PIE's). The
-    start-files from this toolchain are used when building libc, and the second
-    toolchain we build in this chapter uses files from libc which were linked
-    to files from this toolchain. The smoothest way of dealing with this is to
-    add the <option>-fPIC</option> option to this GCC's specs file, and during
-    the bootstrap we will begin to escape from a non-position-independent-code
-    toolchain. The libc in this chapter will also be built with
-    <option>-fPIC</option>, and we will have sucessfully built a purely PIC
-    toolchain which can in turn build a purely PIC final system. Add
-    <option>-fPIC</option> to the GCC specs file with the following command:</para>
+    <para role="aslr">There are several reasons we need this compiler to use
+    <option>-fPIC</option> by default, and at this stage. The start-files
+    built and installed by this compiler will find their way into C library
+    files, and in turn will find their way into the next toolchain. These need
+    to be PIC to begin with the avoid text relocations later on. The
+    <filename class="libraryfile">libiberty.a</filename> library built in the
+    next toolchain builds two versions when the
+    <parameter>--enable-shared</parameter> <command>configure</command> option
+    is used, a PIC and non-PIC version. The PIC version of the
+    <filename class="libraryfile">libiberty.a</filename> library is
+    explicitly linked to shared libraries by the GCC build system. The non-PIC
+    version of the <filename class="libraryfile">libiberty.a</filename>
+    library is explicitly linked to program files. In our environment the
+    program files will be shared objects, but if linked to a non-PIC library
+    then the program files will not be position independent. Using the
+    <option>-fPIC</option> option on everything, including both versions of
+    <filename class="libraryfile">libiberty.a</filename> will help ensure our
+    next toolchain builds itself correctly. The <option>-fPIC</option> option
+    is not as ideal for program files as the <option>-fPIE</option> option,
+    because the <option>-fPIE</option> option allows the program to be
+    optimized better. But at this stage it is the simplest option to use, and
+    will not reflect on to the performance of the final system.</para>
 
-<!-- Note: -fPIC is also needed here so that libssp.a will be pic when used
-with uClibc to build the next toolchain. Otherwise 'gcc -lssp -pie' = TEXTREL.
--->
+    <para role="aslr" condition="uclibc">Furthermore, we are using the
+    <filename class="libraryfile">libssp.a</filename> static library to
+    provide SSP functions during the early stages of the uClibc system. This
+    library must also be PIC because it will be linked to shared libraries in
+    the next toolchain.</para>
 
+    <para role="aslr">Modify this GCC to use the <option>-fPIC</option> option
+    by default with the following command:</para>
+
 <screen role="aslr"><userinput>cp -vi gcc/config/i386/linux.h{,.orig}
 sed 's/^\(#define CC1_SPEC.*\)\("\)$/\1 %{fno-pic|fpic|fPIC:;:-fPIC}\2/' \
     gcc/config/i386/linux.h.orig > gcc/config/i386/linux.h</userinput></screen>

Modified: trunk/BOOK/general.ent
===================================================================
--- trunk/BOOK/general.ent	2007-06-16 12:08:45 UTC (rev 1163)
+++ trunk/BOOK/general.ent	2007-06-16 12:49:00 UTC (rev 1164)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!ENTITY version "SVN-20070614">
-<!ENTITY releasedate "June 14th, 2007">
+<!ENTITY version "SVN-20070616">
+<!ENTITY releasedate "June 16th, 2007">
 <!ENTITY milestone "1.1">
 
 <!ENTITY lfs-root "http://www.linuxfromscratch.org/">




More information about the hlfs-book mailing list