#!/bin/sh # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions source ../packages-list # 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 && # 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. gcc -dumpspecs | sed \ -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \ -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ `dirname $(gcc --print-libgcc-file-name)`/specs && # Testing toolchain cd /tmp && echo 'main(){}' > dummy.c && cc dummy.c -Wl,--verbose &> dummy.log && if [ ! readelf -l a.out | grep 'Requesting program interpreter: /lib/' \ 1> /dev/null 2>&1 ]; then exit 1 fi && if [ ! grep "attempt to open /usr/lib/crt.* succeeded" dummy.log 1> /dev/null 2>&1 ]; then exit 1 fi && if [ ! grep "attempt to open /lib/libc.so.6 succeeded" dummy.log 1> /dev/null 2>&1 ]; then exit 1 fi && if [ ! grep "found ld-linux.so.2 at /lib/ld-linux.so.2" dummy.log 1> /dev/null 2>&1 ]; then exit 1 fi && rm dummy.c a.out # Return last error exit $?