Ignore:
Timestamp:
02/03/2006 06:23:22 PM (19 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Children:
fa994c9
Parents:
b4cd3c5
Message:

Ported r7294 to r7325 from trunk to alphabetical branch.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/alphabetical/BOOK@7333 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter06/readjusting.xml

    rb4cd3c5 re6ab4b5  
    1010<para>Now that the final C libraries have been installed, it is time to adjust
    1111the toolchain again. The toolchain will be adjusted so that it will link any
    12 newly compiled program against these new libraries. This is the same process
     12newly compiled program against these new libraries. This is a similar process
    1313used in the <quote>Adjusting</quote> phase in the beginning of <xref
    1414linkend="chapter-temporary-tools"/>, but with the adjustments reversed. In <xref
     
    2020directories.</para>
    2121
    22 <para>Start by adjusting the linker. The source and build directories from the
    23 second pass of Binutils were retained for this purpose. Install the adjusted
    24 linker by running the following command from within the <filename
    25 class="directory">binutils-build</filename> directory:</para>
     22<para>First, backup the <filename class="directory">/tools</filename> linker, and
     23replace it with the adjusted linker we made in chapter 5. We'll also create a
     24link to its counterpart in <filename class="directory">/tools/$(gcc -dumpmachine)/bin</filename>.</para>
    2625
    27 <screen><userinput>make -C ld INSTALL=/tools/bin/install install</userinput></screen>
    28 
    29 <note><para>If the earlier warning to retain the Binutils source and
    30 build directories from the second pass in <xref
    31 linkend="chapter-temporary-tools"/> was missed, or if they were
    32 accidentally deleted or are inaccessible, ignore the above command.
    33 The result will be that the next package, Binutils, will link against
    34 the C libraries in <filename class="directory">/tools</filename>
    35 rather than in <filename class="directory">/{,usr/}lib</filename>.
    36 This is not ideal, however, testing has shown that the resulting
    37 Binutils program binaries should be identical.</para></note>
    38 
    39 <para>From now on, every compiled program will link only against the
    40 libraries in <filename class="directory">/usr/lib</filename> and
    41 <filename class="directory">/lib</filename>. The extra
    42 <parameter>INSTALL=/tools/bin/install</parameter> option is needed
    43 because the <filename>Makefile</filename> file created during the
    44 second pass still contains the reference to
    45 <command>/usr/bin/install</command>, which has not been installed yet.
    46 Some host distributions contain a <filename
    47 class="symlink">ginstall</filename> symbolic link which takes
    48 precedence in the <filename>Makefile</filename> file and can cause a
    49 problem. The above command takes care of this issue.</para>
    50 
    51 <para>Remove the Binutils source and build directories now.</para>
     26<screen><userinput>mv -v /tools/bin/{ld,ld-old}
     27mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
     28mv -v /tools/bin/{ld-new,ld}
     29ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld</userinput></screen>
    5230
    5331<para>Next, amend the GCC specs file so that it points to the new
    54 dynamic linker. A <command>sed</command> command accomplishes this:</para>
     32dynamic linker, and so that GCC knows where to find its start files.
     33A <command>perl</command> command accomplishes this:</para>
    5534
    56 <screen><userinput>SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs &amp;&amp;
    57 gcc -dumpspecs > $SPECFILE &amp;&amp;
    58 sed -i 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE &amp;&amp;
    59 unset SPECFILE</userinput></screen>
     35<screen><userinput>gcc -dumpspecs | \
     36perl -p -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g;' \
     37     -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' &gt; \
     38     `dirname $(gcc --print-libgcc-file-name)`/specs
     39</userinput></screen>
    6040
    6141<para>It is a good idea to visually inspect the specs file to verify the intended
     
    7656
    7757<screen><userinput>echo 'main(){}' &gt; dummy.c
    78 cc dummy.c
     58cc dummy.c -Wl,--verbose &amp;&gt; dummy.log
    7959readelf -l a.out | grep ': /lib'</userinput></screen>
    8060
     
    8868the prefix of our dynamic linker.</para>
    8969
     70<para>Now make sure that we're setup to use the correct start files:</para>
     71
     72<screen><userinput>grep "/usr/lib/crt.* " dummy.log</userinput></screen>
     73
     74<para>If everything is working correctly, there should be no errors,
     75and the output of the last command will be:</para>
     76
     77<screen><computeroutput>attempt to open /usr/lib/crt1.o succeeded
     78attempt to open /usr/lib/crti.o succeeded
     79attempt to open /usr/lib/crtn.o succeeded</computeroutput></screen>
     80
     81<para>Next make sure that we're using the correct libc:</para>
     82
     83<screen><userinput>grep "/lib/libc.so.6 " dummy.log</userinput></screen>
     84
     85<para>If everything is working correctly, there should be no errors,
     86and the output of the last command will be:</para>
     87
     88<screen><computeroutput>attempt to open /lib/libc.so.6 succeeded</computeroutput></screen>
     89
     90<para>Lastly, make sure GCC is using the correct dynamic linker:</para>
     91
     92<screen><userinput>grep found dummy.log</userinput></screen>
     93
     94<para>If everything is working correctly, there should be no errors,
     95and the output of the last command will be (allowing for
     96platform-specific differences in dynamic linker name):</para>
     97
     98<screen><computeroutput>found ld-linux.so.2 at /lib/ld-linux.so.2</computeroutput></screen>
     99
    90100<para>If the output does not appear as shown above or is not received
    91101at all, then something is seriously wrong. Investigate and retrace the
     
    98108files:</para>
    99109
    100 <screen><userinput>rm -v dummy.c a.out</userinput></screen></caution>
     110<screen><userinput>rm -v dummy.c a.out dummy.log</userinput></screen></caution>
    101111
    102112</sect1>
Note: See TracChangeset for help on using the changeset viewer.