Author: jhuntwork
Date: 2006-01-26 07:45:36 -0700 (Thu, 26 Jan 2006)
New Revision: 7308

Modified:
   trunk/BOOK/chapter01/changelog.xml
   trunk/BOOK/chapter05/binutils-pass2.xml
   trunk/BOOK/chapter06/readjusting.xml
Log:
Adjust chapter 5 binutils to build a static ld-new for use in the chapter 6 
readjusting section.
Also add some extended sanity checks. These fixes are adapted from DIY-Linux 
and Greg Schafer.
Thanks to Dan Nicholson for the report, as well.


Modified: trunk/BOOK/chapter01/changelog.xml
===================================================================
--- trunk/BOOK/chapter01/changelog.xml  2006-01-26 11:52:41 UTC (rev 7307)
+++ trunk/BOOK/chapter01/changelog.xml  2006-01-26 14:45:36 UTC (rev 7308)
@@ -43,6 +43,12 @@
           <para>[jhuntwork] - Modify chapter 6 Glibc's make install command to
          allow test-installation.pl to run.</para>
         </listitem>
+       <listitem>
+         <para>[jhuntwork] - Adjust chapter 5 binutils to build a static ld-new
+         for use in the chapter 6 readjusting section. Also add some extended
+         sanity checks. These fixes are adapted from DIY-Linux and Greg 
Schafer.
+         Thanks to Dan Nicholson for the report, as well.
+       </listitem>
       </itemizedlist>
     </listitem>
 

Modified: trunk/BOOK/chapter05/binutils-pass2.xml
===================================================================
--- trunk/BOOK/chapter05/binutils-pass2.xml     2006-01-26 11:52:41 UTC (rev 
7307)
+++ trunk/BOOK/chapter05/binutils-pass2.xml     2006-01-26 14:45:36 UTC (rev 
7308)
@@ -49,7 +49,7 @@
     <para>Prepare Binutils for compilation:</para>
 
 <screen><userinput>../binutils-&binutils-version;/configure --prefix=/tools \
-    --disable-nls --enable-shared 
--with-lib-path=/tools/lib</userinput></screen>
+    --disable-nls --with-lib-path=/tools/lib</userinput></screen>
 
     <variablelist>
       <title>The meaning of the new configure options:</title>
@@ -80,6 +80,13 @@
 
     <para>Install the package:</para>
 
+    <para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in
+    the next chapter:</para>
+
+<screen><userinput>make -C ld clean
+make -C ld LDFLAGS="-s" LIB_PATH=/usr/lib:/lib
+cp -v ld/ld-new /tools/bin</userinput></screen>
+
 <screen><userinput>make install</userinput></screen>
 
   </sect2>

Modified: trunk/BOOK/chapter06/readjusting.xml
===================================================================
--- trunk/BOOK/chapter06/readjusting.xml        2006-01-26 11:52:41 UTC (rev 
7307)
+++ trunk/BOOK/chapter06/readjusting.xml        2006-01-26 14:45:36 UTC (rev 
7308)
@@ -19,12 +19,17 @@
 directory to the LFS <filename class="directory">/{,usr/}lib</filename>
 directories.</para>
 
-<para>First, amend the GCC specs file so that it points to the new
+<para>First, create a symlink to the adjusted linker we created in chapter 
5.</para>
+
+<screen><userinput>ln -sv /tools/bin/ld-new /usr/bin/ld</userinput></screen>
+
+<para>Next, amend the GCC specs file so that it points to the new
 dynamic linker. A <command>sed</command> command accomplishes this:</para>
 
 <screen><userinput>SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs 
&amp;&amp;
 gcc -dumpspecs > $SPECFILE &amp;&amp;
