Changeset e6ab4b5 for chapter06/readjusting.xml
- Timestamp:
- 02/03/2006 06:23:22 PM (19 years ago)
- Children:
- fa994c9
- Parents:
- b4cd3c5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter06/readjusting.xml
rb4cd3c5 re6ab4b5 10 10 <para>Now that the final C libraries have been installed, it is time to adjust 11 11 the toolchain again. The toolchain will be adjusted so that it will link any 12 newly compiled program against these new libraries. This is the sameprocess12 newly compiled program against these new libraries. This is a similar process 13 13 used in the <quote>Adjusting</quote> phase in the beginning of <xref 14 14 linkend="chapter-temporary-tools"/>, but with the adjustments reversed. In <xref … … 20 20 directories.</para> 21 21 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 23 replace it with the adjusted linker we made in chapter 5. We'll also create a 24 link to its counterpart in <filename class="directory">/tools/$(gcc -dumpmachine)/bin</filename>.</para> 26 25 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} 27 mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} 28 mv -v /tools/bin/{ld-new,ld} 29 ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld</userinput></screen> 52 30 53 31 <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> 32 dynamic linker, and so that GCC knows where to find its start files. 33 A <command>perl</command> command accomplishes this:</para> 55 34 56 <screen><userinput>SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs && 57 gcc -dumpspecs > $SPECFILE && 58 sed -i 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE && 59 unset SPECFILE</userinput></screen> 35 <screen><userinput>gcc -dumpspecs | \ 36 perl -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;' > \ 38 `dirname $(gcc --print-libgcc-file-name)`/specs 39 </userinput></screen> 60 40 61 41 <para>It is a good idea to visually inspect the specs file to verify the intended … … 76 56 77 57 <screen><userinput>echo 'main(){}' > dummy.c 78 cc dummy.c 58 cc dummy.c -Wl,--verbose &> dummy.log 79 59 readelf -l a.out | grep ': /lib'</userinput></screen> 80 60 … … 88 68 the prefix of our dynamic linker.</para> 89 69 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, 75 and the output of the last command will be:</para> 76 77 <screen><computeroutput>attempt to open /usr/lib/crt1.o succeeded 78 attempt to open /usr/lib/crti.o succeeded 79 attempt 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, 86 and 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, 95 and the output of the last command will be (allowing for 96 platform-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 90 100 <para>If the output does not appear as shown above or is not received 91 101 at all, then something is seriously wrong. Investigate and retrace the … … 98 108 files:</para> 99 109 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> 101 111 102 112 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.