diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml
index 2c7de998c..baec8f3a8 100644
--- a/chapter05/glibc.xml
+++ b/chapter05/glibc.xml
@@ -189,32 +189,98 @@ cd build
sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd
-
- At this point, it is imperative to stop and ensure that the basic
- functions (compiling and linking) of the new toolchain are working as
- expected. To perform a sanity check, run the following commands:
+ Now that our cross toolchain is in place, it is important to ensure
+ that compiling and linking will work as expected. We do this by performing
+ some sanity checks:
-echo 'int main(){}' | $LFS_TGT-gcc -xc -
-readelf -l a.out | grep ld-linux
+echo 'int main(){}' | $LFS_TGT-gcc -x c - -v -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 of the form:
+ There should be no errors,
+ and the output of the last command will be (allowing for
+ platform-specific differences in the dynamic linker name):
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
- Note that for 32-bit machines, the interpreter name will be
- /lib/ld-linux.so.2.
+ Note that this path should not contain
+ /mnt/lfs (or the value of
+ the LFS variable if you used a different one). The path is
+ resolved when the compiled program is executed, and that should only happen
+ after we enter the chroot environment where the kernel would consider
+ $LFS as the root directory
+ (/).
- If the output is not as shown above, or there is no output at all,
- then something is wrong. Investigate and retrace the steps to find out
- where the problem is and correct it. This issue must be resolved before
- continuing.
+ Now make sure that we're set up to use the correct start files:
- Once all is well, clean up the test file:
+grep -E -o "$LFS/lib.*/S?crt[1in].*succeeded" dummy.log
-rm -v a.out
+ The output of the last command should be:
-
+/mnt/lfs/lib/../lib/Scrt1.o succeeded
+/mnt/lfs/lib/../lib/crti.o succeeded
+/mnt/lfs/lib/../lib/crtn.o succeeded
+
+ Verify that the compiler is searching for the correct header
+ files:
+
+grep -B3 "^ $LFS/usr/include" dummy.log
+
+ This command should return the following output:
+
+#include <...> search starts here:
+ /mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/&gcc-version;/include
+ /mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/&gcc-version;/include-fixed
+ /mnt/lfs/usr/include
+
+ Again, the directory named after your target triplet may be
+ different than the above, depending on your system architecture.
+
+ Next, verify that the new linker is being used with the correct search paths:
+
+grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
+
+ References to paths that have components with '-linux-gnu' should
+ be ignored, but otherwise the output of the last command should be:
+
+SEARCH_DIR("=/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib64")
+SEARCH_DIR("=/usr/local/lib64")
+SEARCH_DIR("=/lib64")
+SEARCH_DIR("=/usr/lib64")
+SEARCH_DIR("=/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib")
+SEARCH_DIR("=/usr/local/lib")
+SEARCH_DIR("=/lib")
+SEARCH_DIR("=/usr/lib");
+
+ A 32-bit system may use a few other directories, but anyway
+ the important facet here is all the pathes should begin with an equal sign
+ (=), which would be replaced with the sysroot
+ directory that we've configured for the linker.
+
+ Next make sure that we're using the correct libc:
+
+grep "/lib.*/libc.so.6 " dummy.log
+
+ The output of the last command should be:
+
+attempt to open /mnt/lfs/usr/lib/libc.so.6 succeeded
+
+ Make sure GCC is using the correct dynamic linker:
+
+grep found dummy.log
+
+ The output of the last command should be (allowing for
+ platform-specific differences in dynamic linker name):
+
+found ld-linux-x86-64.so.2 at /mnt/lfs/usr/lib/ld-linux-x86-64.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. Any
+ issues should be resolved before continuing with the process.
+
+ Once everything is working correctly, clean up the test files:
+
+rm -v a.out dummy.log
Building the packages in the next chapter will serve as an
additional check that the toolchain has been built properly. If some