From 3f3931b0a87f6b5e217b5ffd8bbfcd758045f8c0 Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Tue, 7 Feb 2006 19:39:29 +0000 Subject: Indenting chapter 6, part 9 git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7362 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/readjusting.xml | 135 +++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 66 deletions(-) (limited to 'chapter06/readjusting.xml') diff --git a/chapter06/readjusting.xml b/chapter06/readjusting.xml index 18fc83d4a..e108286f0 100644 --- a/chapter06/readjusting.xml +++ b/chapter06/readjusting.xml @@ -1,113 +1,116 @@ - %general-entities; ]> + -Re-adjusting the Toolchain - - -Now that the final C libraries have been installed, it is time to adjust -the toolchain again. The toolchain will be adjusted so that it will link any -newly compiled program against these new libraries. This is a similar process -used in the Adjusting phase in the beginning of , but with the adjustments reversed. In , the chain was guided from the host's -/{,usr/}lib directories to the new -/tools/lib directory. Now, the chain will -be guided from that same /tools/lib -directory to the LFS /{,usr/}lib -directories. - -First, backup the /tools linker, and -replace it with the adjusted linker we made in chapter 5. We'll also create a -link to its counterpart in /tools/$(gcc -dumpmachine)/bin. + + + Re-adjusting the Toolchain + + Now that the final C libraries have been installed, it is time to adjust + the toolchain again. The toolchain will be adjusted so that it will link any + newly compiled program against these new libraries. This is a similar process + used in the Adjusting phase in the beginning of , but with the adjustments reversed. In , the chain was guided from the host's + /{,usr/}lib directories to the new + /tools/lib directory. Now, the chain will + be guided from that same /tools/lib + directory to the LFS /{,usr/}lib + directories. + + First, backup the /tools linker, + and replace it with the adjusted linker we made in chapter 5. We'll also create + a link to its counterpart in /tools/$(gcc + -dumpmachine)/bin. mv -v /tools/bin/{ld,ld-old} mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} mv -v /tools/bin/{ld-new,ld} ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld -Next, amend the GCC specs file so that it points to the new -dynamic linker, and so that GCC knows where to find its start files. -A perl command accomplishes this: + Next, amend the GCC specs file so that it points to the new + dynamic linker, and so that GCC knows where to find its start files. + A perl command accomplishes this: gcc -dumpspecs | \ perl -p -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g;' \ - -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \ - `dirname $(gcc --print-libgcc-file-name)`/specs - - -It is a good idea to visually inspect the specs file to verify the intended -change was actually made. - -If working on a platform where the name of the -dynamic linker is something other than -ld-linux.so.2, substitute -ld-linux.so.2 with the name of the platform's -dynamic linker in the above commands. Refer back to if -necessary. - -It is imperative at this point to stop and ensure that -the basic functions (compiling and linking) of the adjusted toolchain -are working as expected. To do this, perform a sanity -check: + -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \ + `dirname $(gcc --print-libgcc-file-name)`/specs + + It is a good idea to visually inspect the specs file to verify the + intended change was actually made. + + + If working on a platform where the name of the dynamic linker is + something other than ld-linux.so.2, + substitute ld-linux.so.2 with the name of the platform's + dynamic linker in the above commands. Refer back to if necessary. + + + + It is imperative at this point to stop and ensure that the basic + functions (compiling and linking) of the adjusted toolchain are working + as expected. To do this, perform a sanity check: echo 'main(){}' > dummy.c cc dummy.c -Wl,--verbose &> dummy.log readelf -l a.out | grep ': /lib' -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): + 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): [Requesting program interpreter: /lib/ld-linux.so.2] -Note that /lib is now -the prefix of our dynamic linker. + Note that /lib is now + the prefix of our dynamic linker. -Now make sure that we're setup to use the correct start files: + Now make sure that we're setup to use the correct start files: grep "/usr/lib/crt.* " dummy.log -If everything is working correctly, there should be no errors, -and the output of the last command will be: + If everything is working correctly, there should be no errors, + and the output of the last command will be: attempt to open /usr/lib/crt1.o succeeded attempt to open /usr/lib/crti.o succeeded attempt to open /usr/lib/crtn.o succeeded -Next make sure that we're using the correct libc: + Next make sure that we're using the correct libc: grep "/lib/libc.so.6 " dummy.log -If everything is working correctly, there should be no errors, -and the output of the last command will be: + If everything is working correctly, there should be no errors, + and the output of the last command will be: attempt to open /lib/libc.so.6 succeeded -Lastly, make sure GCC is using the correct dynamic linker: + Lastly, make sure GCC is using the correct dynamic linker: grep found dummy.log -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): + 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): found ld-linux.so.2 at /lib/ld-linux.so.2 -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 -reason is that something went wrong with the specs file amendment -above. Any issues will need to be resolved before continuing on with -the process. + 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 + reason is that something went wrong with the specs file amendment + above. Any issues will need to be resolved before continuing on with + the process. -Once everything is working correctly, clean up the test -files: + Once everything is working correctly, clean up the test + files: -rm -v dummy.c a.out dummy.log +rm -v dummy.c a.out dummy.log + - -- cgit v1.2.3-54-g00ecf