-sed -i '[EMAIL PROTECTED]/tools/lib/ld-linux.so.2@/lib/[EMAIL PROTECTED]' 
$SPECFILE &amp;&amp;
+sed -i -e '/^\*link:$/{n;s,$, -L/usr/lib,}' \
+       -e '[EMAIL PROTECTED]/tools/lib/ld-linux.so.2@/lib/[EMAIL PROTECTED]' 
$SPECFILE &amp;&amp;
 unset SPECFILE</userinput></screen>
 
 <para>It is a good idea to visually inspect the specs file to verify the 
intended 
@@ -38,20 +43,16 @@
 linkend="ch-tools-toolchaintechnotes" role=","/> if
 necessary.</para></important>
 
-<para>Now create temporary wrapper scripts for <filename>gcc</filename> and
-<filename>ld</filename>. These scripts will point to their real counterparts
+<para>Now create a temporary wrapper script for <filename>gcc</filename>.
+This script will point to the real <filename>gcc</filename>
 in <filename class="directory">/tools</filename> but with adjusted parameters
 to ensure that GCC in the next section links to our newly installed 
Glibc.</para>
 
 <screen><userinput>cat &gt; /usr/bin/gcc &lt;&lt; "EOF"
 #!/bin/bash
-/tools/bin/gcc -B/usr/lib $@
+/tools/bin/gcc -B/usr/lib/ -B/usr/bin/ $@
 EOF
-cat &gt; /usr/bin/ld &lt;&lt; "EOF"
-#!/bin/bash
-/tools/bin/ld -nostdlib -L/usr/lib -L/lib $@
-EOF
-chmod 755 /usr/bin/{ld,gcc}
+chmod 755 /usr/bin/gcc
 ln -s gcc /usr/bin/cc</userinput></screen>
 
 <caution><para>It is imperative at this point to stop and ensure that
@@ -60,7 +61,7 @@
 check:</para>
 
 <screen><userinput>echo 'main(){}' &gt; dummy.c
-cc dummy.c
+cc dummy.c -Wl,--verbose &amp;&gt; dummy.log
 readelf -l a.out | grep ': /lib'</userinput></screen>
 
 <para>If everything is working correctly, there should be no errors,
@@ -72,6 +73,36 @@
 <para>Note that <filename class="directory">/lib</filename> is now
 the prefix of our dynamic linker.</para>
 
+<para>Now make sure that we're setup to use the correct start files:</para>
+
+<screen><userinput>grep "/usr/lib/crt.* " dummy.log</userinput></screen>
+
+<para>If everything is working correctly, there should be no errors,
+and the output of the last command will be:</para>
+
+<screen><computeroutput>attempt to open /usr/lib/crt1.o succeeded
+attempt to open /usr/lib/crti.o succeeded
+attempt to open /usr/lib/crtn.o succeeded</computeroutput></screen>
+
+<para>Next make sure that we're using the correct libc:</para>
+
+<screen><userinput>grep "/lib/libc.so.6 " dummy.log</userinput></screen>
+
+<para>If everything is working correctly, there should be no errors,
+and the output of the last command will be:</para>
+
+<screen><computeroutput>attempt to open /lib/libc.so.6 
succeeded</computeroutput></screen>
+
+<para>Lastly, make sure GCC is using the correct dynamic linker:</para>
+
+<screen><userinput>grep found dummy.log</userinput></screen>
+
+<para>If everything is working correctly, there should be no errors,
+and the output of the last command will be (allowing for
+platform-specific differences in dynamic linker name):</para>
+
+<screen><computeroutput>found ld-linux.so.2 at 
/lib/ld-linux.so.2</computeroutput></screen>
+
 <para>If the output does not appear as shown above or is not received
 at all, then something is seriously wrong. Investigate and retrace the
 steps to find out where the problem is and correct it. The most likely
@@ -82,7 +113,7 @@
 <para>Once everything is working correctly, clean up the test
 files:</para>
 
-<screen><userinput>rm -v dummy.c a.out</userinput></screen></caution>
+<screen><userinput>rm -v dummy.c a.out dummy.log</userinput></screen></caution>
 
 </sect1>
 

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-book
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to